diff options
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/changeset_test.rb | 2 | ||||
-rw-r--r-- | test/unit/document_test.rb | 9 | ||||
-rw-r--r-- | test/unit/issue_test.rb | 8 | ||||
-rw-r--r-- | test/unit/journal_test.rb | 11 | ||||
-rw-r--r-- | test/unit/mail_handler_test.rb | 15 | ||||
-rw-r--r-- | test/unit/news_test.rb | 20 |
6 files changed, 62 insertions, 3 deletions
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index 6cc53d852..6a0df2c5d 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -24,6 +24,7 @@ class ChangesetTest < Test::Unit::TestCase end def test_ref_keywords_any + ActionMailer::Base.deliveries.clear Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id Setting.commit_fix_done_ratio = '90' Setting.commit_ref_keywords = '*' @@ -38,6 +39,7 @@ class ChangesetTest < Test::Unit::TestCase fixed = Issue.find(1) assert fixed.closed? assert_equal 90, fixed.done_ratio + assert_equal 1, ActionMailer::Base.deliveries.size end def test_ref_keywords_any_line_start diff --git a/test/unit/document_test.rb b/test/unit/document_test.rb index 17a0ad6ea..1950f8558 100644 --- a/test/unit/document_test.rb +++ b/test/unit/document_test.rb @@ -25,6 +25,15 @@ class DocumentTest < Test::Unit::TestCase assert doc.save end + def test_create_should_send_email_notification + ActionMailer::Base.deliveries.clear + Setting.notified_events << 'document_added' + doc = Document.new(:project => Project.find(1), :title => 'New document', :category => Enumeration.find_by_name('User documentation')) + + assert doc.save + assert_equal 1, ActionMailer::Base.deliveries.size + end + def test_create_with_default_category # Sets a default category e = Enumeration.find_by_name('Technical documentation') diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index 365316034..ae3fa5bda 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -241,4 +241,12 @@ class IssueTest < Test::Unit::TestCase assert !Issue.new(:due_date => nil).overdue? assert !Issue.new(:due_date => 1.day.ago.to_date, :status => IssueStatus.find(:first, :conditions => {:is_closed => true})).overdue? end + + def test_create_should_send_email_notification + ActionMailer::Base.deliveries.clear + issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.priorities.first, :subject => 'test_create', :estimated_hours => '1:30') + + assert issue.save + assert_equal 1, ActionMailer::Base.deliveries.size + end end diff --git a/test/unit/journal_test.rb b/test/unit/journal_test.rb index b177f3198..147af4aae 100644 --- a/test/unit/journal_test.rb +++ b/test/unit/journal_test.rb @@ -36,4 +36,15 @@ class JournalTest < Test::Unit::TestCase assert_kind_of IssueStatus, status assert_equal 2, status.id end + + def test_create_should_send_email_notification + ActionMailer::Base.deliveries.clear + issue = Issue.find(:first) + user = User.find(:first) + journal = issue.init_journal(user, issue) + + assert journal.save + assert_equal 1, ActionMailer::Base.deliveries.size + end + end diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 1e9e7f19e..704e12c7f 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -133,6 +133,14 @@ class MailHandlerTest < Test::Unit::TestCase Role.anonymous.add_permission!(:add_issues) assert_equal false, submit_email('ticket_without_from_header.eml') end + + def test_add_issue_should_send_email_notification + ActionMailer::Base.deliveries.clear + # This email contains: 'Project: onlinestore' + issue = submit_email('ticket_on_given_project.eml') + assert issue.is_a?(Issue) + assert_equal 1, ActionMailer::Base.deliveries.size + end def test_add_issue_note journal = submit_email('ticket_reply.eml') @@ -152,6 +160,13 @@ class MailHandlerTest < Test::Unit::TestCase assert_match /This is reply/, journal.notes assert_equal IssueStatus.find_by_name("Resolved"), issue.status end + + def test_add_issue_note_should_send_email_notification + ActionMailer::Base.deliveries.clear + journal = submit_email('ticket_reply.eml') + assert journal.is_a?(Journal) + assert_equal 1, ActionMailer::Base.deliveries.size + end def test_reply_to_a_message m = submit_email('message_reply.eml') diff --git a/test/unit/news_test.rb b/test/unit/news_test.rb index 527715b00..3a908dcc8 100644 --- a/test/unit/news_test.rb +++ b/test/unit/news_test.rb @@ -20,9 +20,23 @@ require File.dirname(__FILE__) + '/../test_helper' class NewsTest < Test::Unit::TestCase fixtures :projects, :users, :roles, :members, :enabled_modules, :news + def valid_news + { :title => 'Test news', :description => 'Lorem ipsum etc', :author => User.find(:first) } + end + + def setup end + def test_create_should_send_email_notification + ActionMailer::Base.deliveries.clear + Setting.notified_events << 'news_added' + news = Project.find(:first).news.new(valid_news) + + assert news.save + assert_equal 1, ActionMailer::Base.deliveries.size + end + def test_should_include_news_for_projects_with_news_enabled project = projects(:projects_001) assert project.enabled_modules.any?{ |em| em.name == 'news' } @@ -37,7 +51,7 @@ class NewsTest < Test::Unit::TestCase assert ! project.enabled_modules.any?{ |em| em.name == 'news' } # Add a piece of news to the project - news = project.news.create(:title => 'Test news', :description => 'This should not be returned by News.latest') + news = project.news.create(valid_news) # News.latest should not return that new piece of news assert News.latest.include?(news) == false @@ -50,14 +64,14 @@ class NewsTest < Test::Unit::TestCase def test_should_limit_the_amount_of_returned_news # Make sure we have a bunch of news stories - 10.times { projects(:projects_001).news.create(:title => 'Test news', :description => 'Lorem ipsum etc') } + 10.times { projects(:projects_001).news.create(valid_news) } assert_equal 2, News.latest(users(:users_002), 2).size assert_equal 6, News.latest(users(:users_002), 6).size end def test_should_return_5_news_stories_by_default # Make sure we have a bunch of news stories - 10.times { projects(:projects_001).news.create(:title => 'Test news', :description => 'Lorem ipsum etc') } + 10.times { projects(:projects_001).news.create(valid_news) } assert_equal 5, News.latest(users(:users_004)).size end end |