send teacher notifications of submission comments before assignment is submitted; fixes #4516
Change-Id: I81d932790e82065160351349ada13ac4cd1994e1 Reviewed-on: https://gerrit.instructure.com/3513 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
6b403d6aa9
commit
3d116c6434
|
@ -104,18 +104,18 @@ class SubmissionComment < ActiveRecord::Base
|
|||
p.dispatch :submission_comment
|
||||
p.to { [submission.user] - [author] }
|
||||
p.whenever {|record|
|
||||
record.just_created &&
|
||||
record.submission.assignment && (!record.submission.assignment.context.admins.include?(author) || record.submission.assignment.published?) &&
|
||||
record.just_created &&
|
||||
record.submission.assignment &&
|
||||
(!record.submission.assignment.context.admins.include?(author) || record.submission.assignment.published?) &&
|
||||
(record.created_at - record.submission.created_at rescue 0) > 30
|
||||
}
|
||||
|
||||
# Too noisy?
|
||||
p.dispatch :submission_comment_for_teacher
|
||||
p.to { submission.assignment.context.admins_in_charge_of(author_id) - [author] }
|
||||
p.whenever {|record|
|
||||
record.just_created &&
|
||||
record.submission.user_id == record.author_id && record.submission.submitted_at &&
|
||||
(record.created_at - record.submission.submitted_at rescue 0) > 30
|
||||
record.just_created &&
|
||||
record.submission.user_id == record.author_id &&
|
||||
(!record.submission.submitted_at || ((record.created_at - record.submission.submitted_at rescue 0) > 30))
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -50,12 +50,9 @@ describe SubmissionComment do
|
|||
Notification.create(:name => 'Submission Comment')
|
||||
@comment = @submission.add_comment(:author => te.user, :comment => "some comment")
|
||||
@comment.messages_sent.should_not be_include('Submission Comment')
|
||||
|
||||
# @comment.save!
|
||||
# @comment.messages_sent.should be_nil
|
||||
end
|
||||
|
||||
it "should dispatch notification on create if assignment is not published" do
|
||||
it "should dispatch notification on create if assignment is published" do
|
||||
assignment_model
|
||||
@assignment.workflow_state = 'published'
|
||||
@assignment.save
|
||||
|
@ -68,9 +65,20 @@ describe SubmissionComment do
|
|||
Notification.create(:name => 'Submission Comment')
|
||||
@comment = @submission.add_comment(:author => se.user, :comment => "some comment")
|
||||
@comment.messages_sent.should be_include('Submission Comment')
|
||||
|
||||
# @comment.save!
|
||||
# @comment.messages_sent.should be_nil
|
||||
end
|
||||
|
||||
it "should dispatch notification on create to teachers even if submission not submitted yet" do
|
||||
assignment_model
|
||||
@assignment.workflow_state = 'published'
|
||||
@assignment.save
|
||||
@course.offer
|
||||
@course.enroll_teacher(user)
|
||||
se = @course.enroll_student(user)
|
||||
@submission = @assignment.find_or_create_submission(se.user)
|
||||
@submission.save
|
||||
Notification.create(:name => 'Submission Comment For Teacher')
|
||||
@comment = @submission.add_comment(:author => se.user, :comment => "some comment")
|
||||
@comment.messages_sent.should be_include('Submission Comment For Teacher')
|
||||
end
|
||||
|
||||
it "should respond to attachments" do
|
||||
|
|
Loading…
Reference in New Issue