fix journal observer tests, remove journal observer

This commit is contained in:
Tim Felgentreff 2010-10-27 11:42:15 +02:00
parent 8c5312e0ec
commit 1a2aa363bd
3 changed files with 24 additions and 15 deletions

View File

@ -824,6 +824,17 @@ class Issue < ActiveRecord::Base
end
IssueJournal.class_eval do
after_create :notify_of_updates
def notify_of_updates
return if self.version == 1
if Setting.notified_events.include?('issue_updated')
Mailer.deliver_issue_edit(self)
elsif Setting.notified_events.include?('issue_note_added') and !self.notes.blank?
Mailer.deliver_issue_edit(self)
end
end
# Shortcut
def new_status
if details.keys.include? 'status_id'

View File

@ -36,7 +36,7 @@ Rails::Initializer.run do |config|
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
config.active_record.observers = :journal_observer, :message_observer, :issue_observer, :news_observer, :document_observer, :wiki_content_observer
config.active_record.observers = :message_observer, :issue_observer, :news_observer, :document_observer, :wiki_content_observer
# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc

View File

@ -30,9 +30,9 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = ['issue_updated']
issue = Issue.find(:first)
user = User.find(:first)
journal = issue.init_journal(user, issue)
issue.init_journal(user)
assert journal.save
assert issue.send(:create_journal)
assert_equal 1, ActionMailer::Base.deliveries.size
end
@ -40,9 +40,9 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = []
issue = Issue.find(:first)
user = User.find(:first)
journal = issue.init_journal(user, issue)
issue.init_journal(user)
assert journal.save
assert issue.save
assert_equal 0, ActionMailer::Base.deliveries.size
end
@ -51,10 +51,9 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = ['issue_note_added']
issue = Issue.find(:first)
user = User.find(:first)
journal = issue.init_journal(user, issue)
journal.notes = 'This update has a note'
issue.init_journal(user, 'This update has a note')
assert journal.save
assert issue.save
assert_equal 1, ActionMailer::Base.deliveries.size
end
@ -62,10 +61,9 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = []
issue = Issue.find(:first)
user = User.find(:first)
journal = issue.init_journal(user, issue)
journal.notes = 'This update has a note'
issue.init_journal(user, 'This update has a note')
assert journal.save
assert issue.save
assert_equal 0, ActionMailer::Base.deliveries.size
end
@ -74,7 +72,7 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = ['issue_status_updated']
issue = Issue.find(:first)
user = User.find(:first)
issue.init_journal(user, issue)
issue.init_journal(user)
issue.status = IssueStatus.last
assert issue.save
@ -85,7 +83,7 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = []
issue = Issue.find(:first)
user = User.find(:first)
issue.init_journal(user, issue)
issue.init_journal(user)
issue.status = IssueStatus.last
assert issue.save
@ -97,7 +95,7 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = ['issue_priority_updated']
issue = Issue.find(:first)
user = User.find(:first)
issue.init_journal(user, issue)
issue.init_journal(user)
issue.priority = IssuePriority.last
assert issue.save
@ -108,7 +106,7 @@ class JournalObserverTest < ActiveSupport::TestCase
Setting.notified_events = []
issue = Issue.find(:first)
user = User.find(:first)
issue.init_journal(user, issue)
issue.init_journal(user)
issue.priority = IssuePriority.last
assert issue.save