Tests should not change settings.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9949 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -95,16 +95,16 @@ LOREM
|
||||
|
||||
def test_create_with_one_attachment
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.notified_events << 'document_added'
|
||||
@request.session[:user_id] = 2
|
||||
set_tmp_attachments_directory
|
||||
|
||||
post :create, :project_id => 'ecookbook',
|
||||
with_settings :notified_events => %w(document_added) do
|
||||
post :create, :project_id => 'ecookbook',
|
||||
:document => { :title => 'DocumentsControllerTest#test_post_new',
|
||||
:description => 'This is a new document',
|
||||
:category_id => 2},
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/documents'
|
||||
|
||||
document = Document.find_by_title('DocumentsControllerTest#test_post_new')
|
||||
|
||||
@@ -58,13 +58,14 @@ class FilesControllerTest < ActionController::TestCase
|
||||
def test_create_file
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
Setting.notified_events = ['file_added']
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
assert_difference 'Attachment.count' do
|
||||
post :create, :project_id => 1, :version_id => '',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
assert_response :redirect
|
||||
with_settings :notified_events => %w(file_added) do
|
||||
assert_difference 'Attachment.count' do
|
||||
post :create, :project_id => 1, :version_id => '',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
||||
assert_response :redirect
|
||||
end
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/files'
|
||||
a = Attachment.find(:first, :order => 'created_on DESC')
|
||||
@@ -80,7 +81,6 @@ class FilesControllerTest < ActionController::TestCase
|
||||
def test_create_version_file
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
Setting.notified_events = ['file_added']
|
||||
|
||||
assert_difference 'Attachment.count' do
|
||||
post :create, :project_id => 1, :version_id => '2',
|
||||
|
||||
@@ -91,11 +91,12 @@ class MessagesControllerTest < ActionController::TestCase
|
||||
def test_post_new
|
||||
@request.session[:user_id] = 2
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.notified_events = ['message_posted']
|
||||
|
||||
post :new, :board_id => 1,
|
||||
with_settings :notified_events => %w(message_posted) do
|
||||
post :new, :board_id => 1,
|
||||
:message => { :subject => 'Test created message',
|
||||
:content => 'Message body'}
|
||||
end
|
||||
message = Message.find_by_subject('Test created message')
|
||||
assert_not_nil message
|
||||
assert_redirected_to "/boards/1/topics/#{message.to_param}"
|
||||
|
||||
@@ -82,12 +82,13 @@ class NewsControllerTest < ActionController::TestCase
|
||||
|
||||
def test_post_create
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.notified_events << 'news_added'
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
post :create, :project_id => 1, :news => { :title => 'NewsControllerTest',
|
||||
|
||||
with_settings :notified_events => %w(news_added) do
|
||||
post :create, :project_id => 1, :news => { :title => 'NewsControllerTest',
|
||||
:description => 'This is the description',
|
||||
:summary => '' }
|
||||
end
|
||||
assert_redirected_to '/projects/ecookbook/news'
|
||||
|
||||
news = News.find_by_title('NewsControllerTest')
|
||||
|
||||
@@ -292,21 +292,22 @@ class RepositoriesGitControllerTest < ActionController::TestCase
|
||||
@repository.fetch_changesets
|
||||
@project.reload
|
||||
assert_equal NUM_REV, @repository.changesets.count
|
||||
Setting.diff_max_lines_displayed = 5
|
||||
|
||||
# Truncated diff of changeset 2f9c0091
|
||||
with_cache do
|
||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
assert_response :success
|
||||
assert @response.body.include?("... This diff was truncated")
|
||||
|
||||
Setting.default_language = 'fr'
|
||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
assert_response :success
|
||||
assert ! @response.body.include?("... This diff was truncated")
|
||||
assert @response.body.include?("... Ce diff")
|
||||
with_settings :diff_max_lines_displayed => 5 do
|
||||
# Truncated diff of changeset 2f9c0091
|
||||
with_cache do
|
||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
assert_response :success
|
||||
assert @response.body.include?("... This diff was truncated")
|
||||
|
||||
Setting.default_language = 'fr'
|
||||
get :diff, :id => PRJ_ID, :type => 'inline',
|
||||
:rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
|
||||
assert_response :success
|
||||
assert ! @response.body.include?("... This diff was truncated")
|
||||
assert @response.body.include?("... Ce diff")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ class SettingsControllerTest < ActionController::TestCase
|
||||
assert !Setting.bcc_recipients?
|
||||
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
|
||||
assert_equal 'Test footer', Setting.emails_footer
|
||||
Setting.clear_cache
|
||||
end
|
||||
|
||||
def test_get_plugin_settings
|
||||
|
||||
@@ -33,6 +33,10 @@ class SysControllerTest < ActionController::TestCase
|
||||
Setting.enabled_scm = %w(Subversion Git)
|
||||
end
|
||||
|
||||
def teardown
|
||||
Setting.clear_cache
|
||||
end
|
||||
|
||||
def test_projects_with_repository_enabled
|
||||
get :projects
|
||||
assert_response :success
|
||||
|
||||
Reference in New Issue
Block a user