<commit_before>require File.dirname(__FILE__) + "/../helpers"
require File.dirname(__FILE__) + "/../helpers/acceptance/textfile_notifier"

class BuildNotificationsTest < Test::Unit::AcceptanceTestCase
  story <<-EOS
    As an administrator,
    I want to setup notifiers on my projects
    So that I get alerts with every build
  EOS

  scenario "an admin sets up a notifier for a project that didn't have any" do
    git_repo(:my_test_project).add_successful_commit
    Project.gen(:my_test_project, :notifiers => [], :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"
    check "enabled_notifiers_textfile"
    fill_in "File", :with => "/tmp/textfile_notifications.txt"
    click_button "Update Project"
    
    click_button "manual build"
    
    notification = File.read("/tmp/textfile_notifications.txt")
    notification.should =~ /=== Build #{git_repo(:my_test_project).short_head} was successful ===/
    notification.should =~ /Build #{git_repo(:my_test_project).head} was successful/
    notification.should =~ /Commit Author: <NAME>/
    notification.should =~ /Commit Date: (.+)/
    notification.should =~ /Commit Message: This commit will work/
    notification.should =~ /Build Output:\n\nRunning tests...\n/
  end
end<commit_msg>Also check that notification messages include the full url to the build<commit_after>require File.dirname(__FILE__) + "/../helpers"
require File.dirname(__FILE__) + "/../helpers/acceptance/textfile_notifier"

class BuildNotificationsTest < Test::Unit::AcceptanceTestCase
  story <<-EOS
    As an administrator,
    I want to setup notifiers on my projects
    So that I get alerts with every build
  EOS
  
  before(:each) do
    Integrity.config[:base_uri] = "http://integrity.example.org"
  end

  scenario "an admin sets up a notifier for a project that didn't have any" do
    git_repo(:my_test_project).add_successful_commit
    Project.gen(:my_test_project, :notifiers => [], :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"
    check "enabled_notifiers_textfile"
    fill_in "File", :with => "/tmp/textfile_notifications.txt"
    click_button "Update Project"
    
    click_button "manual build"
    
    notification = File.read("/tmp/textfile_notifications.txt")
    notification.should =~ /=== Build #{git_repo(:my_test_project).short_head} was successful ===/
    notification.should =~ /Build #{git_repo(:my_test_project).head} was successful/
    notification.should =~ %r(http://integrity.example.org/my-test-project/builds/#{git_repo(:my_test_project).head})
    notification.should =~ /Commit Author: <NAME>/
    notification.should =~ /Commit Date: (.+)/
    notification.should =~ /Commit Message: This commit will work/
    notification.should =~ /Build Output:\n\nRunning tests...\n/
  end
end
{'fraction_non_alphanumeric': 0.12355467459530889, 'fraction_numerical': 0.0, 'mean_word_length': 3.821656050955414, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4142524', 'n_tokens_mistral': 926, 'n_tokens_neox': 922, 'n_words': 227}