test/acceptance/build_notifications_test.rb in integrity-0.1.9.3 vs test/acceptance/build_notifications_test.rb in integrity-0.1.10

- old
+ new

@@ -1,7 +1,8 @@ require File.dirname(__FILE__) + "/../helpers/acceptance" require "helpers/acceptance/notifier_helper" +require "helpers/acceptance/email_notifier" class BuildNotificationsTest < Test::Unit::AcceptanceTestCase include NotifierHelper story <<-EOS @@ -10,13 +11,15 @@ So that I get alerts with every build EOS before(:each) do # This is needed before any available notifier is unset - # in the global #before + # in the global #before. + # But, we need the reload this one because we remove_const + # it in a test case. Sigh. load "helpers/acceptance/textfile_notifier.rb" - load "helpers/acceptance/email_notifier.rb" + Notifier.register(Integrity::Notifier::Textfile) Notifier.register(Integrity::Notifier::Email) end scenario "an admin sets up a notifier and issue a manual build" do @@ -44,10 +47,29 @@ notification.should =~ /Commit Date: (.+)/ notification.should =~ /Commit Message: This commit will work/ notification.should =~ /Build Output:\n\nRunning tests...\n/ end + scenario "an admin sets up the Textfile notifier but do not enable it" do + git_repo(:my_test_project).add_successful_commit + Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path) + rm_f "/tmp/textfile_notifications.txt" + + login_as "admin", "test" + + visit "/my-test-project" + + click_link "Edit Project" + uncheck "enabled_notifiers_textfile" + fill_in "File", :with => "/tmp/textfile_notifications.txt" + click_button "Update Project" + + click_button "manual build" + + assert ! File.file?("/tmp/textfile_notifications.txt") + end + scenario "an admin can setup a notifier without enabling it" do Project.gen(:integrity) login_as "admin", "test" @@ -56,9 +78,30 @@ fill_in_email_notifier click_button "Update Project" visit "/integrity/edit" assert_have_email_notifier + end + + scenario "an admin enables the Textfile notifier and get rid of it later" do + git_repo(:my_test_project).add_successful_commit + Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path) + + login_as "admin", "test" + visit "/my-test-project" + + click_link "Edit Project" + check "enabled_notifiers_textfile" + fill_in "File", :with => "/tmp/textfile_notifications.txt" + click_button "Update Project" + + Notifier.send(:remove_const, :Textfile) + Notifier.available.clear + rm_f "/tmp/textfile_notifications.txt" + + click_button "manual build" + + assert ! File.file?("/tmp/textfile_notifications.txt") end scenario "an admin configures various notifiers accros multiple projects" do Project.first(:permalink => "integrity").should be_nil