Merge pull request #431 from sfu/fix-alerts_spillover
Fix bug that causes alerts to affect other courses
This commit is contained in:
commit
f3f5eeb911
|
@ -110,7 +110,7 @@ class Alert < ActiveRecord::Base
|
|||
def self.evaluate_for_course(course, account_alerts = nil, include_user_notes = nil)
|
||||
return unless course.available?
|
||||
|
||||
alerts = Array(account_alerts)
|
||||
alerts = Array.new(account_alerts || [])
|
||||
alerts.concat course.alerts.all
|
||||
return if alerts.empty?
|
||||
|
||||
|
|
|
@ -123,6 +123,16 @@ describe Alert do
|
|||
Alert.evaluate_for_course(@course)
|
||||
Alert.sent_alerts.should be_blank
|
||||
end
|
||||
|
||||
it "should not trigger any alerts in subsequent courses" do
|
||||
course_with_teacher(:active_all => 1)
|
||||
student_in_course(:active_all => 1)
|
||||
@course.alerts.create!(:recipients => [:student], :criteria => [{:criterion_type => 'Interaction', :threshold => 7}])
|
||||
@course.start_at = Time.now - 30.days
|
||||
account_alerts = []
|
||||
Alert.evaluate_for_course(@course, account_alerts)
|
||||
account_alerts.should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context 'repetition' do
|
||||
|
|
Loading…
Reference in New Issue