mirror of
https://github.com/redmine/redmine.git
synced 2025-11-13 08:46:01 +01:00
Set notified events as expected.
git-svn-id: http://svn.redmine.org/redmine/trunk@13683 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -2036,6 +2036,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
with_settings :notified_events => %w(issue_added) do
|
||||
assert_difference 'Watcher.count', 2 do
|
||||
post :create, :project_id => 1,
|
||||
:issue => {:tracker_id => 1,
|
||||
@@ -2044,6 +2045,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
:priority_id => 5,
|
||||
:watcher_user_ids => ['2', '3']}
|
||||
end
|
||||
end
|
||||
issue = Issue.find_by_subject('This is a new issue with watchers')
|
||||
assert_not_nil issue
|
||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
|
||||
@@ -2148,6 +2150,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
def test_post_create_should_send_a_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@request.session[:user_id] = 2
|
||||
with_settings :notified_events => %w(issue_added) do
|
||||
assert_difference 'Issue.count' do
|
||||
post :create, :project_id => 1,
|
||||
:issue => {:tracker_id => 3,
|
||||
@@ -2161,6 +2164,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_create_should_preserve_fields_values_on_validation_failure
|
||||
@request.session[:user_id] = 2
|
||||
@@ -2237,7 +2241,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
with_settings :host_name => 'mydomain.foo', :protocol => 'http' do
|
||||
with_settings :host_name => 'mydomain.foo', :protocol => 'http', :notified_events => %w(issue_added) do
|
||||
assert_difference 'Issue.count' do
|
||||
post :create, :project_id => 1,
|
||||
:issue => { :tracker_id => '1', :subject => 'With attachment' },
|
||||
@@ -2841,37 +2845,27 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
def test_put_update_without_custom_fields_param
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
issue = Issue.find(1)
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
old_subject = issue.subject
|
||||
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
||||
|
||||
assert_difference('Journal.count') do
|
||||
assert_difference('JournalDetail.count', 2) do
|
||||
put :update, :id => 1, :issue => {:subject => new_subject,
|
||||
:priority_id => '6',
|
||||
:category_id => '1' # no change
|
||||
}
|
||||
assert_difference('JournalDetail.count') do
|
||||
put :update, :id => 1, :issue => {:subject => 'New subject'}
|
||||
end
|
||||
end
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
issue.reload
|
||||
assert_equal new_subject, issue.subject
|
||||
assert_equal 'New subject', issue.subject
|
||||
# Make sure custom fields were not cleared
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_not_nil mail
|
||||
assert mail.subject.starts_with?("[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]")
|
||||
assert_mail_body_match "Subject changed from #{old_subject} to #{new_subject}", mail
|
||||
end
|
||||
|
||||
def test_put_update_with_project_change
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
assert_difference('Journal.count') do
|
||||
assert_difference('JournalDetail.count', 3) do
|
||||
put :update, :id => 1, :issue => {:project_id => '2',
|
||||
@@ -2881,6 +2875,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
issue = Issue.find(1)
|
||||
assert_equal 2, issue.project_id
|
||||
@@ -2898,6 +2893,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
assert_difference('Journal.count') do
|
||||
assert_difference('JournalDetail.count', 2) do
|
||||
put :update, :id => 1, :issue => {:project_id => '1',
|
||||
@@ -2906,6 +2902,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
issue = Issue.find(1)
|
||||
assert_equal 1, issue.project_id
|
||||
@@ -2924,6 +2921,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
issue = Issue.find(1)
|
||||
assert_equal '125', issue.custom_value_for(2).value
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
assert_difference('Journal.count') do
|
||||
assert_difference('JournalDetail.count', 3) do
|
||||
put :update, :id => 1, :issue => {:subject => 'Custom field change',
|
||||
@@ -2933,6 +2931,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
issue.reload
|
||||
assert_equal 'New custom value', issue.custom_value_for(2).value
|
||||
@@ -2967,12 +2966,15 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
issue = Issue.find(1)
|
||||
assert_equal 1, issue.status_id
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
assert_difference('TimeEntry.count', 0) do
|
||||
put :update,
|
||||
:id => 1,
|
||||
:issue => { :status_id => 2, :assigned_to_id => 3, :notes => 'Assigned to dlopper' },
|
||||
:time_entry => { :hours => '', :comments => '', :activity_id => TimeEntryActivity.first }
|
||||
end
|
||||
end
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
issue.reload
|
||||
assert_equal 2, issue.status_id
|
||||
@@ -2988,10 +2990,13 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
|
||||
def test_put_update_with_note_only
|
||||
notes = 'Note added by IssuesControllerTest#test_update_with_note_only'
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
# anonymous user
|
||||
put :update,
|
||||
:id => 1,
|
||||
:issue => { :notes => notes }
|
||||
end
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
j = Journal.order('id DESC').first
|
||||
assert_equal notes, j.notes
|
||||
@@ -3080,12 +3085,14 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
# journal to get fetched in the next find.
|
||||
Journal.delete_all
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
# anonymous user
|
||||
assert_difference 'Attachment.count' do
|
||||
put :update, :id => 1,
|
||||
:issue => {:notes => ''},
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
|
||||
end
|
||||
end
|
||||
|
||||
assert_redirected_to :action => 'show', :id => '1'
|
||||
j = Issue.find(1).journals.reorder('id DESC').first
|
||||
@@ -3211,12 +3218,14 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
old_subject = issue.subject
|
||||
new_subject = 'Subject modified by IssuesControllerTest#test_post_edit'
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
put :update, :id => 1, :issue => {:subject => new_subject,
|
||||
:priority_id => '6',
|
||||
:category_id => '1' # no change
|
||||
}
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
end
|
||||
|
||||
def test_put_update_with_invalid_spent_time_hours_only
|
||||
@request.session[:user_id] = 2
|
||||
@@ -3521,6 +3530,7 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
def test_bullk_update_should_send_a_notification
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
post(:bulk_update,
|
||||
{
|
||||
:ids => [1, 2],
|
||||
@@ -3531,10 +3541,10 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
:custom_field_values => {'2' => ''}
|
||||
}
|
||||
})
|
||||
|
||||
assert_response 302
|
||||
assert_equal 2, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
end
|
||||
|
||||
def test_bulk_update_project
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
@@ -1825,12 +1825,14 @@ class IssueTest < ActiveSupport::TestCase
|
||||
user.members.update_all ["mail_notification = ?", false]
|
||||
user.update_attribute :mail_notification, 'only_assigned'
|
||||
|
||||
with_settings :notified_events => %w(issue_updated) do
|
||||
issue = Issue.find(2)
|
||||
issue.init_journal User.find(1)
|
||||
issue.assigned_to = nil
|
||||
issue.save!
|
||||
assert_include user.mail, ActionMailer::Base.deliveries.last.bcc
|
||||
end
|
||||
end
|
||||
|
||||
def test_stale_issue_should_not_send_email_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
Reference in New Issue
Block a user