update email notification for peer review to be anonymous
*Test Plan Create an assignment with anonymous peer reviews enabled create two students set one student up as a peer reviewer of other as first student submit assignment as student two peer review assignment make sure peer review notifications show anonymous Change-Id: If1a474192504a26ca09f4086514900809bdb6d81 fixes: PFS-2581 Reviewed-on: https://gerrit.instructure.com/62432 Tested-by: Jenkins Reviewed-by: Cameron Sutter <csutter@instructure.com> QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Allison Weiss <allison@instructure.com>
This commit is contained in:
parent
fb08dd4499
commit
3822474b96
|
@ -0,0 +1,15 @@
|
|||
module Messages::PeerReviewsHelper
|
||||
|
||||
def reviewee_name(asset, reviewer)
|
||||
asset.can_read_assessment_user_name?(reviewer, nil) ? asset.asset.user.name : I18n.t(:anonymous_user, 'Anonymous User')
|
||||
end
|
||||
|
||||
def submission_comment_author(submission_comment, user)
|
||||
submission_comment.can_read_author?(user, nil) ? (submission_comment.author_name || I18n.t(:someone, "Someone")) : I18n.t(:anonymous_user, 'Anonymous User')
|
||||
end
|
||||
|
||||
def submission_comment_submittor(submission_comment, user)
|
||||
submission_comment.submission.can_read_submission_user_name?(user, nil) ? submission_comment.submission.user.short_name : I18n.t(:anonymous_user, 'Anonymous User')
|
||||
end
|
||||
|
||||
end
|
|
@ -3,9 +3,9 @@
|
|||
<% end %>
|
||||
|
||||
<% define_content :subject do %>
|
||||
<%= t('#messages.peer_review_invitation.email.subject', "Assigned peer review for %{reviewee}", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.email.subject', "Assigned peer review for %{reviewee}", :reviewee => reviewee_name(asset, user))%>
|
||||
<% end %>
|
||||
|
||||
<%= t('#messages.peer_review_invitation.email.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.email.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => reviewee_name(asset, user))%>
|
||||
|
||||
<%= content :link %>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% end %>
|
||||
|
||||
<% define_content :subject do %>
|
||||
<%= t('#messages.peer_review_invitation.email.subject', "Assigned peer review for %{reviewee}", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.email.subject', "Assigned peer review for %{reviewee}", :reviewee => reviewee_name(asset, user))%>
|
||||
<% end %>
|
||||
|
||||
<% define_content :footer_link do %>
|
||||
|
@ -12,4 +12,4 @@
|
|||
</a>
|
||||
<% end %>
|
||||
|
||||
<%= t('#messages.peer_review_invitation.email.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.email.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => reviewee_name(asset, user))%>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
<%= t('#messages.peer_review_invitation.summary.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.summary.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => reviewee_name(asset, user))%>
|
||||
|
||||
<%= t :more_info, "More info at %{url}", :url => HostUrl.context_host(asset.context) %>
|
||||
<%= t :more_info, "More info at %{url}", :url => HostUrl.context_host(asset.context) %>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% end %>
|
||||
|
||||
<% define_content :subject do %>
|
||||
<%= t('#messages.peer_review_invitation.email.subject', "Assigned peer review for %{reviewee}", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.email.subject', "Assigned peer review for %{reviewee}", :reviewee => reviewee_name(asset, user))%>
|
||||
<% end %>
|
||||
|
||||
<%= t('#messages.peer_review_invitation.email.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.email.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => reviewee_name(asset, user))%>
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
<%= polymorphic_url([asset.context, asset.asset.assignment, :submission], id: asset.asset.user_id) %>
|
||||
<% end -%>
|
||||
|
||||
<%= t('#messages.peer_review_invitation.twitter.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => asset.asset.user.name)%>
|
||||
<%= t('#messages.peer_review_invitation.twitter.body', "You've been invited to peer review %{reviewee}. Follow the link below to review them!", :reviewee => reviewee_name(asset, user))%>
|
||||
|
|
|
@ -3,10 +3,16 @@
|
|||
<% end %>
|
||||
|
||||
<% define_content :subject do %>
|
||||
<%= t :subject, "Submission Comment: %{user}, %{assignment}, %{context}", :user => asset.submission.user.short_name, :assignment => asset.submission.assignment.title, :context => asset.submission.assignment.context.name %>
|
||||
<%= t :subject, "Submission Comment: %{user}, %{assignment}, %{context}",
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:assignment => asset.submission.assignment.title,
|
||||
:context => asset.submission.assignment.context.name %>
|
||||
<% end %>
|
||||
|
||||
<%= t :body, "%{author} just made a new comment on the submission for %{user} for %{assignment}", :author => (asset.author_name || t(:someone, "Someone")), :user => asset.submission.user.short_name, :assignment => asset.submission.assignment.title %>
|
||||
<%= t :body, "%{author} just made a new comment on the submission for %{user} for %{assignment}",
|
||||
:author => submission_comment_author(asset, user),
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:assignment => asset.submission.assignment.title %>
|
||||
|
||||
<%= asset.comment %>
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
<% end %>
|
||||
|
||||
<% define_content :subject do %>
|
||||
<%= t :subject, "Submission Comment: %{user}, %{assignment}, %{context}", :user => asset.submission.user.short_name, :assignment => asset.submission.assignment.title, :context => asset.submission.assignment.context.name %>
|
||||
<%= t :subject, "Submission Comment: %{user}, %{assignment}, %{context}",
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:assignment => asset.submission.assignment.title,
|
||||
:context => asset.submission.assignment.context.name %>
|
||||
<% end %>
|
||||
|
||||
<% define_content :footer_link do %>
|
||||
|
@ -13,47 +16,49 @@
|
|||
<% end %>
|
||||
|
||||
<p><%= t :body, "%{author} just made a new comment on the submission for %{user} for %{assignment}",
|
||||
:author => (asset.author_name || t(:someone, "Someone")),
|
||||
:user => asset.submission.user.short_name,
|
||||
:author => submission_comment_author(asset, user),
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:assignment => asset.submission.assignment.title %></p>
|
||||
|
||||
<p><%= asset.comment.gsub(/\n/,'</p><p>') %></p>
|
||||
|
||||
<% if avatar_enabled? %>
|
||||
<table border="0" style="border-collapse: collapse">
|
||||
<tr height="30px">
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td align="left" width="50" style="width: 50px"><img style="border-radius: 50px; height: 50px; width: 50px;" height="50" width="50" src="<%=author_avatar_url%>" alt="<%=author_short_name%>"> </td>
|
||||
<td width="10"></td>
|
||||
<td>
|
||||
<table border="0" style="font-size: 14px; color: #444444; background-color: #ffffff; font-family: 'Open Sans', 'Lucida Grande', 'Segoe UI', Arial, Verdana, 'Lucida Sans Unicode', Tahoma, 'Sans Serif';" valign="top" align="left">
|
||||
<tr>
|
||||
<td valign="bottom" align="left">
|
||||
<b><%= author_short_name%></b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="left">
|
||||
<a href="mailto:<%= author_email_address %>">
|
||||
<%= author_email_address%>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% else %>
|
||||
<p height="30px"></p>
|
||||
<p>
|
||||
<b><%= author_short_name%></b>
|
||||
<br/>
|
||||
<a href="mailto:<%= author_email_address %>">
|
||||
<%= author_email_address%>
|
||||
</a>
|
||||
</p>
|
||||
<% if asset.can_read_author?(user, nil) %>
|
||||
<% if avatar_enabled? %>
|
||||
<table border="0" style="border-collapse: collapse">
|
||||
<tr height="30px">
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td align="left" width="50" style="width: 50px"><img style="border-radius: 50px; height: 50px; width: 50px;" height="50" width="50" src="<%=author_avatar_url%>" alt="<%=author_short_name%>"> </td>
|
||||
<td width="10"></td>
|
||||
<td>
|
||||
<table border="0" style="font-size: 14px; color: #444444; background-color: #ffffff; font-family: 'Open Sans', 'Lucida Grande', 'Segoe UI', Arial, Verdana, 'Lucida Sans Unicode', Tahoma, 'Sans Serif';" valign="top" align="left">
|
||||
<tr>
|
||||
<td valign="bottom" align="left">
|
||||
<b><%= author_short_name%></b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" align="left">
|
||||
<a href="mailto:<%= author_email_address %>">
|
||||
<%= author_email_address%>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% else %>
|
||||
<p height="30px"></p>
|
||||
<p>
|
||||
<b><%= author_short_name%></b>
|
||||
<br/>
|
||||
<a href="mailto:<%= author_email_address %>">
|
||||
<%= author_email_address%>
|
||||
</a>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if asset.media_comment? %>
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
<%= t :body, "New comment by %{author} for %{assignment}, %{user}, %{context}.", :author => asset.author.short_name, :assignment => asset.submission.assignment.title, :user => asset.submission.user.short_name, :context => asset.submission.assignment.context.name %>
|
||||
<%= t :body, "New comment by %{author} for %{assignment}, %{user}, %{context}.",
|
||||
:author => submission_comment_author(asset, user),
|
||||
:assignment => asset.submission.assignment.title,
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:context => asset.submission.assignment.context.name %>
|
||||
|
||||
<%= t :more_info, "More info at %{url}", :url => HostUrl.context_host(asset.submission.assignment.context) %>
|
||||
|
|
|
@ -3,7 +3,13 @@
|
|||
<% end %>
|
||||
|
||||
<% define_content :subject do %>
|
||||
<%= t :subject, "Submission Comment: %{user}, %{assignment}, %{context}", :user => asset.submission.user.short_name, :assignment => asset.submission.assignment.title, :context => asset.submission.assignment.context.name %>
|
||||
<%= t :subject, "Submission Comment: %{user}, %{assignment}, %{context}",
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:assignment => asset.submission.assignment.title,
|
||||
:context => asset.submission.assignment.context.name %>
|
||||
<% end %>
|
||||
|
||||
<%= t :body, "%{author} just made a new comment on the submission for %{user} for %{assignment}.", :author => (asset.author_name || t(:someone, "Someone")), :user => asset.submission.user.short_name, :assignment => asset.submission.assignment.title %>
|
||||
<%= t :body, "%{author} just made a new comment on the submission for %{user} for %{assignment}.",
|
||||
:author => submission_comment_author(asset, user),
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:assignment => asset.submission.assignment.title %>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<% define_content :link do -%>
|
||||
<%= polymorphic_url([asset.submission.assignment.context, asset.submission.assignment, :submission], id: asset.submission.user) %>
|
||||
<% end -%>
|
||||
<%= t :tweet, "Canvas Alert - Comment: %{author} for %{assignment}, %{user}, %{context}.",
|
||||
:author => asset.author.short_name,
|
||||
:assignment => asset.submission.assignment.title,
|
||||
:user => asset.submission.user.short_name,
|
||||
<%= t :tweet, "Canvas Alert - Comment: %{author} for %{assignment}, %{user}, %{context}.",
|
||||
:author => submission_comment_author(asset, user),
|
||||
:assignment => asset.submission.assignment.title,
|
||||
:user => submission_comment_submittor(asset, user),
|
||||
:context => asset.submission.assignment.context.name %>
|
|
@ -33,9 +33,11 @@ class Message < ActiveRecord::Base
|
|||
include TextHelper
|
||||
include HtmlTextHelper
|
||||
include Workflow
|
||||
include Messages::PeerReviewsHelper
|
||||
|
||||
extend TextHelper
|
||||
|
||||
|
||||
# Associations
|
||||
belongs_to :asset_context, :polymorphic => true
|
||||
belongs_to :communication_channel
|
||||
|
|
|
@ -8,7 +8,7 @@ module Messages
|
|||
|
||||
def from_name
|
||||
return nil unless has_named_source?
|
||||
source_user.short_name
|
||||
anonymized_user
|
||||
end
|
||||
|
||||
def reply_to_name
|
||||
|
@ -18,6 +18,14 @@ module Messages
|
|||
|
||||
private
|
||||
|
||||
def anonymized_user
|
||||
if is_anonymized_asset?
|
||||
asset.can_read_author?(asset.recipient, nil) ? source_user.short_name : I18n.t(:anonymous_user, 'Anonymous User')
|
||||
else
|
||||
source_user.short_name
|
||||
end
|
||||
end
|
||||
|
||||
def source_user
|
||||
if is_author_asset?
|
||||
asset.author
|
||||
|
@ -42,6 +50,14 @@ module Messages
|
|||
"Assignment Resubmitted"
|
||||
]
|
||||
|
||||
ANONYMIZED_NOTIFICATIONS = [
|
||||
"Submission Comment"
|
||||
]
|
||||
|
||||
def is_anonymized_asset?
|
||||
ANONYMIZED_NOTIFICATIONS.include?(notification_name) && asset.respond_to?(:recipient)
|
||||
end
|
||||
|
||||
def is_author_asset?
|
||||
SOURCE_AUTHOR_NOTIFICATIONS.include?(notification_name)
|
||||
end
|
||||
|
|
|
@ -275,6 +275,12 @@ class Submission < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def can_read_submission_user_name?(user, session)
|
||||
!self.assignment.anonymous_peer_reviews? ||
|
||||
self.user_id == user.id ||
|
||||
self.assignment.context.grants_right?(user, session, :view_all_grades)
|
||||
end
|
||||
|
||||
def update_final_score
|
||||
if score_changed? || excused_changed?
|
||||
if skip_grade_calc
|
||||
|
|
|
@ -106,10 +106,7 @@ class SubmissionComment < ActiveRecord::Base
|
|||
can :read and can :delete
|
||||
|
||||
given { |user, session|
|
||||
!self.anonymous? ||
|
||||
self.author == user ||
|
||||
self.submission.assignment.context.grants_right?(user, session, :view_all_grades) ||
|
||||
self.submission.assignment.context.grants_right?(self.author, session, :view_all_grades)
|
||||
self.can_read_author?(user, session)
|
||||
}
|
||||
can :read_author
|
||||
end
|
||||
|
@ -135,6 +132,13 @@ class SubmissionComment < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
def can_read_author?(user, session)
|
||||
(!self.anonymous? && !self.submission.assignment.anonymous_peer_reviews?) ||
|
||||
self.author == user ||
|
||||
self.submission.assignment.context.grants_right?(user, session, :view_all_grades) ||
|
||||
self.submission.assignment.context.grants_right?(self.author, session, :view_all_grades)
|
||||
end
|
||||
|
||||
def update_participants
|
||||
self.submission_comment_participants.where(user_id: self.submission.user_id, participation_type: 'submitter').first_or_create
|
||||
self.submission_comment_participants.where(user_id: self.author_id, participation_type: 'author').first_or_create
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
#
|
||||
# Copyright (C) 2015 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
|
||||
describe Messages::PeerReviewsHelper do
|
||||
|
||||
describe 'assessment requests' do
|
||||
|
||||
it 'should should return reviewee name' do
|
||||
assessment_request_model
|
||||
expect(reviewee_name(@assessment_request, @user)).to eq(@assessment_request.asset.user.name)
|
||||
end
|
||||
|
||||
it 'should return anonymous when anonymous peer reviews enabled' do
|
||||
assessment_request_model
|
||||
assignment = @assessment_request.asset.assignment
|
||||
assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@assessment_request.reload
|
||||
expect(reviewee_name(@assessment_request, @user2)).to eq(I18n.t(:anonymous_user, 'Anonymous User'))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'submission comments' do
|
||||
|
||||
context 'anonymous peer reviews disabled' do
|
||||
|
||||
it 'should return author name' do
|
||||
submission_model
|
||||
comment = @submission.add_comment(:comment => "new comment")
|
||||
expect(submission_comment_author(comment, @user)).to eq(comment.author_name)
|
||||
end
|
||||
|
||||
it 'should return anonymous' do
|
||||
@user2 = user_model
|
||||
submission_model
|
||||
comment = @submission.add_comment(:comment => "new comment", :user => @user2)
|
||||
@submission.assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
comment.reload
|
||||
expect(submission_comment_author(comment, @user)).to eq(I18n.t(:anonymous_user, 'Anonymous User'))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'anonymous peer reviews enabled' do
|
||||
|
||||
it 'should return submittor' do
|
||||
submission_model
|
||||
comment = @submission.add_comment(:comment => "new comment")
|
||||
expect(submission_comment_submittor(comment, @user)).to eq(@submission.user.short_name)
|
||||
end
|
||||
|
||||
it 'should return anonymous' do
|
||||
@user2 = user_model
|
||||
submission_model
|
||||
comment = @submission.add_comment(:comment => "new comment", :user => @user2)
|
||||
@submission.assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
comment.reload
|
||||
expect(submission_comment_submittor(comment, @user2)).to eq(I18n.t(:anonymous_user, 'Anonymous User'))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -20,11 +20,24 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'peer_review_invitation.email' do
|
||||
it "should render" do
|
||||
|
||||
before :each do
|
||||
assessment_request_model
|
||||
@object = @assessment_request
|
||||
@object.reload
|
||||
expect(@object.context).not_to be_nil
|
||||
generate_message(:peer_review_invitation, :email, @object)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:peer_review_invitation, :email, @object)
|
||||
expect(message.html_body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
assignment = @assessment_request.asset.assignment
|
||||
assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:peer_review_invitation, :email, @object)
|
||||
expect(message.html_body).to include('Anonymous User')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,11 +19,25 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'peer_review_invitation.sms' do
|
||||
it "should render" do
|
||||
|
||||
before :each do
|
||||
assessment_request_model
|
||||
@object = @assessment_request
|
||||
@object.reload
|
||||
expect(@object.context).not_to be_nil
|
||||
generate_message(:peer_review_invitation, :sms, @object)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:peer_review_invitation, :sms, @object)
|
||||
expect(message.body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
assignment = @assessment_request.asset.assignment
|
||||
assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:peer_review_invitation, :sms, @object)
|
||||
expect(message.body).to include('Anonymous User')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,11 +20,25 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'peer_review_invitation.summary' do
|
||||
it "should render" do
|
||||
|
||||
before :each do
|
||||
assessment_request_model
|
||||
@object = @assessment_request
|
||||
@object.reload
|
||||
expect(@object.context).not_to be_nil
|
||||
generate_message(:peer_review_invitation, :summary, @object)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:peer_review_invitation, :summary, @object)
|
||||
expect(message.body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
assignment = @assessment_request.asset.assignment
|
||||
assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:peer_review_invitation, :summary, @object)
|
||||
expect(message.body).to include('Anonymous User')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,11 +20,23 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'peer_review_invitation.twitter' do
|
||||
it "should render" do
|
||||
before :each do
|
||||
assessment_request_model
|
||||
@object = @assessment_request
|
||||
@object.reload
|
||||
expect(@object.context).not_to be_nil
|
||||
generate_message(:peer_review_invitation, :twitter, @object)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:peer_review_invitation, :twitter, @object)
|
||||
expect(message.body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
assignment = @assessment_request.asset.assignment
|
||||
assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:peer_review_invitation, :twitter, @object)
|
||||
expect(message.body).to include('Anonymous User')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,13 +20,26 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'submission_comment.email' do
|
||||
it "should render" do
|
||||
|
||||
before :each do
|
||||
submission_model
|
||||
@object = @submission.add_comment(:comment => "new comment")
|
||||
expect(@object.submission).not_to be_nil
|
||||
expect(@object.submission.assignment).not_to be_nil
|
||||
expect(@object.submission.assignment.context).not_to be_nil
|
||||
expect(@object.submission.user).not_to be_nil
|
||||
generate_message(:submission_comment, :email, @object)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:submission_comment, :email, @object)
|
||||
expect(message.html_body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
@submission.assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:submission_comment, :email, @object)
|
||||
expect(message.html_body).to include('Anonymous User')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,13 +20,26 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'submission_comment.sms' do
|
||||
it "should render" do
|
||||
|
||||
before :each do
|
||||
submission_model
|
||||
@object = @submission.add_comment(:comment => "new comment")
|
||||
expect(@object.submission).not_to be_nil
|
||||
expect(@object.submission.assignment).not_to be_nil
|
||||
expect(@object.submission.assignment.context).not_to be_nil
|
||||
expect(@object.submission.user).not_to be_nil
|
||||
generate_message(:submission_comment, :sms, @object)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:submission_comment, :sms, @object)
|
||||
expect(message.body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
@submission.assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:submission_comment, :sms, @object)
|
||||
expect(message.body).to include('Anonymous User')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,13 +20,26 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'submission_comment.summary' do
|
||||
it "should render" do
|
||||
|
||||
before :each do
|
||||
submission_model
|
||||
@object = @submission.add_comment(:comment => "new comment")
|
||||
expect(@object.submission).not_to be_nil
|
||||
expect(@object.submission.assignment).not_to be_nil
|
||||
expect(@object.submission.assignment.context).not_to be_nil
|
||||
expect(@object.submission.user).not_to be_nil
|
||||
generate_message(:submission_comment, :summary, @object)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:submission_comment, :summary, @object)
|
||||
expect(message.body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
@submission.assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:submission_comment, :summary, @object)
|
||||
expect(message.body).to include('Anonymous User')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
#
|
||||
# Copyright (C) 2011 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/messages_helper')
|
||||
|
||||
describe 'submission_comment.twitter' do
|
||||
|
||||
before :each do
|
||||
submission_model
|
||||
@object = @submission.add_comment(:comment => "new comment")
|
||||
expect(@object.submission).not_to be_nil
|
||||
expect(@object.submission.assignment).not_to be_nil
|
||||
expect(@object.submission.assignment.context).not_to be_nil
|
||||
expect(@object.submission.user).not_to be_nil
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
message = generate_message(:submission_comment, :twitter, @object)
|
||||
expect(message.body).to_not include('Anonymous User')
|
||||
end
|
||||
|
||||
it 'should show anonymous when anonymous peer review enabled' do
|
||||
@submission.assignment.update_attribute(:anonymous_peer_reviews, true)
|
||||
@object.reload
|
||||
message = generate_message(:submission_comment, :twitter, @object)
|
||||
expect(message.body).to include('Anonymous User')
|
||||
end
|
||||
|
||||
end
|
|
@ -7,7 +7,7 @@ module Messages
|
|||
let(:user){ stub("User", short_name: "User Name") }
|
||||
let(:asset){ stub("Asset", user: user, author: author) }
|
||||
|
||||
def asset_for(notification_name)
|
||||
def asset_for(notification_name, asset = asset)
|
||||
AssetContext.new(asset, notification_name)
|
||||
end
|
||||
|
||||
|
@ -37,6 +37,11 @@ module Messages
|
|||
it 'uses the user name for messages belonging to users' do
|
||||
expect(asset_for("Assignment Resubmitted").from_name).to eq "User Name"
|
||||
end
|
||||
|
||||
it 'returns Anonymous User' do
|
||||
asset2 = stub("Asset", user: user, author: author, recipient: user, can_read_author?: false)
|
||||
expect(asset_for("Submission Comment", asset2).from_name).to eq "Anonymous User"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue