git-svn-id: http://svn.redmine.org/redmine/trunk@15666 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/3.4.0
@@ -45,7 +45,7 @@ class RolesControllerTest < Redmine::ControllerTest | |||
def test_new_with_copy | |||
copy_from = Role.find(2) | |||
get :new, :copy => copy_from.id.to_s | |||
get :new, :params => {:copy => copy_from.id.to_s} | |||
assert_response :success | |||
assert_template 'new' | |||
@@ -68,20 +68,26 @@ class RolesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_create_with_validaton_failure | |||
post :create, :role => {:name => '', | |||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |||
:assignable => '0'} | |||
post :create, :params => { | |||
:role => { | |||
:name => '', | |||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |||
:assignable => '0' | |||
} | |||
} | |||
assert_response :success | |||
assert_template 'new' | |||
assert_select 'div#errorExplanation' | |||
end | |||
def test_create_without_workflow_copy | |||
post :create, :role => {:name => 'RoleWithoutWorkflowCopy', | |||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |||
:assignable => '0'} | |||
post :create, :params => { | |||
:role => { | |||
:name => 'RoleWithoutWorkflowCopy', | |||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |||
:assignable => '0' | |||
} | |||
} | |||
assert_redirected_to '/roles' | |||
role = Role.find_by_name('RoleWithoutWorkflowCopy') | |||
assert_not_nil role | |||
@@ -90,11 +96,14 @@ class RolesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_create_with_workflow_copy | |||
post :create, :role => {:name => 'RoleWithWorkflowCopy', | |||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |||
:assignable => '0'}, | |||
:copy_workflow_from => '1' | |||
post :create, :params => { | |||
:role => { | |||
:name => 'RoleWithWorkflowCopy', | |||
:permissions => ['add_issues', 'edit_issues', 'log_time', ''], | |||
:assignable => '0' | |||
}, | |||
:copy_workflow_from => '1' | |||
} | |||
assert_redirected_to '/roles' | |||
role = Role.find_by_name('RoleWithWorkflowCopy') | |||
assert_not_nil role | |||
@@ -102,7 +111,7 @@ class RolesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_edit | |||
get :edit, :id => 1 | |||
get :edit, :params => {:id => 1} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_equal Role.find(1), assigns(:role) | |||
@@ -110,34 +119,39 @@ class RolesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_edit_anonymous | |||
get :edit, :id => Role.anonymous.id | |||
get :edit, :params => {:id => Role.anonymous.id} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_select 'select[name=?]', 'role[issues_visibility]', 0 | |||
end | |||
def test_edit_invalid_should_respond_with_404 | |||
get :edit, :id => 999 | |||
get :edit, :params => {:id => 999} | |||
assert_response 404 | |||
end | |||
def test_update | |||
put :update, :id => 1, | |||
:role => {:name => 'Manager', | |||
:permissions => ['edit_project', ''], | |||
:assignable => '0'} | |||
put :update, :params => { | |||
:id => 1, | |||
:role => { | |||
:name => 'Manager', | |||
:permissions => ['edit_project', ''], | |||
:assignable => '0' | |||
} | |||
} | |||
assert_redirected_to '/roles' | |||
role = Role.find(1) | |||
assert_equal [:edit_project], role.permissions | |||
end | |||
def test_update_trackers_permissions | |||
put :update, :id => 1, :role => { | |||
:permissions_all_trackers => {'add_issues' => '0'}, | |||
:permissions_tracker_ids => {'add_issues' => ['1', '3', '']} | |||
put :update, :params => { | |||
:id => 1, | |||
:role => { | |||
:permissions_all_trackers => {'add_issues' => '0'}, | |||
:permissions_tracker_ids => {'add_issues' => ['1', '3', '']} | |||
} | |||
} | |||
assert_redirected_to '/roles' | |||
role = Role.find(1) | |||
@@ -149,7 +163,7 @@ class RolesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_update_with_failure | |||
put :update, :id => 1, :role => {:name => ''} | |||
put :update, :params => {:id => 1, :role => {:name => ''}} | |||
assert_response :success | |||
assert_template 'edit' | |||
end | |||
@@ -157,13 +171,13 @@ class RolesControllerTest < Redmine::ControllerTest | |||
def test_destroy | |||
r = Role.create!(:name => 'ToBeDestroyed', :permissions => [:view_wiki_pages]) | |||
delete :destroy, :id => r | |||
delete :destroy, :params => {:id => r} | |||
assert_redirected_to '/roles' | |||
assert_nil Role.find_by_id(r.id) | |||
end | |||
def test_destroy_role_in_use | |||
delete :destroy, :id => 1 | |||
delete :destroy, :params => {:id => 1} | |||
assert_redirected_to '/roles' | |||
assert_equal 'This role is in use and cannot be deleted.', flash[:error] | |||
assert_not_nil Role.find_by_id(1) | |||
@@ -182,7 +196,13 @@ class RolesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_post_permissions | |||
post :permissions, :permissions => { '0' => '', '1' => ['edit_issues'], '3' => ['add_issues', 'delete_issues']} | |||
post :permissions, :params => { | |||
:permissions => { | |||
'0' => '', | |||
'1' => ['edit_issues'], | |||
'3' => ['add_issues', 'delete_issues'] | |||
} | |||
} | |||
assert_redirected_to '/roles' | |||
assert_equal [:edit_issues], Role.find(1).permissions | |||
@@ -191,33 +211,33 @@ class RolesControllerTest < Redmine::ControllerTest | |||
end | |||
def test_clear_all_permissions | |||
post :permissions, :permissions => { '0' => '' } | |||
post :permissions, :params => {:permissions => { '0' => '' }} | |||
assert_redirected_to '/roles' | |||
assert Role.find(1).permissions.empty? | |||
end | |||
def test_move_highest | |||
put :update, :id => 3, :role => {:position => 1} | |||
put :update, :params => {:id => 3, :role => {:position => 1}} | |||
assert_redirected_to '/roles' | |||
assert_equal 1, Role.find(3).position | |||
end | |||
def test_move_higher | |||
position = Role.find(3).position | |||
put :update, :id => 3, :role => {:position => position - 1} | |||
put :update, :params => {:id => 3, :role => {:position => position - 1}} | |||
assert_redirected_to '/roles' | |||
assert_equal position - 1, Role.find(3).position | |||
end | |||
def test_move_lower | |||
position = Role.find(2).position | |||
put :update, :id => 2, :role => {:position => position + 1} | |||
put :update, :params => {:id => 2, :role => {:position => position + 1}} | |||
assert_redirected_to '/roles' | |||
assert_equal position + 1, Role.find(2).position | |||
end | |||
def test_move_lowest | |||
put :update, :id => 2, :role => {:position => Role.givable.count} | |||
put :update, :params => {:id => 2, :role => {:position => Role.givable.count}} | |||
assert_redirected_to '/roles' | |||
assert_equal Role.givable.count, Role.find(2).position | |||
end |
@@ -35,7 +35,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
assert_response :success | |||
assert_template 'index' | |||
get :index, :q => "cook" | |||
get :index, :params => {:q => "cook"} | |||
assert_response :success | |||
assert_template 'index' | |||
assert assigns(:results).include?(Project.find(1)) | |||
@@ -43,30 +43,30 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_on_archived_project_should_return_404 | |||
Project.find(3).archive | |||
get :index, :id => 3 | |||
get :index, :params => {:id => 3} | |||
assert_response 404 | |||
end | |||
def test_search_on_invisible_project_by_user_should_be_denied | |||
@request.session[:user_id] = 7 | |||
get :index, :id => 2 | |||
get :index, :params => {:id => 2} | |||
assert_response 403 | |||
end | |||
def test_search_on_invisible_project_by_anonymous_user_should_redirect | |||
get :index, :id => 2 | |||
get :index, :params => {:id => 2} | |||
assert_response 302 | |||
end | |||
def test_search_on_private_project_by_member_should_succeed | |||
@request.session[:user_id] = 2 | |||
get :index, :id => 2 | |||
get :index, :params => {:id => 2} | |||
assert_response :success | |||
end | |||
def test_search_all_projects | |||
with_settings :default_language => 'en' do | |||
get :index, :q => 'recipe subproject commit', :all_words => '' | |||
get :index, :params => {:q => 'recipe subproject commit', :all_words => ''} | |||
end | |||
assert_response :success | |||
assert_template 'index' | |||
@@ -83,7 +83,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
end | |||
def test_search_issues | |||
get :index, :q => 'issue', :issues => 1 | |||
get :index, :params => {:q => 'issue', :issues => 1} | |||
assert_response :success | |||
assert_template 'index' | |||
@@ -97,7 +97,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_issues_should_search_notes | |||
Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword') | |||
get :index, :q => 'searchkeyword', :issues => 1 | |||
get :index, :params => {:q => 'searchkeyword', :issues => 1} | |||
assert_response :success | |||
assert_include Issue.find(2), assigns(:results) | |||
end | |||
@@ -106,7 +106,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword') | |||
Journal.create!(:journalized => Issue.find(2), :notes => 'Issue notes with searchkeyword') | |||
get :index, :q => 'searchkeyword', :issues => 1 | |||
get :index, :params => {:q => 'searchkeyword', :issues => 1} | |||
assert_response :success | |||
assert_include Issue.find(2), assigns(:results) | |||
assert_equal 1, assigns(:results).size | |||
@@ -117,18 +117,18 @@ class SearchControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
Role.find(1).add_permission! :view_private_notes | |||
get :index, :q => 'searchkeyword', :issues => 1 | |||
get :index, :params => {:q => 'searchkeyword', :issues => 1} | |||
assert_response :success | |||
assert_include Issue.find(2), assigns(:results) | |||
Role.find(1).remove_permission! :view_private_notes | |||
get :index, :q => 'searchkeyword', :issues => 1 | |||
get :index, :params => {:q => 'searchkeyword', :issues => 1} | |||
assert_response :success | |||
assert_not_include Issue.find(2), assigns(:results) | |||
end | |||
def test_search_all_projects_with_scope_param | |||
get :index, :q => 'issue', :scope => 'all' | |||
get :index, :params => {:q => 'issue', :scope => 'all'} | |||
assert_response :success | |||
assert_template 'index' | |||
assert assigns(:results).present? | |||
@@ -136,7 +136,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_my_projects | |||
@request.session[:user_id] = 2 | |||
get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => '' | |||
get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''} | |||
assert_response :success | |||
assert_template 'index' | |||
assert assigns(:results).include?(Issue.find(1)) | |||
@@ -145,14 +145,14 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_my_projects_without_memberships | |||
# anonymous user has no memberships | |||
get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => '' | |||
get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => ''} | |||
assert_response :success | |||
assert_template 'index' | |||
assert assigns(:results).empty? | |||
end | |||
def test_search_project_and_subprojects | |||
get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => '' | |||
get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''} | |||
assert_response :success | |||
assert_template 'index' | |||
assert assigns(:results).include?(Issue.find(1)) | |||
@@ -162,18 +162,18 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_without_searchable_custom_fields | |||
CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}" | |||
get :index, :id => 1 | |||
get :index, :params => {:id => 1} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:project) | |||
get :index, :id => 1, :q => "can" | |||
get :index, :params => {:id => 1, :q => "can"} | |||
assert_response :success | |||
assert_template 'index' | |||
end | |||
def test_search_with_searchable_custom_fields | |||
get :index, :id => 1, :q => "stringforcustomfield" | |||
get :index, :params => {:id => 1, :q => "stringforcustomfield"} | |||
assert_response :success | |||
results = assigns(:results) | |||
assert_not_nil results | |||
@@ -185,7 +185,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
issue = Issue.generate! :subject => 'search_attachments' | |||
attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' | |||
get :index, :id => 1, :q => 'search_attachments', :attachments => '0' | |||
get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '0'} | |||
results = assigns(:results) | |||
assert_equal 1, results.size | |||
assert_equal issue, results.first | |||
@@ -195,7 +195,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
issue = Issue.generate! :subject => 'search_attachments' | |||
attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' | |||
get :index, :id => 1, :q => 'search_attachments', :attachments => 'only' | |||
get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => 'only'} | |||
results = assigns(:results) | |||
assert_equal 1, results.size | |||
assert_equal attachment.container, results.first | |||
@@ -205,7 +205,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
Issue.generate! :subject => 'search_attachments' | |||
Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' | |||
get :index, :id => 1, :q => 'search_attachments', :attachments => '1' | |||
get :index, :params => {:id => 1, :q => 'search_attachments', :attachments => '1'} | |||
results = assigns(:results) | |||
assert_equal 2, results.size | |||
end | |||
@@ -214,14 +214,14 @@ class SearchControllerTest < Redmine::ControllerTest | |||
Issue.generate! :subject => 'search_open' | |||
Issue.generate! :subject => 'search_open', :status_id => 5 | |||
get :index, :id => 1, :q => 'search_open', :open_issues => '1' | |||
get :index, :params => {:id => 1, :q => 'search_open', :open_issues => '1'} | |||
results = assigns(:results) | |||
assert_equal 1, results.size | |||
end | |||
def test_search_all_words | |||
# 'all words' is on by default | |||
get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1' | |||
get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => '1'} | |||
assert_equal true, assigns(:all_words) | |||
results = assigns(:results) | |||
assert_not_nil results | |||
@@ -230,7 +230,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
end | |||
def test_search_one_of_the_words | |||
get :index, :id => 1, :q => 'recipe updating saving', :all_words => '' | |||
get :index, :params => {:id => 1, :q => 'recipe updating saving', :all_words => ''} | |||
assert_equal false, assigns(:all_words) | |||
results = assigns(:results) | |||
assert_not_nil results | |||
@@ -239,14 +239,14 @@ class SearchControllerTest < Redmine::ControllerTest | |||
end | |||
def test_search_titles_only_without_result | |||
get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1' | |||
get :index, :params => {:id => 1, :q => 'recipe updating saving', :titles_only => '1'} | |||
results = assigns(:results) | |||
assert_not_nil results | |||
assert_equal 0, results.size | |||
end | |||
def test_search_titles_only | |||
get :index, :id => 1, :q => 'recipe', :titles_only => '1' | |||
get :index, :params => {:id => 1, :q => 'recipe', :titles_only => '1'} | |||
assert_equal true, assigns(:titles_only) | |||
results = assigns(:results) | |||
assert_not_nil results | |||
@@ -255,7 +255,8 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_content | |||
Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'") | |||
get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => '' | |||
get :index, :params => {:id => 1, :q => 'searchkeywordinthecontent', :titles_only => ''} | |||
assert_equal false, assigns(:titles_only) | |||
results = assigns(:results) | |||
assert_not_nil results | |||
@@ -265,54 +266,54 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_search_with_pagination | |||
issue = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse | |||
get :index, :q => 'search_with_limited_results' | |||
get :index, :params => {:q => 'search_with_limited_results'} | |||
assert_response :success | |||
assert_equal issue[0..9], assigns(:results) | |||
get :index, :q => 'search_with_limited_results', :page => 2 | |||
get :index, :params => {:q => 'search_with_limited_results', :page => 2} | |||
assert_response :success | |||
assert_equal issue[10..19], assigns(:results) | |||
get :index, :q => 'search_with_limited_results', :page => 3 | |||
get :index, :params => {:q => 'search_with_limited_results', :page => 3} | |||
assert_response :success | |||
assert_equal issue[20..24], assigns(:results) | |||
get :index, :q => 'search_with_limited_results', :page => 4 | |||
get :index, :params => {:q => 'search_with_limited_results', :page => 4} | |||
assert_response :success | |||
assert_equal [], assigns(:results) | |||
end | |||
def test_search_with_invalid_project_id | |||
get :index, :id => 195, :q => 'recipe' | |||
get :index, :params => {:id => 195, :q => 'recipe'} | |||
assert_response 404 | |||
assert_nil assigns(:results) | |||
end | |||
def test_quick_jump_to_issue | |||
# issue of a public project | |||
get :index, :q => "3" | |||
get :index, :params => {:q => "3"} | |||
assert_redirected_to '/issues/3' | |||
# issue of a private project | |||
get :index, :q => "4" | |||
get :index, :params => {:q => "4"} | |||
assert_response :success | |||
assert_template 'index' | |||
end | |||
def test_large_integer | |||
get :index, :q => '4615713488' | |||
get :index, :params => {:q => '4615713488'} | |||
assert_response :success | |||
assert_template 'index' | |||
end | |||
def test_tokens_with_quotes | |||
get :index, :id => 1, :q => '"good bye" hello "bye bye"' | |||
get :index, :params => {:id => 1, :q => '"good bye" hello "bye bye"'} | |||
assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens) | |||
end | |||
def test_results_should_be_escaped_once | |||
assert Issue.find(1).update_attributes(:subject => '<subject> escaped_once', :description => '<description> escaped_once') | |||
get :index, :q => 'escaped_once' | |||
get :index, :params => {:q => 'escaped_once'} | |||
assert_response :success | |||
assert_select '#search-results' do | |||
assert_select 'dt.issue a', :text => /<subject>/ | |||
@@ -322,7 +323,7 @@ class SearchControllerTest < Redmine::ControllerTest | |||
def test_keywords_should_be_highlighted | |||
assert Issue.find(1).update_attributes(:subject => 'subject highlighted', :description => 'description highlighted') | |||
get :index, :q => 'highlighted' | |||
get :index, :params => {:q => 'highlighted'} | |||
assert_response :success | |||
assert_select '#search-results' do | |||
assert_select 'dt.issue a span.highlight', :text => 'highlighted' |
@@ -64,7 +64,7 @@ class SearchCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
@users_to_test.each do |user, fields| | |||
@request.session[:user_id] = user.id | |||
@fields.each_with_index do |field, i| | |||
get :index, :q => "value#{i}" | |||
get :index, :params => {:q => "value#{i}"} | |||
assert_response :success | |||
# we should get a result only if the custom field is visible | |||
if fields.include?(field) |
@@ -35,7 +35,7 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => 10.hours.ago, :updated_on => 10.hours.ago) | |||
created = token.reload.created_on | |||
get :index, {}, {:user_id => 2, :tk => token.value} | |||
get :index, :session => {:user_id => 2, :tk => token.value} | |||
assert_response :success | |||
token.reload | |||
assert_equal created.to_i, token.created_on.to_i | |||
@@ -48,13 +48,13 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) | |||
with_settings :session_lifetime => '0', :session_timeout => '0' do | |||
get :index, {}, {:user_id => 2, :tk => token.value} | |||
get :index, :session => {:user_id => 2, :tk => token.value} | |||
assert_response :success | |||
end | |||
end | |||
def test_user_session_without_token_should_be_reset | |||
get :index, {}, {:user_id => 2} | |||
get :index, :session => {:user_id => 2} | |||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' | |||
end | |||
@@ -63,7 +63,7 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) | |||
with_settings :session_timeout => '720' do | |||
get :index, {}, {:user_id => 2, :tk => token.value} | |||
get :index, :session => {:user_id => 2, :tk => token.value} | |||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' | |||
end | |||
end | |||
@@ -73,7 +73,7 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) | |||
with_settings :session_timeout => '720' do | |||
get :index, {}, {:user_id => 2, :tk => token.value} | |||
get :index, :session => {:user_id => 2, :tk => token.value} | |||
assert_response :success | |||
end | |||
end | |||
@@ -83,7 +83,7 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) | |||
with_settings :session_timeout => '60' do | |||
get :index, {}, {:user_id => 2, :tk => token.value} | |||
get :index, :session => {:user_id => 2, :tk => token.value} | |||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' | |||
end | |||
end | |||
@@ -93,7 +93,7 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) | |||
with_settings :session_timeout => '60' do | |||
get :index, {}, {:user_id => 2, :tk => token.value} | |||
get :index, :session => {:user_id => 2, :tk => token.value} | |||
assert_response :success | |||
end | |||
end | |||
@@ -106,7 +106,7 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
autologin_token = Token.create!(:user_id => 2, :action => 'autologin', :created_on => 1.day.ago) | |||
@request.cookies['autologin'] = autologin_token.value | |||
get :index, {}, {:user_id => 2, :tk => token.value} | |||
get :index, :session => {:user_id => 2, :tk => token.value} | |||
assert_equal 2, session[:user_id] | |||
assert_response :success | |||
assert_not_equal token.value, session[:tk] | |||
@@ -122,7 +122,7 @@ class SessionsControllerTest < Redmine::ControllerTest | |||
token = Token.create!(:user_id => 2, :action => 'session', :created_on => created, :updated_on => created) | |||
with_settings :session_timeout => '60' do | |||
get :index, {}, {:user_id => user.id, :tk => token.value} | |||
get :index, :session => {:user_id => user.id, :tk => token.value} | |||
assert_redirected_to 'http://test.host/login?back_url=http%3A%2F%2Ftest.host%2F' | |||
assert_include "Veuillez vous reconnecter", flash[:error] | |||
assert_equal :fr, current_language |
@@ -73,11 +73,14 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_post_edit_notifications | |||
post :edit, :settings => {:mail_from => 'functional@test.foo', | |||
:bcc_recipients => '0', | |||
:notified_events => %w(issue_added issue_updated news_added), | |||
:emails_footer => 'Test footer' | |||
} | |||
post :edit, :params => { | |||
:settings => { | |||
:mail_from => 'functional@test.foo', | |||
:bcc_recipients => '0', | |||
:notified_events => %w(issue_added issue_updated news_added), | |||
:emails_footer => 'Test footer' | |||
} | |||
} | |||
assert_redirected_to '/settings' | |||
assert_equal 'functional@test.foo', Setting.mail_from | |||
assert !Setting.bcc_recipients? | |||
@@ -125,12 +128,14 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_post_edit_commit_update_keywords | |||
post :edit, :settings => { | |||
:commit_update_keywords => { | |||
:keywords => ["resolves", "closes"], | |||
:status_id => ["3", "5"], | |||
:done_ratio => ["", "100"], | |||
:if_tracker_id => ["", "2"] | |||
post :edit, :params => { | |||
:settings => { | |||
:commit_update_keywords => { | |||
:keywords => ["resolves", "closes"], | |||
:status_id => ["3", "5"], | |||
:done_ratio => ["", "100"], | |||
:if_tracker_id => ["", "2"] | |||
} | |||
} | |||
} | |||
assert_redirected_to '/settings' | |||
@@ -142,10 +147,11 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
def test_post_edit_should_send_security_notification_for_notified_settings | |||
ActionMailer::Base.deliveries.clear | |||
post :edit, :settings => { | |||
:login_required => 1 | |||
post :edit, :params => { | |||
:settings => { | |||
:login_required => 1 | |||
} | |||
} | |||
assert_not_nil (mail = ActionMailer::Base.deliveries.last) | |||
assert_mail_body_match '0.0.0.0', mail | |||
assert_mail_body_match I18n.t(:setting_login_required), mail | |||
@@ -161,19 +167,21 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
def test_post_edit_should_not_send_security_notification_for_non_notified_settings | |||
ActionMailer::Base.deliveries.clear | |||
post :edit, :settings => { | |||
:app_title => 'MineRed' | |||
post :edit, :params => { | |||
:settings => { | |||
:app_title => 'MineRed' | |||
} | |||
} | |||
assert_nil (mail = ActionMailer::Base.deliveries.last) | |||
end | |||
def test_post_edit_should_not_send_security_notification_for_unchanged_settings | |||
ActionMailer::Base.deliveries.clear | |||
post :edit, :settings => { | |||
:login_required => 0 | |||
post :edit, :params => { | |||
:settings => { | |||
:login_required => 0 | |||
} | |||
} | |||
assert_nil (mail = ActionMailer::Base.deliveries.last) | |||
end | |||
@@ -185,7 +193,7 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
end | |||
Setting.plugin_foo = {'sample_setting' => 'Plugin setting value'} | |||
get :plugin, :id => 'foo' | |||
get :plugin, :params => {:id => 'foo'} | |||
assert_response :success | |||
assert_template 'plugin' | |||
assert_select 'form[action="/settings/plugin/foo"]' do | |||
@@ -196,14 +204,14 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_get_invalid_plugin_settings | |||
get :plugin, :id => 'none' | |||
get :plugin, :params => {:id => 'none'} | |||
assert_response 404 | |||
end | |||
def test_get_non_configurable_plugin_settings | |||
Redmine::Plugin.register(:foo) {} | |||
get :plugin, :id => 'foo' | |||
get :plugin, :params => {:id => 'foo'} | |||
assert_response 404 | |||
ensure | |||
@@ -216,7 +224,10 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
:default => {'sample_setting' => 'Plugin setting value'} | |||
end | |||
post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |||
post :plugin, :params => { | |||
:id => 'foo', | |||
:settings => {'sample_setting' => 'Value'} | |||
} | |||
assert_redirected_to '/settings/plugin/foo' | |||
assert_equal({'sample_setting' => 'Value'}, Setting.plugin_foo) | |||
@@ -225,7 +236,10 @@ class SettingsControllerTest < Redmine::ControllerTest | |||
def test_post_non_configurable_plugin_settings | |||
Redmine::Plugin.register(:foo) {} | |||
post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |||
post :plugin, :params => { | |||
:id => 'foo', | |||
:settings => {'sample_setting' => 'Value'} | |||
} | |||
assert_response 404 | |||
ensure |
@@ -48,9 +48,11 @@ class SysControllerTest < Redmine::ControllerTest | |||
def test_create_project_repository | |||
assert_nil Project.find(4).repository | |||
post :create_project_repository, :id => 4, | |||
:vendor => 'Subversion', | |||
:repository => { :url => 'file:///create/project/repository/subproject2'} | |||
post :create_project_repository, :params => { | |||
:id => 4, | |||
:vendor => 'Subversion', | |||
:repository => { :url => 'file:///create/project/repository/subproject2'} | |||
} | |||
assert_response :created | |||
assert_equal 'application/xml', @response.content_type | |||
@@ -67,18 +69,20 @@ class SysControllerTest < Redmine::ControllerTest | |||
end | |||
def test_create_already_existing | |||
post :create_project_repository, :id => 1, | |||
post :create_project_repository, :params => { | |||
:id => 1, | |||
:vendor => 'Subversion', | |||
:repository => { :url => 'file:///create/project/repository/subproject2'} | |||
} | |||
assert_response :conflict | |||
end | |||
def test_create_with_failure | |||
post :create_project_repository, :id => 4, | |||
post :create_project_repository, :params => { | |||
:id => 4, | |||
:vendor => 'Subversion', | |||
:repository => { :url => 'invalid url'} | |||
} | |||
assert_response :unprocessable_entity | |||
end | |||
@@ -90,18 +94,18 @@ class SysControllerTest < Redmine::ControllerTest | |||
def test_fetch_changesets_one_project_by_identifier | |||
Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true) | |||
get :fetch_changesets, :id => 'ecookbook' | |||
get :fetch_changesets, :params => {:id => 'ecookbook'} | |||
assert_response :success | |||
end | |||
def test_fetch_changesets_one_project_by_id | |||
Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true) | |||
get :fetch_changesets, :id => '1' | |||
get :fetch_changesets, :params => {:id => '1'} | |||
assert_response :success | |||
end | |||
def test_fetch_changesets_unknown_project | |||
get :fetch_changesets, :id => 'unknown' | |||
get :fetch_changesets, :params => {:id => 'unknown'} | |||
assert_response 404 | |||
end | |||
@@ -114,14 +118,14 @@ class SysControllerTest < Redmine::ControllerTest | |||
def test_api_key | |||
with_settings :sys_api_key => 'my_secret_key' do | |||
get :projects, :key => 'my_secret_key' | |||
get :projects, :params => {:key => 'my_secret_key'} | |||
assert_response :success | |||
end | |||
end | |||
def test_wrong_key_should_respond_with_403_error | |||
with_settings :sys_api_enabled => 'my_secret_key' do | |||
get :projects, :key => 'wrong_key' | |||
get :projects, :params => {:key => 'wrong_key'} | |||
assert_response 403 | |||
end | |||
end |
@@ -35,7 +35,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_at_project_level | |||
get :report, :project_id => 'ecookbook' | |||
get :report, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report' | |||
@@ -58,7 +58,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_all_projects_one_criteria | |||
get :report, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project'] | |||
get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -66,7 +66,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_all_time | |||
get :report, :project_id => 1, :criteria => ['project', 'issue'] | |||
get :report, :params => {:project_id => 1, :criteria => ['project', 'issue']} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -74,7 +74,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_all_time_by_day | |||
get :report, :project_id => 1, :criteria => ['project', 'issue'], :columns => 'day' | |||
get :report, :params => {:project_id => 1, :criteria => ['project', 'issue'], :columns => 'day'} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -83,7 +83,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_one_criteria | |||
get :report, :project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project'] | |||
get :report, :params => {:project_id => 1, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -91,7 +91,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_two_criteria | |||
get :report, :project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"] | |||
get :report, :params => {:project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-12-31", :criteria => ["user", "activity"]} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -104,7 +104,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value1') | |||
CustomValue.create!(:customized => entry, :custom_field => field, :value => 'value2') | |||
get :report, :project_id => 1, :columns => 'day', :criteria => ["cf_#{field.id}"] | |||
get :report, :params => {:project_id => 1, :columns => 'day', :criteria => ["cf_#{field.id}"]} | |||
assert_response :success | |||
end | |||
@@ -112,7 +112,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
TimeEntryCustomField.create!(:name => 'Single', :field_format => 'list', :possible_values => ['value1', 'value2']) | |||
TimeEntryCustomField.create!(:name => 'Multi', :field_format => 'list', :multiple => true, :possible_values => ['value1', 'value2']) | |||
get :report, :project_id => 1 | |||
get :report, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_select 'select[name=?]', 'criteria[]' do | |||
assert_select 'option', :text => 'Single' | |||
@@ -121,7 +121,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_one_day | |||
get :report, :project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"] | |||
get :report, :params => {:project_id => 1, :columns => 'day', :from => "2007-03-23", :to => "2007-03-23", :criteria => ["user", "activity"]} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -135,7 +135,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
TimeEntry.generate!(:hours => '8', :spent_on => '2010-01-01') # 2009-53 | |||
TimeEntry.generate!(:hours => '16', :spent_on => '2010-01-05') # 2010-1 | |||
get :report, :columns => 'week', :from => "2009-12-25", :to => "2010-01-05", :criteria => ["project"] | |||
get :report, :params => {:columns => 'week', :from => "2009-12-25", :to => "2010-01-05", :criteria => ["project"]} | |||
assert_response :success | |||
assert_select '#time-report thead tr' do | |||
@@ -167,7 +167,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_with_association_custom_fields | |||
get :report, :criteria => ['cf_1', 'cf_3', 'cf_7'] | |||
get :report, :params => {:criteria => ['cf_1', 'cf_3', 'cf_7']} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -187,7 +187,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_one_criteria_no_result | |||
get :report, :project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project'] | |||
get :report, :params => {:project_id => 1, :columns => 'week', :from => "1998-04-01", :to => "1998-04-30", :criteria => ['project']} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_not_nil assigns(:report) | |||
@@ -195,7 +195,7 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_status_criterion | |||
get :report, :project_id => 1, :criteria => ['status'] | |||
get :report, :params => {:project_id => 1, :criteria => ['status']} | |||
assert_response :success | |||
assert_template 'report' | |||
assert_select 'th', :text => 'Status' | |||
@@ -203,8 +203,13 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_all_projects_csv_export | |||
get :report, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", | |||
:criteria => ["project", "user", "activity"], :format => "csv" | |||
get :report, :params => { | |||
:columns => 'month', | |||
:from => "2007-01-01", | |||
:to => "2007-06-30", | |||
:criteria => ["project", "user", "activity"], | |||
:format => "csv" | |||
} | |||
assert_response :success | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
lines = @response.body.chomp.split("\n") | |||
@@ -215,9 +220,14 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_report_csv_export | |||
get :report, :project_id => 1, :columns => 'month', | |||
:from => "2007-01-01", :to => "2007-06-30", | |||
:criteria => ["project", "user", "activity"], :format => "csv" | |||
get :report, :params => { | |||
:project_id => 1, | |||
:columns => 'month', | |||
:from => "2007-01-01", | |||
:to => "2007-06-30", | |||
:criteria => ["project", "user", "activity"], | |||
:format => "csv" | |||
} | |||
assert_response :success | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
lines = @response.body.chomp.split("\n") | |||
@@ -248,9 +258,14 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
assert_equal 3, te2.user_id | |||
with_settings :default_language => "zh-TW" do | |||
get :report, :project_id => 1, :columns => 'day', | |||
:from => "2011-11-11", :to => "2011-11-11", | |||
:criteria => ["user"], :format => "csv" | |||
get :report, :params => { | |||
:project_id => 1, | |||
:columns => 'day', | |||
:from => "2011-11-11", | |||
:to => "2011-11-11", | |||
:criteria => ["user"], | |||
:format => "csv" | |||
} | |||
end | |||
assert_response :success | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
@@ -290,9 +305,14 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
assert_equal 3, te2.user_id | |||
with_settings :default_language => "zh-TW" do | |||
get :report, :project_id => 1, :columns => 'day', | |||
:from => "2011-11-11", :to => "2011-11-11", | |||
:criteria => ["user"], :format => "csv" | |||
get :report, :params => { | |||
:project_id => 1, | |||
:columns => 'day', | |||
:from => "2011-11-11", | |||
:to => "2011-11-11", | |||
:criteria => ["user"], | |||
:format => "csv" | |||
} | |||
end | |||
assert_response :success | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
@@ -321,9 +341,14 @@ class TimeEntryReportsControllerTest < Redmine::ControllerTest | |||
assert_equal 7.3, te2.hours | |||
assert_equal 3, te2.user_id | |||
get :report, :project_id => 1, :columns => 'day', | |||
:from => "2011-11-11", :to => "2011-11-11", | |||
:criteria => ["user"], :format => "csv" | |||
get :report, :params => { | |||
:project_id => 1, | |||
:columns => 'day', | |||
:from => "2011-11-11", | |||
:to => "2011-11-11", | |||
:criteria => ["user"], | |||
:format => "csv" | |||
} | |||
assert_response :success | |||
assert_equal 'text/csv; header=present', @response.content_type | |||
lines = @response.body.chomp.split("\n") |
@@ -43,7 +43,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_new_with_project_id | |||
@request.session[:user_id] = 3 | |||
get :new, :project_id => 1 | |||
get :new, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_template 'new' | |||
assert_select 'input[name=?][type=hidden]', 'project_id' | |||
@@ -53,7 +53,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_new_with_issue_id | |||
@request.session[:user_id] = 3 | |||
get :new, :issue_id => 2 | |||
get :new, :params => {:issue_id => 2} | |||
assert_response :success | |||
assert_template 'new' | |||
assert_select 'input[name=?][type=hidden]', 'project_id', 0 | |||
@@ -63,7 +63,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_new_without_project_should_prefill_the_form | |||
@request.session[:user_id] = 3 | |||
get :new, :time_entry => {:project_id => '1'} | |||
get :new, :params => {:time_entry => {:project_id => '1'}} | |||
assert_response :success | |||
assert_template 'new' | |||
assert_select 'select[name=?]', 'time_entry[project_id]' do | |||
@@ -81,7 +81,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_new_should_select_default_activity | |||
@request.session[:user_id] = 3 | |||
get :new, :project_id => 1 | |||
get :new, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_select 'select[name=?]', 'time_entry[activity_id]' do | |||
assert_select 'option[selected=selected]', :text => 'Development' | |||
@@ -90,21 +90,21 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_new_should_only_show_active_time_entry_activities | |||
@request.session[:user_id] = 3 | |||
get :new, :project_id => 1 | |||
get :new, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_select 'option', :text => 'Inactive Activity', :count => 0 | |||
end | |||
def test_post_new_as_js_should_update_activity_options | |||
@request.session[:user_id] = 3 | |||
post :new, :time_entry => {:project_id => 1}, :format => 'js' | |||
post :new, :params => {:time_entry => {:project_id => 1}, :format => 'js'} | |||
assert_response :success | |||
assert_include '#time_entry_activity_id', response.body | |||
end | |||
def test_get_edit_existing_time | |||
@request.session[:user_id] = 2 | |||
get :edit, :id => 2, :project_id => nil | |||
get :edit, :params => {:id => 2, :project_id => nil} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_select 'form[action=?]', '/time_entries/2' | |||
@@ -116,7 +116,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
te.save!(:validate => false) | |||
@request.session[:user_id] = 1 | |||
get :edit, :project_id => 1, :id => 1 | |||
get :edit, :params => {:project_id => 1, :id => 1} | |||
assert_response :success | |||
assert_template 'edit' | |||
# Blank option since nothing is pre-selected | |||
@@ -126,13 +126,16 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_post_create | |||
@request.session[:user_id] = 3 | |||
assert_difference 'TimeEntry.count' do | |||
post :create, :project_id => 1, | |||
:time_entry => {:comments => 'Some work on TimelogControllerTest', | |||
# Not the default activity | |||
:activity_id => '11', | |||
:spent_on => '2008-03-14', | |||
:issue_id => '1', | |||
:hours => '7.3'} | |||
post :create, :params => { | |||
:project_id => 1, | |||
:time_entry => {:comments => 'Some work on TimelogControllerTest', | |||
# Not the default activity | |||
:activity_id => '11', | |||
:spent_on => '2008-03-14', | |||
:issue_id => '1', | |||
:hours => '7.3' | |||
} | |||
} | |||
assert_redirected_to '/projects/ecookbook/time_entries' | |||
end | |||
@@ -149,13 +152,17 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_post_create_with_blank_issue | |||
@request.session[:user_id] = 3 | |||
assert_difference 'TimeEntry.count' do | |||
post :create, :project_id => 1, | |||
:time_entry => {:comments => 'Some work on TimelogControllerTest', | |||
# Not the default activity | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'} | |||
post :create, :params => { | |||
:project_id => 1, | |||
:time_entry => { | |||
:comments => 'Some work on TimelogControllerTest', | |||
# Not the default activity | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
} | |||
} | |||
assert_redirected_to '/projects/ecookbook/time_entries' | |||
end | |||
@@ -174,9 +181,11 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => { | |||
:project_id => '1', :issue_id => '', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '1', :issue_id => '', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
} | |||
} | |||
end | |||
end | |||
@@ -186,9 +195,11 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => { | |||
:project_id => '1', :issue_id => '', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '1', :issue_id => '', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
} | |||
} | |||
end | |||
end | |||
@@ -198,9 +209,11 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => { | |||
:project_id => '', :issue_id => '1', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '', :issue_id => '1', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
} | |||
} | |||
assert_select_error /Issue is invalid/ | |||
end | |||
@@ -211,9 +224,11 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => { | |||
:project_id => '', :issue_id => '1', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '', :issue_id => '1', | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
} | |||
} | |||
assert_select_error /Issue is invalid/ | |||
end | |||
@@ -225,9 +240,11 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 3 | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => { | |||
:project_id => '', :issue_id => issue.id.to_s, | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '', :issue_id => issue.id.to_s, | |||
:activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3' | |||
} | |||
} | |||
end | |||
assert_select_error /Issue is invalid/ | |||
@@ -239,12 +256,16 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_and_continue_at_project_level | |||
@request.session[:user_id] = 2 | |||
assert_difference 'TimeEntry.count' do | |||
post :create, :time_entry => {:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'}, | |||
:continue => '1' | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
}, | |||
:continue => '1' | |||
} | |||
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=1' | |||
end | |||
end | |||
@@ -252,12 +273,16 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_and_continue_at_issue_level | |||
@request.session[:user_id] = 2 | |||
assert_difference 'TimeEntry.count' do | |||
post :create, :time_entry => {:project_id => '', | |||
:activity_id => '11', | |||
:issue_id => '1', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'}, | |||
:continue => '1' | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '', | |||
:activity_id => '11', | |||
:issue_id => '1', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
}, | |||
:continue => '1' | |||
} | |||
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D=' | |||
end | |||
end | |||
@@ -265,12 +290,16 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_and_continue_with_project_id | |||
@request.session[:user_id] = 2 | |||
assert_difference 'TimeEntry.count' do | |||
post :create, :project_id => 1, | |||
:time_entry => {:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'}, | |||
:continue => '1' | |||
post :create, :params => { | |||
:project_id => 1, | |||
:time_entry => { | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
}, | |||
:continue => '1' | |||
} | |||
assert_redirected_to '/projects/ecookbook/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=' | |||
end | |||
end | |||
@@ -278,12 +307,16 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_and_continue_with_issue_id | |||
@request.session[:user_id] = 2 | |||
assert_difference 'TimeEntry.count' do | |||
post :create, :issue_id => 1, | |||
:time_entry => {:activity_id => '11', | |||
:issue_id => '1', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'}, | |||
:continue => '1' | |||
post :create, :params => { | |||
:issue_id => 1, | |||
:time_entry => { | |||
:activity_id => '11', | |||
:issue_id => '1', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
}, | |||
:continue => '1' | |||
} | |||
assert_redirected_to '/issues/1/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D=' | |||
end | |||
end | |||
@@ -291,18 +324,21 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_without_log_time_permission_should_be_denied | |||
@request.session[:user_id] = 2 | |||
Role.find_by_name('Manager').remove_permission! :log_time | |||
post :create, :project_id => 1, | |||
:time_entry => {:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'} | |||
post :create, :params => { | |||
:project_id => 1, | |||
:time_entry => { | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
} | |||
} | |||
assert_response 403 | |||
end | |||
def test_create_without_project_and_issue_should_fail | |||
@request.session[:user_id] = 2 | |||
post :create, :time_entry => {:issue_id => ''} | |||
post :create, :params => {:time_entry => {:issue_id => ''}} | |||
assert_response :success | |||
assert_template 'new' | |||
@@ -310,12 +346,15 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_with_failure | |||
@request.session[:user_id] = 2 | |||
post :create, :project_id => 1, | |||
:time_entry => {:activity_id => '', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'} | |||
post :create, :params => { | |||
:project_id => 1, | |||
:time_entry => { | |||
:activity_id => '', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
} | |||
} | |||
assert_response :success | |||
assert_template 'new' | |||
end | |||
@@ -323,11 +362,15 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_without_project | |||
@request.session[:user_id] = 2 | |||
assert_difference 'TimeEntry.count' do | |||
post :create, :time_entry => {:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'} | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
} | |||
} | |||
end | |||
assert_redirected_to '/projects/ecookbook/time_entries' | |||
@@ -338,11 +381,15 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_without_project_should_fail_with_issue_not_inside_project | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => {:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '5', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'} | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '5', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
} | |||
} | |||
end | |||
assert_response :success | |||
@@ -354,11 +401,15 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Project.find(3).disable_module!(:time_tracking) | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => {:project_id => '3', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3'} | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '3', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '7.3' | |||
} | |||
} | |||
end | |||
assert_response 403 | |||
@@ -367,11 +418,15 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_create_without_project_with_failure | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'TimeEntry.count' do | |||
post :create, :time_entry => {:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => ''} | |||
post :create, :params => { | |||
:time_entry => { | |||
:project_id => '1', | |||
:activity_id => '11', | |||
:issue_id => '', | |||
:spent_on => '2008-03-14', | |||
:hours => '' | |||
} | |||
} | |||
end | |||
assert_response :success | |||
@@ -386,9 +441,13 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
assert_equal 2, entry.user_id | |||
@request.session[:user_id] = 1 | |||
put :update, :id => 1, | |||
:time_entry => {:issue_id => '2', | |||
:hours => '8'} | |||
put :update, :params => { | |||
:id => 1, | |||
:time_entry => { | |||
:issue_id => '2', | |||
:hours => '8' | |||
} | |||
} | |||
assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |||
entry.reload | |||
@@ -401,7 +460,12 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
entry = TimeEntry.generate!(:issue_id => 1) | |||
@request.session[:user_id] = 1 | |||
put :update, :id => entry.id, :time_entry => {:issue_id => '5'} | |||
put :update, :params => { | |||
:id => entry.id, | |||
:time_entry => { | |||
:issue_id => '5' | |||
} | |||
} | |||
assert_response 302 | |||
entry.reload | |||
@@ -414,14 +478,20 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Project.find(3).disable_module!(:time_tracking) | |||
@request.session[:user_id] = 1 | |||
put :update, :id => entry.id, :time_entry => {:issue_id => '5'} | |||
put :update, :params => { | |||
:id => entry.id, | |||
:time_entry => { | |||
:issue_id => '5' | |||
} | |||
} | |||
assert_response 200 | |||
assert_include "Issue is invalid", assigns(:time_entry).errors.full_messages | |||
end | |||
def test_get_bulk_edit | |||
@request.session[:user_id] = 2 | |||
get :bulk_edit, :ids => [1, 2] | |||
get :bulk_edit, :params => {:ids => [1, 2]} | |||
assert_response :success | |||
assert_template 'bulk_edit' | |||
@@ -444,7 +514,8 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_get_bulk_edit_on_different_projects | |||
@request.session[:user_id] = 2 | |||
get :bulk_edit, :ids => [1, 2, 6] | |||
get :bulk_edit, :params => {:ids => [1, 2, 6]} | |||
assert_response :success | |||
assert_template 'bulk_edit' | |||
end | |||
@@ -455,14 +526,14 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Role.find_by_name('Manager').add_permission! :edit_own_time_entries | |||
ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id} | |||
get :bulk_edit, :ids => ids | |||
get :bulk_edit, :params => {:ids => ids} | |||
assert_response :success | |||
end | |||
def test_bulk_update | |||
@request.session[:user_id] = 2 | |||
# update time entry activity | |||
post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} | |||
post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :activity_id => 9}} | |||
assert_response 302 | |||
# check that the issues were updated | |||
@@ -471,7 +542,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_bulk_update_with_failure | |||
@request.session[:user_id] = 2 | |||
post :bulk_update, :ids => [1, 2], :time_entry => { :hours => 'A'} | |||
post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :hours => 'A'}} | |||
assert_response 302 | |||
assert_match /Failed to save 2 time entrie/, flash[:error] | |||
@@ -483,7 +554,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Member.create!(:user_id => 2, :project_id => 3, :role_ids => [1]) | |||
# update time entry activity | |||
post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } | |||
post :bulk_update, :params => {:ids => [1, 2, 4], :time_entry => { :activity_id => 9 }} | |||
assert_response 302 | |||
# check that the issues were updated | |||
@@ -496,7 +567,8 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
action = { :controller => "timelog", :action => "bulk_update" } | |||
assert user.allowed_to?(action, TimeEntry.find(1).project) | |||
assert ! user.allowed_to?(action, TimeEntry.find(5).project) | |||
post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 } | |||
post :bulk_update, :params => {:ids => [1, 5], :time_entry => { :activity_id => 9 }} | |||
assert_response 403 | |||
end | |||
@@ -506,7 +578,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Role.find_by_name('Manager').add_permission! :edit_own_time_entries | |||
ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id} | |||
post :bulk_update, :ids => ids, :time_entry => { :activity_id => 9 } | |||
post :bulk_update, :params => {:ids => ids, :time_entry => { :activity_id => 9 }} | |||
assert_response 302 | |||
end | |||
@@ -515,13 +587,13 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
Role.find_by_name('Manager').remove_permission! :edit_time_entries | |||
Role.find_by_name('Manager').add_permission! :edit_own_time_entries | |||
post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9 } | |||
post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :activity_id => 9 }} | |||
assert_response 403 | |||
end | |||
def test_bulk_update_custom_field | |||
@request.session[:user_id] = 2 | |||
post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } | |||
post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }} | |||
assert_response 302 | |||
assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value} | |||
@@ -530,7 +602,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_bulk_update_clear_custom_field | |||
field = TimeEntryCustomField.generate!(:field_format => 'string') | |||
@request.session[:user_id] = 2 | |||
post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} } | |||
post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} }} | |||
assert_response 302 | |||
assert_equal ["", ""], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(field).value} | |||
@@ -538,7 +610,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter | |||
@request.session[:user_id] = 2 | |||
post :bulk_update, :ids => [1,2], :back_url => '/time_entries' | |||
post :bulk_update, :params => {:ids => [1,2], :back_url => '/time_entries'} | |||
assert_response :redirect | |||
assert_redirected_to '/time_entries' | |||
@@ -546,7 +618,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host | |||
@request.session[:user_id] = 2 | |||
post :bulk_update, :ids => [1,2], :back_url => 'http://google.com' | |||
post :bulk_update, :params => {:ids => [1,2], :back_url => 'http://google.com'} | |||
assert_response :redirect | |||
assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier | |||
@@ -555,14 +627,15 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_post_bulk_update_without_edit_permission_should_be_denied | |||
@request.session[:user_id] = 2 | |||
Role.find_by_name('Manager').remove_permission! :edit_time_entries | |||
post :bulk_update, :ids => [1,2] | |||
post :bulk_update, :params => {:ids => [1,2]} | |||
assert_response 403 | |||
end | |||
def test_destroy | |||
@request.session[:user_id] = 2 | |||
delete :destroy, :id => 1 | |||
delete :destroy, :params => {:id => 1} | |||
assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |||
assert_equal I18n.t(:notice_successful_delete), flash[:notice] | |||
assert_nil TimeEntry.find_by_id(1) | |||
@@ -571,9 +644,9 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_destroy_should_fail | |||
# simulate that this fails (e.g. due to a plugin), see #5700 | |||
TimeEntry.any_instance.expects(:destroy).returns(false) | |||
@request.session[:user_id] = 2 | |||
delete :destroy, :id => 1 | |||
delete :destroy, :params => {:id => 1} | |||
assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |||
assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] | |||
assert_not_nil TimeEntry.find_by_id(1) | |||
@@ -597,14 +670,14 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_index_my_spent_time | |||
@request.session[:user_id] = 2 | |||
get :index, :user_id => 'me' | |||
get :index, :params => {:user_id => 'me'} | |||
assert_response :success | |||
assert_template 'index' | |||
assert assigns(:entries).all? {|entry| entry.user_id == 2} | |||
end | |||
def test_index_at_project_level | |||
get :index, :project_id => 'ecookbook' | |||
get :index, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:entries) | |||
@@ -620,7 +693,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
entry = TimeEntry.generate!(:project => Project.find(3)) | |||
with_settings :display_subprojects_issues => '0' do | |||
get :index, :project_id => 'ecookbook' | |||
get :index, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_include entry, assigns(:entries) | |||
@@ -631,7 +704,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
entry = TimeEntry.generate!(:project => Project.find(3)) | |||
with_settings :display_subprojects_issues => '0' do | |||
get :index, :project_id => 'ecookbook', :subproject_id => 3 | |||
get :index, :params => {:project_id => 'ecookbook', :subproject_id => 3} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_include entry, assigns(:entries) | |||
@@ -644,7 +717,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
TimeEntry.generate!(:issue => issue, :hours => 3) | |||
@request.session[:user_id] = 2 | |||
get :index, :project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1 | |||
get :index, :params => {:project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1} | |||
assert_select '.total-for-hours', :text => 'Hours: 7.00' | |||
end | |||
@@ -655,15 +728,17 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
TimeEntry.generate!(:issue => issue, :hours => 3) | |||
@request.session[:user_id] = 2 | |||
get :index, :project_id => 'ecookbook', :"issue.fixed_version_id" => version.id.to_s, :set_filter => 1 | |||
get :index, :params => {:project_id => 'ecookbook', :"issue.fixed_version_id" => version.id.to_s, :set_filter => 1} | |||
assert_select '.total-for-hours', :text => 'Hours: 5.00' | |||
end | |||
def test_index_at_project_level_with_date_range | |||
get :index, :project_id => 'ecookbook', | |||
get :index, :params => { | |||
:project_id => 'ecookbook', | |||
:f => ['spent_on'], | |||
:op => {'spent_on' => '><'}, | |||
:v => {'spent_on' => ['2007-03-20', '2007-04-30']} | |||
} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:entries) | |||
@@ -674,7 +749,11 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index_at_project_level_with_date_range_using_from_and_to_params | |||
get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30' | |||
get :index, :params => { | |||
:project_id => 'ecookbook', | |||
:from => '2007-03-20', | |||
:to => '2007-04-30' | |||
} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:entries) | |||
@@ -685,10 +764,12 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index_at_project_level_with_period | |||
get :index, :project_id => 'ecookbook', | |||
get :index, :params => { | |||
:project_id => 'ecookbook', | |||
:f => ['spent_on'], | |||
:op => {'spent_on' => '>t-'}, | |||
:v => {'spent_on' => ['7']} | |||
} | |||
assert_response :success | |||
assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' | |||
@@ -699,18 +780,22 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
t2 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00', :activity_id => 10) | |||
t3 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00', :activity_id => 10) | |||
get :index, :project_id => 1, | |||
get :index, :params => { | |||
:project_id => 1, | |||
:f => ['spent_on'], | |||
:op => {'spent_on' => '><'}, | |||
:v => {'spent_on' => ['2012-06-15', '2012-06-16']} | |||
} | |||
assert_response :success | |||
assert_equal [t2, t1, t3], assigns(:entries) | |||
get :index, :project_id => 1, | |||
get :index, :params => { | |||
:project_id => 1, | |||
:f => ['spent_on'], | |||
:op => {'spent_on' => '><'}, | |||
:v => {'spent_on' => ['2012-06-15', '2012-06-16']}, | |||
:sort => 'spent_on' | |||
} | |||
assert_response :success | |||
assert_equal [t3, t1, t2], assigns(:entries) | |||
end | |||
@@ -719,7 +804,11 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'}) | |||
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5) | |||
get :index, :f => ['issue.cf_2'], :op => {'issue.cf_2' => '='}, :v => {'issue.cf_2' => ['filter_on_issue_custom_field']} | |||
get :index, :params => { | |||
:f => ['issue.cf_2'], | |||
:op => {'issue.cf_2' => '='}, | |||
:v => {'issue.cf_2' => ['filter_on_issue_custom_field']} | |||
} | |||
assert_response :success | |||
assert_equal [entry], assigns(:entries) | |||
end | |||
@@ -728,7 +817,9 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'}) | |||
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5) | |||
get :index, :c => %w(project spent_on issue comments hours issue.cf_2) | |||
get :index, :params => { | |||
:c => %w(project spent_on issue comments hours issue.cf_2) | |||
} | |||
assert_response :success | |||
assert_include :'issue.cf_2', assigns(:query).column_names | |||
assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field' | |||
@@ -739,7 +830,9 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
entry = TimeEntry.generate!(:hours => 2.5, :custom_field_values => {field.id => 'CF Value'}) | |||
field_name = "cf_#{field.id}" | |||
get :index, :c => ["hours", field_name] | |||
get :index, :params => { | |||
:c => ["hours", field_name] | |||
} | |||
assert_response :success | |||
assert_include field_name.to_sym, assigns(:query).column_names | |||
assert_select "td.#{field_name}", :text => 'CF Value' | |||
@@ -752,7 +845,10 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
TimeEntry.generate!(:hours => 2.5, :custom_field_values => {field.id => 'CF Value 2'}) | |||
field_name = "cf_#{field.id}" | |||
get :index, :c => ["hours", field_name], :sort => field_name | |||
get :index, :params => { | |||
:c => ["hours", field_name], | |||
:sort => field_name | |||
} | |||
assert_response :success | |||
assert_include field_name.to_sym, assigns(:query).column_names | |||
assert_select "th a.sort", :text => 'String Field' | |||
@@ -768,14 +864,14 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
query.save! | |||
@request.session[:user_id] = 2 | |||
get :index, :project_id => 'ecookbook', :query_id => query.id | |||
get :index, :params => {:project_id => 'ecookbook', :query_id => query.id} | |||
assert_response :success | |||
assert_select 'h2', :text => query.name | |||
assert_select '#sidebar a.selected', :text => query.name | |||
end | |||
def test_index_atom_feed | |||
get :index, :project_id => 1, :format => 'atom' | |||
get :index, :params => {:project_id => 1, :format => 'atom'} | |||
assert_response :success | |||
assert_equal 'application/atom+xml', @response.content_type | |||
assert_not_nil assigns(:items) | |||
@@ -783,11 +879,13 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index_at_project_level_should_include_csv_export_dialog | |||
get :index, :project_id => 'ecookbook', | |||
get :index, :params => { | |||
:project_id => 'ecookbook', | |||
:f => ['spent_on'], | |||
:op => {'spent_on' => '>='}, | |||
:v => {'spent_on' => ['2007-04-01']}, | |||
:c => ['spent_on', 'user'] | |||
} | |||
assert_response :success | |||
assert_select '#csv-export-options' do | |||
@@ -815,7 +913,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_index_csv_all_projects | |||
with_settings :date_format => '%m/%d/%Y' do | |||
get :index, :format => 'csv' | |||
get :index, :params => {:format => 'csv'} | |||
assert_response :success | |||
assert_equal 'text/csv; header=present', response.content_type | |||
end | |||
@@ -823,7 +921,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
def test_index_csv | |||
with_settings :date_format => '%m/%d/%Y' do | |||
get :index, :project_id => 1, :format => 'csv' | |||
get :index, :params => {:project_id => 1, :format => 'csv'} | |||
assert_response :success | |||
assert_equal 'text/csv; header=present', response.content_type | |||
end | |||
@@ -833,7 +931,7 @@ class TimelogControllerTest < Redmine::ControllerTest | |||
issue = Issue.find(1) | |||
entry = TimeEntry.generate!(:issue => issue, :comments => "Issue column content test") | |||
get :index, :format => 'csv' | |||
get :index, :params => {:format => 'csv'} | |||
line = response.body.split("\n").detect {|l| l.include?(entry.comments)} | |||
assert_not_nil line | |||
assert_include "#{issue.tracker} #1: #{issue.subject}", line |
@@ -64,7 +64,11 @@ class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
def test_index_should_show_visible_custom_fields_only | |||
@users_to_test.each do |user, fields| | |||
@request.session[:user_id] = user.id | |||
get :index, :project_id => 1, :issue_id => @issue.id, :c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}) | |||
get :index, :params => { | |||
:project_id => 1, | |||
:issue_id => @issue.id, | |||
:c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}) | |||
} | |||
@fields.each_with_index do |field, i| | |||
if fields.include?(field) | |||
assert_select 'td', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}" | |||
@@ -78,7 +82,12 @@ class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
def test_index_as_csv_should_show_visible_custom_fields_only | |||
@users_to_test.each do |user, fields| | |||
@request.session[:user_id] = user.id | |||
get :index, :project_id => 1, :issue_id => @issue.id, :c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}), :format => 'csv' | |||
get :index, :params => { | |||
:project_id => 1, | |||
:issue_id => @issue.id, | |||
:c => (['hours'] + @fields.map{|f| "issue.cf_#{f.id}"}), | |||
:format => 'csv' | |||
} | |||
@fields.each_with_index do |field, i| | |||
if fields.include?(field) | |||
assert_include "Value#{i}", response.body, "User #{user.id} was not able to view #{field.name} in CSV" | |||
@@ -107,12 +116,13 @@ class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest | |||
:issue => Issue.generate!(:project => p1, :tracker_id => 1, | |||
:custom_field_values => {@field2.id => 'ValueC'})) | |||
@request.session[:user_id] = user.id | |||
get :index, :c => ["hours", "issue.cf_#{@field2.id}"] | |||
get :index, :params => {:c => ["hours", "issue.cf_#{@field2.id}"]} | |||
assert_select 'td', {:text => 'ValueA'}, "ValueA not found in:\n#{response.body}" | |||
assert_select 'td', :text => 'ValueB', :count => 0 | |||
assert_select 'td', {:text => 'ValueC'}, "ValueC not found in:\n#{response.body}" | |||
get :index, :set_filter => '1', "issue.cf_#{@field2.id}" => '*' | |||
get :index, :params => {:set_filter => '1', "issue.cf_#{@field2.id}" => '*'} | |||
assert_equal %w(ValueA ValueC), assigns(:entries).map{|i| i.issue.custom_field_value(@field2)}.sort | |||
end | |||
end |
@@ -51,7 +51,14 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_create | |||
assert_difference 'Tracker.count' do | |||
post :create, :tracker => { :name => 'New tracker', :default_status_id => 1, :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] } | |||
post :create, :params => { | |||
:tracker => { | |||
:name => 'New tracker', | |||
:default_status_id => 1, | |||
:project_ids => ['1', '', ''], | |||
:custom_field_ids => ['1', '6', ''] | |||
} | |||
} | |||
end | |||
assert_redirected_to :action => 'index' | |||
tracker = Tracker.order('id DESC').first | |||
@@ -64,7 +71,13 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_create_with_disabled_core_fields | |||
assert_difference 'Tracker.count' do | |||
post :create, :tracker => { :name => 'New tracker', :default_status_id => 1, :core_fields => ['assigned_to_id', 'fixed_version_id', ''] } | |||
post :create, :params => { | |||
:tracker => { | |||
:name => 'New tracker', | |||
:default_status_id => 1, | |||
:core_fields => ['assigned_to_id', 'fixed_version_id', ''] | |||
} | |||
} | |||
end | |||
assert_redirected_to :action => 'index' | |||
tracker = Tracker.order('id DESC').first | |||
@@ -74,7 +87,13 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_create_new_with_workflow_copy | |||
assert_difference 'Tracker.count' do | |||
post :create, :tracker => { :name => 'New tracker', :default_status_id => 1 }, :copy_workflow_from => 1 | |||
post :create, :params => { | |||
:tracker => { | |||
:name => 'New tracker', | |||
:default_status_id => 1 | |||
}, | |||
:copy_workflow_from => 1 | |||
} | |||
end | |||
assert_redirected_to :action => 'index' | |||
tracker = Tracker.find_by_name('New tracker') | |||
@@ -84,8 +103,13 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_create_with_failure | |||
assert_no_difference 'Tracker.count' do | |||
post :create, :tracker => { :name => '', :project_ids => ['1', '', ''], | |||
:custom_field_ids => ['1', '6', ''] } | |||
post :create, :params => { | |||
:tracker => { | |||
:name => '', | |||
:project_ids => ['1', '', ''], | |||
:custom_field_ids => ['1', '6', ''] | |||
} | |||
} | |||
end | |||
assert_response :success | |||
assert_template 'new' | |||
@@ -95,7 +119,7 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_edit | |||
Tracker.find(1).project_ids = [1, 3] | |||
get :edit, :id => 1 | |||
get :edit, :params => {:id => 1} | |||
assert_response :success | |||
assert_template 'edit' | |||
@@ -110,7 +134,7 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
tracker.core_fields = %w(assigned_to_id fixed_version_id) | |||
tracker.save! | |||
get :edit, :id => 1 | |||
get :edit, :params => {:id => 1} | |||
assert_response :success | |||
assert_template 'edit' | |||
@@ -124,27 +148,43 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
end | |||
def test_update | |||
put :update, :id => 1, :tracker => { :name => 'Renamed', | |||
:project_ids => ['1', '2', ''] } | |||
put :update, :params => { | |||
:id => 1, | |||
:tracker => { | |||
:name => 'Renamed', | |||
:project_ids => ['1', '2', ''] | |||
} | |||
} | |||
assert_redirected_to :action => 'index' | |||
assert_equal [1, 2], Tracker.find(1).project_ids.sort | |||
end | |||
def test_update_without_projects | |||
put :update, :id => 1, :tracker => { :name => 'Renamed', | |||
:project_ids => [''] } | |||
put :update, :params => { | |||
:id => 1, | |||
:tracker => { | |||
:name => 'Renamed', | |||
:project_ids => [''] | |||
} | |||
} | |||
assert_redirected_to :action => 'index' | |||
assert Tracker.find(1).project_ids.empty? | |||
end | |||
def test_update_without_core_fields | |||
put :update, :id => 1, :tracker => { :name => 'Renamed', :core_fields => [''] } | |||
put :update, :params => { | |||
:id => 1, | |||
:tracker => { | |||
:name => 'Renamed', | |||
:core_fields => [''] | |||
} | |||
} | |||
assert_redirected_to :action => 'index' | |||
assert Tracker.find(1).core_fields.empty? | |||
end | |||
def test_update_with_failure | |||
put :update, :id => 1, :tracker => { :name => '' } | |||
put :update, :params => {:id => 1, :tracker => { :name => '' }} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_select_error /name cannot be blank/i | |||
@@ -152,14 +192,14 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_move_lower | |||
tracker = Tracker.find_by_position(1) | |||
put :update, :id => 1, :tracker => { :position => '2' } | |||
put :update, :params => {:id => 1, :tracker => { :position => '2' }} | |||
assert_equal 2, tracker.reload.position | |||
end | |||
def test_destroy | |||
tracker = Tracker.generate!(:name => 'Destroyable') | |||
assert_difference 'Tracker.count', -1 do | |||
delete :destroy, :id => tracker.id | |||
delete :destroy, :params => {:id => tracker.id} | |||
end | |||
assert_redirected_to :action => 'index' | |||
assert_nil flash[:error] | |||
@@ -167,7 +207,7 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
def test_destroy_tracker_in_use | |||
assert_no_difference 'Tracker.count' do | |||
delete :destroy, :id => 1 | |||
delete :destroy, :params => {:id => 1} | |||
end | |||
assert_redirected_to :action => 'index' | |||
assert_not_nil flash[:error] | |||
@@ -188,9 +228,11 @@ class TrackersControllerTest < Redmine::ControllerTest | |||
end | |||
def test_post_fields | |||
post :fields, :trackers => { | |||
'1' => {'core_fields' => ['assigned_to_id', 'due_date', ''], 'custom_field_ids' => ['1', '2']}, | |||
'2' => {'core_fields' => [''], 'custom_field_ids' => ['']} | |||
post :fields, :params => { | |||
:trackers => { | |||
'1' => {'core_fields' => ['assigned_to_id', 'due_date', ''], 'custom_field_ids' => ['1', '2']}, | |||
'2' => {'core_fields' => [''], 'custom_field_ids' => ['']} | |||
} | |||
} | |||
assert_redirected_to '/trackers/fields' | |||
@@ -27,7 +27,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index | |||
get :index, :project_id => 1 | |||
get :index, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:versions) | |||
@@ -46,7 +46,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index_with_completed_versions | |||
get :index, :project_id => 1, :completed => 1 | |||
get :index, :params => {:project_id => 1, :completed => 1} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:versions) | |||
@@ -57,7 +57,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index_with_tracker_ids | |||
get :index, :project_id => 1, :tracker_ids => [1, 3] | |||
get :index, :params => {:project_id => 1, :tracker_ids => [1, 3]} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:issues_by_version) | |||
@@ -66,7 +66,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_index_showing_subprojects_versions | |||
@subproject_version = Version.create!(:project => Project.find(3), :name => "Subproject version") | |||
get :index, :project_id => 1, :with_subprojects => 1 | |||
get :index, :params => {:project_id => 1, :with_subprojects => 1} | |||
assert_response :success | |||
assert_template 'index' | |||
assert_not_nil assigns(:versions) | |||
@@ -76,7 +76,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index_should_prepend_shared_versions | |||
get :index, :project_id => 1 | |||
get :index, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_select '#sidebar' do | |||
@@ -90,7 +90,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_show | |||
get :show, :id => 2 | |||
get :show, :params => {:id => 2} | |||
assert_response :success | |||
assert_template 'show' | |||
assert_not_nil assigns(:version) | |||
@@ -103,7 +103,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
issue = Issue.generate(:fixed_version => version) | |||
TimeEntry.generate!(:issue => issue, :hours => 7.2) | |||
get :show, :id => version.id | |||
get :show, :params => {:id => version.id} | |||
assert_response :success | |||
assert_select '.total-hours', :text => '7.20 hours' | |||
@@ -112,7 +112,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_show_should_display_nil_counts | |||
with_settings :default_language => 'en' do | |||
get :show, :id => 2, :status_by => 'category' | |||
get :show, :params => {:id => 2, :status_by => 'category'} | |||
assert_response :success | |||
assert_select 'div#status_by' do | |||
assert_select 'select[name=status_by]' do | |||
@@ -125,14 +125,14 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_new | |||
@request.session[:user_id] = 2 | |||
get :new, :project_id => '1' | |||
get :new, :params => {:project_id => '1'} | |||
assert_response :success | |||
assert_template 'new' | |||
end | |||
def test_new_from_issue_form | |||
@request.session[:user_id] = 2 | |||
xhr :get, :new, :project_id => '1' | |||
xhr :get, :new, :params => {:project_id => '1'} | |||
assert_response :success | |||
assert_template 'new' | |||
assert_equal 'text/javascript', response.content_type | |||
@@ -141,7 +141,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_create | |||
@request.session[:user_id] = 2 # manager | |||
assert_difference 'Version.count' do | |||
post :create, :project_id => '1', :version => {:name => 'test_add_version'} | |||
post :create, :params => {:project_id => '1', :version => {:name => 'test_add_version'}} | |||
end | |||
assert_redirected_to '/projects/ecookbook/settings/versions' | |||
version = Version.find_by_name('test_add_version') | |||
@@ -152,7 +152,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_create_from_issue_form | |||
@request.session[:user_id] = 2 | |||
assert_difference 'Version.count' do | |||
xhr :post, :create, :project_id => '1', :version => {:name => 'test_add_version_from_issue_form'} | |||
xhr :post, :create, :params => {:project_id => '1', :version => {:name => 'test_add_version_from_issue_form'}} | |||
end | |||
version = Version.find_by_name('test_add_version_from_issue_form') | |||
assert_not_nil version | |||
@@ -167,7 +167,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_create_from_issue_form_with_failure | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'Version.count' do | |||
xhr :post, :create, :project_id => '1', :version => {:name => ''} | |||
xhr :post, :create, :params => {:project_id => '1', :version => {:name => ''}} | |||
end | |||
assert_response :success | |||
assert_template 'new' | |||
@@ -176,7 +176,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_get_edit | |||
@request.session[:user_id] = 2 | |||
get :edit, :id => 2 | |||
get :edit, :params => {:id => 2} | |||
assert_response :success | |||
assert_template 'edit' | |||
end | |||
@@ -184,7 +184,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_close_completed | |||
Version.update_all("status = 'open'") | |||
@request.session[:user_id] = 2 | |||
put :close_completed, :project_id => 'ecookbook' | |||
put :close_completed, :params => {:project_id => 'ecookbook'} | |||
assert_redirected_to :controller => 'projects', :action => 'settings', | |||
:tab => 'versions', :id => 'ecookbook' | |||
assert_not_nil Version.find_by_status('closed') | |||
@@ -192,9 +192,13 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_post_update | |||
@request.session[:user_id] = 2 | |||
put :update, :id => 2, | |||
:version => {:name => 'New version name', | |||
:effective_date => Date.today.strftime("%Y-%m-%d")} | |||
put :update, :params => { | |||
:id => 2, | |||
:version => { | |||
:name => 'New version name', | |||
:effective_date => Date.today.strftime("%Y-%m-%d") | |||
} | |||
} | |||
assert_redirected_to :controller => 'projects', :action => 'settings', | |||
:tab => 'versions', :id => 'ecookbook' | |||
version = Version.find(2) | |||
@@ -204,9 +208,13 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_post_update_with_validation_failure | |||
@request.session[:user_id] = 2 | |||
put :update, :id => 2, | |||
:version => { :name => '', | |||
:effective_date => Date.today.strftime("%Y-%m-%d")} | |||
put :update, :params => { | |||
:id => 2, | |||
:version => { | |||
:name => '', | |||
:effective_date => Date.today.strftime("%Y-%m-%d") | |||
} | |||
} | |||
assert_response :success | |||
assert_template 'edit' | |||
end | |||
@@ -214,7 +222,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_destroy | |||
@request.session[:user_id] = 2 | |||
assert_difference 'Version.count', -1 do | |||
delete :destroy, :id => 3 | |||
delete :destroy, :params => {:id => 3} | |||
end | |||
assert_redirected_to :controller => 'projects', :action => 'settings', | |||
:tab => 'versions', :id => 'ecookbook' | |||
@@ -224,7 +232,7 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
def test_destroy_version_in_use_should_fail | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'Version.count' do | |||
delete :destroy, :id => 2 | |||
delete :destroy, :params => {:id => 2} | |||
end | |||
assert_redirected_to :controller => 'projects', :action => 'settings', | |||
:tab => 'versions', :id => 'ecookbook' | |||
@@ -233,14 +241,14 @@ class VersionsControllerTest < Redmine::ControllerTest | |||
end | |||
def test_issue_status_by | |||
xhr :get, :status_by, :id => 2 | |||
xhr :get, :status_by, :params => {:id => 2} | |||
assert_response :success | |||
assert_template 'status_by' | |||
assert_template '_issue_counts' | |||
end | |||
def test_issue_status_by_status | |||
xhr :get, :status_by, :id => 2, :status_by => 'status' | |||
xhr :get, :status_by, :params => {:id => 2, :status_by => 'status'} | |||
assert_response :success | |||
assert_template 'status_by' | |||
assert_template '_issue_counts' |
@@ -28,7 +28,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_watch_a_single_object | |||
@request.session[:user_id] = 3 | |||
assert_difference('Watcher.count') do | |||
xhr :post, :watch, :object_type => 'issue', :object_id => '1' | |||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '1'} | |||
assert_response :success | |||
assert_include '$(".issue-1-watcher")', response.body | |||
end | |||
@@ -38,7 +38,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_watch_a_collection_with_a_single_object | |||
@request.session[:user_id] = 3 | |||
assert_difference('Watcher.count') do | |||
xhr :post, :watch, :object_type => 'issue', :object_id => ['1'] | |||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => ['1']} | |||
assert_response :success | |||
assert_include '$(".issue-1-watcher")', response.body | |||
end | |||
@@ -48,7 +48,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_watch_a_collection_with_multiple_objects | |||
@request.session[:user_id] = 3 | |||
assert_difference('Watcher.count', 2) do | |||
xhr :post, :watch, :object_type => 'issue', :object_id => ['1', '3'] | |||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => ['1', '3']} | |||
assert_response :success | |||
assert_include '$(".issue-bulk-watcher")', response.body | |||
end | |||
@@ -61,7 +61,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
assert_not_nil m = Project.find(1).enabled_module('news') | |||
assert_difference 'Watcher.count' do | |||
xhr :post, :watch, :object_type => 'enabled_module', :object_id => m.id.to_s | |||
xhr :post, :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s} | |||
assert_response :success | |||
end | |||
assert m.reload.watched_by?(User.find(7)) | |||
@@ -72,7 +72,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
assert_not_nil m = Project.find(2).enabled_module('news') | |||
assert_no_difference 'Watcher.count' do | |||
xhr :post, :watch, :object_type => 'enabled_module', :object_id => m.id.to_s | |||
xhr :post, :watch, :params => {:object_type => 'enabled_module', :object_id => m.id.to_s} | |||
assert_response 403 | |||
end | |||
end | |||
@@ -81,7 +81,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
Role.find(2).remove_permission! :view_issues | |||
@request.session[:user_id] = 3 | |||
assert_no_difference('Watcher.count') do | |||
xhr :post, :watch, :object_type => 'issue', :object_id => '1' | |||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '1'} | |||
assert_response 403 | |||
end | |||
end | |||
@@ -89,7 +89,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_watch_invalid_class_should_respond_with_404 | |||
@request.session[:user_id] = 3 | |||
assert_no_difference('Watcher.count') do | |||
xhr :post, :watch, :object_type => 'foo', :object_id => '1' | |||
xhr :post, :watch, :params => {:object_type => 'foo', :object_id => '1'} | |||
assert_response 404 | |||
end | |||
end | |||
@@ -97,7 +97,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_watch_invalid_object_should_respond_with_404 | |||
@request.session[:user_id] = 3 | |||
assert_no_difference('Watcher.count') do | |||
xhr :post, :watch, :object_type => 'issue', :object_id => '999' | |||
xhr :post, :watch, :params => {:object_type => 'issue', :object_id => '999'} | |||
assert_response 404 | |||
end | |||
end | |||
@@ -105,7 +105,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_unwatch | |||
@request.session[:user_id] = 3 | |||
assert_difference('Watcher.count', -1) do | |||
xhr :delete, :unwatch, :object_type => 'issue', :object_id => '2' | |||
xhr :delete, :unwatch, :params => {:object_type => 'issue', :object_id => '2'} | |||
assert_response :success | |||
assert_include '$(".issue-2-watcher")', response.body | |||
end | |||
@@ -118,7 +118,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
Watcher.create!(:user_id => 3, :watchable => Issue.find(3)) | |||
assert_difference('Watcher.count', -2) do | |||
xhr :delete, :unwatch, :object_type => 'issue', :object_id => ['1', '3'] | |||
xhr :delete, :unwatch, :params => {:object_type => 'issue', :object_id => ['1', '3']} | |||
assert_response :success | |||
assert_include '$(".issue-bulk-watcher")', response.body | |||
end | |||
@@ -128,21 +128,21 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_new | |||
@request.session[:user_id] = 2 | |||
xhr :get, :new, :object_type => 'issue', :object_id => '2' | |||
xhr :get, :new, :params => {:object_type => 'issue', :object_id => '2'} | |||
assert_response :success | |||
assert_match /ajax-modal/, response.body | |||
end | |||
def test_new_with_multiple_objects | |||
@request.session[:user_id] = 2 | |||
xhr :get, :new, :object_type => 'issue', :object_id => ['1', '2'] | |||
xhr :get, :new, :params => {:object_type => 'issue', :object_id => ['1', '2']} | |||
assert_response :success | |||
assert_match /ajax-modal/, response.body | |||
end | |||
def test_new_for_new_record_with_project_id | |||
@request.session[:user_id] = 2 | |||
xhr :get, :new, :project_id => 1 | |||
xhr :get, :new, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_equal Project.find(1), assigns(:project) | |||
assert_match /ajax-modal/, response.body | |||
@@ -150,7 +150,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_new_for_new_record_with_project_identifier | |||
@request.session[:user_id] = 2 | |||
xhr :get, :new, :project_id => 'ecookbook' | |||
xhr :get, :new, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_equal Project.find(1), assigns(:project) | |||
assert_match /ajax-modal/, response.body | |||
@@ -159,8 +159,10 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_create | |||
@request.session[:user_id] = 2 | |||
assert_difference('Watcher.count') do | |||
xhr :post, :create, :object_type => 'issue', :object_id => '2', | |||
:watcher => {:user_id => '4'} | |||
xhr :post, :create, :params => { | |||
:object_type => 'issue', :object_id => '2', | |||
:watcher => {:user_id => '4'} | |||
} | |||
assert_response :success | |||
assert_match /watchers/, response.body | |||
assert_match /ajax-modal/, response.body | |||
@@ -171,8 +173,10 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_create_with_mutiple_users | |||
@request.session[:user_id] = 2 | |||
assert_difference('Watcher.count', 2) do | |||
xhr :post, :create, :object_type => 'issue', :object_id => '2', | |||
:watcher => {:user_ids => ['4', '7']} | |||
xhr :post, :create, :params => { | |||
:object_type => 'issue', :object_id => '2', | |||
:watcher => {:user_ids => ['4', '7']} | |||
} | |||
assert_response :success | |||
assert_match /watchers/, response.body | |||
assert_match /ajax-modal/, response.body | |||
@@ -184,8 +188,10 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_create_with_mutiple_objects | |||
@request.session[:user_id] = 2 | |||
assert_difference('Watcher.count', 4) do | |||
xhr :post, :create, :object_type => 'issue', :object_id => ['1', '2'], | |||
:watcher => {:user_ids => ['4', '7']} | |||
xhr :post, :create, :params => { | |||
:object_type => 'issue', :object_id => ['1', '2'], | |||
:watcher => {:user_ids => ['4', '7']} | |||
} | |||
assert_response :success | |||
assert_match /watchers/, response.body | |||
assert_match /ajax-modal/, response.body | |||
@@ -198,7 +204,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_autocomplete_on_watchable_creation | |||
@request.session[:user_id] = 2 | |||
xhr :get, :autocomplete_for_user, :q => 'mi', :project_id => 'ecookbook' | |||
xhr :get, :autocomplete_for_user, :params => {:q => 'mi', :project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_select 'input', :count => 4 | |||
assert_select 'input[name=?][value="1"]', 'watcher[user_ids][]' | |||
@@ -213,15 +219,17 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
user = User.generate!(:firstname => 'issue15622') | |||
membership = user.membership(project) | |||
assert_nil membership | |||
xhr :get, :autocomplete_for_user, :q => 'issue15622', :project_id => 'ecookbook' | |||
xhr :get, :autocomplete_for_user, :params => {:q => 'issue15622', :project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_select 'input', :count => 1 | |||
end | |||
def test_autocomplete_on_watchable_update | |||
@request.session[:user_id] = 2 | |||
xhr :get, :autocomplete_for_user, :q => 'mi', :object_id => '2', | |||
:object_type => 'issue', :project_id => 'ecookbook' | |||
xhr :get, :autocomplete_for_user, :params => { | |||
:object_type => 'issue', :object_id => '2', | |||
:project_id => 'ecookbook', :q => 'mi' | |||
} | |||
assert_response :success | |||
assert_select 'input', :count => 3 | |||
assert_select 'input[name=?][value="2"]', 'watcher[user_ids][]' | |||
@@ -235,13 +243,19 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
user = User.generate!(:firstname => 'issue15622') | |||
membership = user.membership(project) | |||
assert_nil membership | |||
xhr :get, :autocomplete_for_user, :q => 'issue15622', :object_id => '2', | |||
:object_type => 'issue', :project_id => 'ecookbook' | |||
xhr :get, :autocomplete_for_user, :params => { | |||
:object_type => 'issue', :object_id => '2', | |||
:project_id => 'ecookbook', :q => 'issue15622' | |||
} | |||
assert_response :success | |||
assert_select 'input', :count => 1 | |||
assert_difference('Watcher.count', 1) do | |||
xhr :post, :create, :object_type => 'issue', :object_id => '2', | |||
:watcher => {:user_ids => ["#{user.id}"]} | |||
xhr :post, :create, :params => { | |||
:object_type => 'issue', :object_id => '2', | |||
:watcher => {:user_ids => ["#{user.id}"]} | |||
} | |||
assert_response :success | |||
assert_match /watchers/, response.body | |||
assert_match /ajax-modal/, response.body | |||
@@ -257,7 +271,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
User.add_to_project(visible, Project.find(1)) | |||
@request.session[:user_id] = 2 | |||
xhr :get, :autocomplete_for_user, :q => 'autocomp', :project_id => 'ecookbook' | |||
xhr :get, :autocomplete_for_user, :params => {:q => 'autocomp', :project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_include visible, assigns(:users) | |||
@@ -267,7 +281,9 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_append | |||
@request.session[:user_id] = 2 | |||
assert_no_difference 'Watcher.count' do | |||
xhr :post, :append, :watcher => {:user_ids => ['4', '7']}, :project_id => 'ecookbook' | |||
xhr :post, :append, :params => { | |||
:watcher => {:user_ids => ['4', '7']}, :project_id => 'ecookbook' | |||
} | |||
assert_response :success | |||
assert_include 'watchers_inputs', response.body | |||
assert_include 'issue[watcher_user_ids][]', response.body | |||
@@ -276,7 +292,7 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_append_without_user_should_render_nothing | |||
@request.session[:user_id] = 2 | |||
xhr :post, :append, :project_id => 'ecookbook' | |||
xhr :post, :append, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert response.body.blank? | |||
end | |||
@@ -284,7 +300,9 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_destroy | |||
@request.session[:user_id] = 2 | |||
assert_difference('Watcher.count', -1) do | |||
xhr :delete, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3' | |||
xhr :delete, :destroy, :params => { | |||
:object_type => 'issue', :object_id => '2', :user_id => '3' | |||
} | |||
assert_response :success | |||
assert_match /watchers/, response.body | |||
end | |||
@@ -298,7 +316,9 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
assert_difference('Watcher.count', -1) do | |||
xhr :delete, :destroy, :object_type => 'issue', :object_id => '2', :user_id => '3' | |||
xhr :delete, :destroy, :params => { | |||
:object_type => 'issue', :object_id => '2', :user_id => '3' | |||
} | |||
assert_response :success | |||
assert_match /watchers/, response.body | |||
end | |||
@@ -308,7 +328,9 @@ class WatchersControllerTest < Redmine::ControllerTest | |||
def test_destroy_invalid_user_should_respond_with_404 | |||
@request.session[:user_id] = 2 | |||
assert_no_difference('Watcher.count') do | |||
delete :destroy, :object_type => 'issue', :object_id => '2', :user_id => '999' | |||
delete :destroy, :params => { | |||
:object_type => 'issue', :object_id => '2', :user_id => '999' | |||
} | |||
assert_response 404 | |||
end | |||
end |
@@ -28,7 +28,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
end | |||
def test_show_start_page | |||
get :show, :project_id => 'ecookbook' | |||
get :show, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'show' | |||
assert_select 'h1', :text => /CookBook documentation/ | |||
@@ -40,13 +40,13 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_export_link | |||
Role.anonymous.add_permission! :export_wiki_pages | |||
get :show, :project_id => 'ecookbook' | |||
get :show, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation.txt' | |||
end | |||
def test_show_page_with_name | |||
get :show, :project_id => 1, :id => 'Another_page' | |||
get :show, :params => {:project_id => 1, :id => 'Another_page'} | |||
assert_response :success | |||
assert_template 'show' | |||
assert_select 'h1', :text => /Another page/ | |||
@@ -57,7 +57,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_old_version | |||
with_settings :default_language => 'en' do | |||
get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2' | |||
get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'} | |||
end | |||
assert_response :success | |||
assert_template 'show' | |||
@@ -75,7 +75,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
content.text = "update" | |||
content.save! | |||
get :show, :project_id => 'ecookbook', :id => page.title, :version => '1' | |||
get :show, :params => {:project_id => 'ecookbook', :id => page.title, :version => '1'} | |||
assert_kind_of WikiContent::Version, assigns(:content) | |||
assert_response :success | |||
assert_template 'show' | |||
@@ -84,13 +84,13 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_old_version_without_permission_should_be_denied | |||
Role.anonymous.remove_permission! :view_wiki_edits | |||
get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2' | |||
get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '2'} | |||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fprojects%2Fecookbook%2Fwiki%2FCookBook_documentation%2F2' | |||
end | |||
def test_show_first_version | |||
with_settings :default_language => 'en' do | |||
get :show, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1' | |||
get :show, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => '1'} | |||
end | |||
assert_response :success | |||
assert_template 'show' | |||
@@ -104,7 +104,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_redirected_page | |||
WikiRedirect.create!(:wiki_id => 1, :title => 'Old_title', :redirects_to => 'Another_page') | |||
get :show, :project_id => 'ecookbook', :id => 'Old_title' | |||
get :show, :params => {:project_id => 'ecookbook', :id => 'Old_title'} | |||
assert_redirected_to '/projects/ecookbook/wiki/Another_page' | |||
end | |||
@@ -113,14 +113,14 @@ class WikiControllerTest < Redmine::ControllerTest | |||
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') | |||
page.save! | |||
get :show, :project_id => 1, :id => 'Another_page' | |||
get :show, :params => {:project_id => 1, :id => 'Another_page'} | |||
assert_response :success | |||
assert_select 'div#sidebar', :text => /Side bar content for test_show_with_sidebar/ | |||
end | |||
def test_show_should_display_section_edit_links | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :id => 'Page with sections' | |||
get :show, :params => {:project_id => 1, :id => 'Page with sections'} | |||
assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=1', 0 | |||
assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' | |||
@@ -129,38 +129,38 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_current_version_should_display_section_edit_links | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :id => 'Page with sections', :version => 3 | |||
get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 3} | |||
assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' | |||
end | |||
def test_show_old_version_should_not_display_section_edit_links | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :id => 'Page with sections', :version => 2 | |||
get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 2} | |||
assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2', 0 | |||
end | |||
def test_show_unexistent_page_without_edit_right | |||
get :show, :project_id => 1, :id => 'Unexistent page' | |||
get :show, :params => {:project_id => 1, :id => 'Unexistent page'} | |||
assert_response 404 | |||
end | |||
def test_show_unexistent_page_with_edit_right | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :id => 'Unexistent page' | |||
get :show, :params => {:project_id => 1, :id => 'Unexistent page'} | |||
assert_response :success | |||
assert_template 'edit' | |||
end | |||
def test_show_specific_version_of_an_unexistent_page_without_edit_right | |||
get :show, :project_id => 1, :id => 'Unexistent page', :version => 1 | |||
get :show, :params => {:project_id => 1, :id => 'Unexistent page', :version => 1} | |||
assert_response 404 | |||
end | |||
def test_show_unexistent_page_with_parent_should_preselect_parent | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :id => 'Unexistent page', :parent => 'Another_page' | |||
get :show, :params => {:project_id => 1, :id => 'Unexistent page', :parent => 'Another_page'} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]' | |||
@@ -168,7 +168,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_should_not_show_history_without_permission | |||
Role.anonymous.remove_permission! :view_wiki_edits | |||
get :show, :project_id => 1, :id => 'Page with sections', :version => 2 | |||
get :show, :params => {:project_id => 1, :id => 'Page with sections', :version => 2} | |||
assert_response 302 | |||
end | |||
@@ -177,7 +177,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
WikiPage.create!(:title => 'NoContent', :wiki => Project.find(1).wiki) | |||
get :show, :project_id => 1, :id => 'NoContent' | |||
get :show, :params => {:project_id => 1, :id => 'NoContent'} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_select 'textarea[name=?]', 'content[text]' | |||
@@ -186,7 +186,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_get_new | |||
@request.session[:user_id] = 2 | |||
get :new, :project_id => 'ecookbook' | |||
get :new, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'new' | |||
end | |||
@@ -194,7 +194,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_get_new_xhr | |||
@request.session[:user_id] = 2 | |||
xhr :get, :new, :project_id => 'ecookbook' | |||
xhr :get, :new, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'new' | |||
end | |||
@@ -202,14 +202,14 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_post_new_with_valid_title_should_redirect_to_edit | |||
@request.session[:user_id] = 2 | |||
post :new, :project_id => 'ecookbook', :title => 'New Page' | |||
post :new, :params => {:project_id => 'ecookbook', :title => 'New Page'} | |||
assert_redirected_to '/projects/ecookbook/wiki/New_Page' | |||
end | |||
def test_post_new_xhr_with_valid_title_should_redirect_to_edit | |||
@request.session[:user_id] = 2 | |||
xhr :post, :new, :project_id => 'ecookbook', :title => 'New Page' | |||
xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'New Page'} | |||
assert_response :success | |||
assert_equal 'window.location = "/projects/ecookbook/wiki/New_Page"', response.body | |||
end | |||
@@ -217,7 +217,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_post_new_with_invalid_title_should_display_errors | |||
@request.session[:user_id] = 2 | |||
post :new, :project_id => 'ecookbook', :title => 'Another page' | |||
post :new, :params => {:project_id => 'ecookbook', :title => 'Another page'} | |||
assert_response :success | |||
assert_template 'new' | |||
assert_select_error 'Title has already been taken' | |||
@@ -226,7 +226,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_post_new_xhr_with_invalid_title_should_display_errors | |||
@request.session[:user_id] = 2 | |||
xhr :post, :new, :project_id => 'ecookbook', :title => 'Another page' | |||
xhr :post, :new, :params => {:project_id => 'ecookbook', :title => 'Another page'} | |||
assert_response :success | |||
assert_template 'new' | |||
assert_include 'Title has already been taken', response.body | |||
@@ -236,11 +236,15 @@ class WikiControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
assert_difference 'WikiPage.count' do | |||
assert_difference 'WikiContent.count' do | |||
put :update, :project_id => 1, | |||
:id => 'New page', | |||
:content => {:comments => 'Created the page', | |||
:text => "h1. New page\n\nThis is a new page", | |||
:version => 0} | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'New page', | |||
:content => { | |||
:comments => 'Created the page', | |||
:text => "h1. New page\n\nThis is a new page", | |||
:version => 0 | |||
} | |||
} | |||
end | |||
end | |||
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'New_page' | |||
@@ -255,12 +259,16 @@ class WikiControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 2 | |||
assert_difference 'WikiPage.count' do | |||
assert_difference 'Attachment.count' do | |||
put :update, :project_id => 1, | |||
:id => 'New page', | |||
:content => {:comments => 'Created the page', | |||
:text => "h1. New page\n\nThis is a new page", | |||
:version => 0}, | |||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'New page', | |||
:content => { | |||
:comments => 'Created the page', | |||
:text => "h1. New page\n\nThis is a new page", | |||
:version => 0 | |||
}, | |||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |||
} | |||
end | |||
end | |||
page = Project.find(1).wiki.find_page('New page') | |||
@@ -271,9 +279,15 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_create_page_with_parent | |||
@request.session[:user_id] = 2 | |||
assert_difference 'WikiPage.count' do | |||
put :update, :project_id => 1, :id => 'New page', | |||
:content => {:text => "h1. New page\n\nThis is a new page", :version => 0}, | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'New page', | |||
:content => { | |||
:text => "h1. New page\n\nThis is a new page", | |||
:version => 0 | |||
}, | |||
:wiki_page => {:parent_id => 2} | |||
} | |||
end | |||
page = Project.find(1).wiki.find_page('New page') | |||
assert_equal WikiPage.find(2), page.parent | |||
@@ -281,7 +295,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_edit_page | |||
@request.session[:user_id] = 2 | |||
get :edit, :project_id => 'ecookbook', :id => 'Another_page' | |||
get :edit, :params => {:project_id => 'ecookbook', :id => 'Another_page'} | |||
assert_response :success | |||
assert_template 'edit' | |||
@@ -292,7 +306,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_edit_section | |||
@request.session[:user_id] = 2 | |||
get :edit, :project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2 | |||
get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 2} | |||
assert_response :success | |||
assert_template 'edit' | |||
@@ -307,7 +321,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_edit_invalid_section_should_respond_with_404 | |||
@request.session[:user_id] = 2 | |||
get :edit, :project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10 | |||
get :edit, :params => {:project_id => 'ecookbook', :id => 'Page_with_sections', :section => 10} | |||
assert_response 404 | |||
end | |||
@@ -317,13 +331,15 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:content => { | |||
:comments => "my comments", | |||
:text => "edited", | |||
:version => 1 | |||
} | |||
} | |||
end | |||
end | |||
end | |||
@@ -340,7 +356,8 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:content => { | |||
:comments => "my comments", | |||
@@ -348,6 +365,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:version => 1 | |||
}, | |||
:wiki_page => {:parent_id => '1'} | |||
} | |||
end | |||
end | |||
end | |||
@@ -365,7 +383,8 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_no_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:content => { | |||
:comments => 'a' * 1300, # failure here, comment is too long | |||
@@ -374,6 +393,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:wiki_page => { | |||
:parent_id => "" | |||
} | |||
} | |||
end | |||
end | |||
end | |||
@@ -390,7 +410,8 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_no_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:content => { | |||
:comments => '', | |||
@@ -398,6 +419,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:version => 1 | |||
}, | |||
:wiki_page => {:parent_id => '1'} | |||
} | |||
end | |||
end | |||
end | |||
@@ -412,7 +434,8 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiContent.count' do | |||
assert_no_difference 'WikiContent::Version.count' do | |||
assert_difference 'Attachment.count' do | |||
put :update, :project_id => 1, | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:content => { | |||
:comments => '', | |||
@@ -420,6 +443,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
:version => 1 | |||
}, | |||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} | |||
} | |||
end | |||
end | |||
end | |||
@@ -438,13 +462,15 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_no_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:content => { | |||
:comments => 'My comments', | |||
:text => 'Text should not be lost', | |||
:version => 1 | |||
} | |||
} | |||
end | |||
end | |||
end | |||
@@ -465,7 +491,11 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_difference 'WikiContent.count' do | |||
put :update, :project_id => 1, :id => 'NoContent', :content => {:text => 'Some content'} | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'NoContent', | |||
:content => {:text => 'Some content'} | |||
} | |||
assert_response 302 | |||
end | |||
end | |||
@@ -481,13 +511,16 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, :id => 'Page_with_sections', | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Page_with_sections', | |||
:content => { | |||
:text => "New section content", | |||
:version => 3 | |||
}, | |||
:section => 2, | |||
:section_hash => hash | |||
} | |||
end | |||
end | |||
end | |||
@@ -504,13 +537,16 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, :id => 'Page_with_sections', | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Page_with_sections', | |||
:content => { | |||
:text => "New section content", | |||
:version => 2 # Current version is 3 | |||
}, | |||
:section => 2, | |||
:section_hash => hash | |||
} | |||
end | |||
end | |||
end | |||
@@ -526,7 +562,9 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiPage.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_no_difference 'WikiContent::Version.count' do | |||
put :update, :project_id => 1, :id => 'Page_with_sections', | |||
put :update, :params => { | |||
:project_id => 1, | |||
:id => 'Page_with_sections', | |||
:content => { | |||
:comments => 'My comments', | |||
:text => "Text should not be lost", | |||
@@ -534,6 +572,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
}, | |||
:section => 2, | |||
:section_hash => Digest::MD5.hexdigest("wrong hash") | |||
} | |||
end | |||
end | |||
end | |||
@@ -546,10 +585,15 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_preview | |||
@request.session[:user_id] = 2 | |||
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation', | |||
:content => { :comments => '', | |||
:text => 'this is a *previewed text*', | |||
:version => 3 } | |||
xhr :post, :preview, :params => { | |||
:project_id => 1, | |||
:id => 'CookBook_documentation', | |||
:content => { | |||
:comments => '', | |||
:text => 'this is a *previewed text*', | |||
:version => 3 | |||
} | |||
} | |||
assert_response :success | |||
assert_template 'common/_preview' | |||
assert_select 'strong', :text => /previewed text/ | |||
@@ -557,10 +601,15 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_preview_new_page | |||
@request.session[:user_id] = 2 | |||
xhr :post, :preview, :project_id => 1, :id => 'New page', | |||
:content => { :text => 'h1. New page', | |||
:comments => '', | |||
:version => 0 } | |||
xhr :post, :preview, :params => { | |||
:project_id => 1, | |||
:id => 'New page', | |||
:content => { | |||
:text => 'h1. New page', | |||
:comments => '', | |||
:version => 0 | |||
} | |||
} | |||
assert_response :success | |||
assert_template 'common/_preview' | |||
assert_select 'h1', :text => /New page/ | |||
@@ -568,7 +617,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_history | |||
@request.session[:user_id] = 2 | |||
get :history, :project_id => 'ecookbook', :id => 'CookBook_documentation' | |||
get :history, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation'} | |||
assert_response :success | |||
assert_template 'history' | |||
assert_not_nil assigns(:versions) | |||
@@ -584,7 +633,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_history_with_one_version | |||
@request.session[:user_id] = 2 | |||
get :history, :project_id => 'ecookbook', :id => 'Another_page' | |||
get :history, :params => {:project_id => 'ecookbook', :id => 'Another_page'} | |||
assert_response :success | |||
assert_template 'history' | |||
assert_not_nil assigns(:versions) | |||
@@ -606,7 +655,11 @@ class WikiControllerTest < Redmine::ControllerTest | |||
content.save! | |||
end | |||
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => content.version, :version_from => (content.version - 1) | |||
get :diff, :params => { | |||
:project_id => 1, :id => 'CookBook_documentation', | |||
:version => content.version, | |||
:version_from => (content.version - 1) | |||
} | |||
assert_response :success | |||
assert_template 'diff' | |||
assert_select 'span.diff_out', :text => 'Line removed' | |||
@@ -614,17 +667,27 @@ class WikiControllerTest < Redmine::ControllerTest | |||
end | |||
def test_diff_with_invalid_version_should_respond_with_404 | |||
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => '99' | |||
get :diff, :params => { | |||
:project_id => 1, :id => 'CookBook_documentation', | |||
:version => '99' | |||
} | |||
assert_response 404 | |||
end | |||
def test_diff_with_invalid_version_from_should_respond_with_404 | |||
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => '99', :version_from => '98' | |||
get :diff, :params => { | |||
:project_id => 1, :id => 'CookBook_documentation', | |||
:version => '99', | |||
:version_from => '98' | |||
} | |||
assert_response 404 | |||
end | |||
def test_annotate | |||
get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2 | |||
get :annotate, :params => { | |||
:project_id => 1, :id => 'CookBook_documentation', | |||
:version => 2 | |||
} | |||
assert_response :success | |||
assert_template 'annotate' | |||
@@ -644,13 +707,16 @@ class WikiControllerTest < Redmine::ControllerTest | |||
end | |||
def test_annotate_with_invalid_version_should_respond_with_404 | |||
get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => '99' | |||
get :annotate, :params => { | |||
:project_id => 1, :id => 'CookBook_documentation', | |||
:version => '99' | |||
} | |||
assert_response 404 | |||
end | |||
def test_get_rename | |||
@request.session[:user_id] = 2 | |||
get :rename, :project_id => 1, :id => 'Another_page' | |||
get :rename, :params => {:project_id => 1, :id => 'Another_page'} | |||
assert_response :success | |||
assert_template 'rename' | |||
@@ -662,7 +728,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_get_rename_child_page | |||
@request.session[:user_id] = 2 | |||
get :rename, :project_id => 1, :id => 'Child_1' | |||
get :rename, :params => {:project_id => 1, :id => 'Child_1'} | |||
assert_response :success | |||
assert_template 'rename' | |||
@@ -674,9 +740,14 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_rename_with_redirect | |||
@request.session[:user_id] = 2 | |||
post :rename, :project_id => 1, :id => 'Another_page', | |||
:wiki_page => { :title => 'Another renamed page', | |||
:redirect_existing_links => 1 } | |||
post :rename, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:wiki_page => { | |||
:title => 'Another renamed page', | |||
:redirect_existing_links => 1 | |||
} | |||
} | |||
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' | |||
wiki = Project.find(1).wiki | |||
# Check redirects | |||
@@ -686,9 +757,14 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_rename_without_redirect | |||
@request.session[:user_id] = 2 | |||
post :rename, :project_id => 1, :id => 'Another_page', | |||
:wiki_page => { :title => 'Another renamed page', | |||
:redirect_existing_links => "0" } | |||
post :rename, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:wiki_page => { | |||
:title => 'Another renamed page', | |||
:redirect_existing_links => "0" | |||
} | |||
} | |||
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page' | |||
wiki = Project.find(1).wiki | |||
# Check that there's no redirects | |||
@@ -697,16 +773,30 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_rename_with_parent_assignment | |||
@request.session[:user_id] = 2 | |||
post :rename, :project_id => 1, :id => 'Another_page', | |||
:wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' } | |||
post :rename, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:wiki_page => { | |||
:title => 'Another page', | |||
:redirect_existing_links => "0", | |||
:parent_id => '4' | |||
} | |||
} | |||
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' | |||
assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent | |||
end | |||
def test_rename_with_parent_unassignment | |||
@request.session[:user_id] = 2 | |||
post :rename, :project_id => 1, :id => 'Child_1', | |||
:wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' } | |||
post :rename, :params => { | |||
:project_id => 1, | |||
:id => 'Child_1', | |||
:wiki_page => { | |||
:title => 'Child 1', | |||
:redirect_existing_links => "0", | |||
:parent_id => '' | |||
} | |||
} | |||
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1' | |||
assert_nil WikiPage.find_by_title('Child_1').parent | |||
end | |||
@@ -716,7 +806,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
project = Project.find(5) | |||
project.enable_module! :wiki | |||
get :rename, :project_id => 1, :id => 'Another_page' | |||
get :rename, :params => {:project_id => 1, :id => 'Another_page'} | |||
assert_response :success | |||
assert_template 'rename' | |||
@@ -732,12 +822,15 @@ class WikiControllerTest < Redmine::ControllerTest | |||
project = Project.find(5) | |||
project.enable_module! :wiki | |||
post :rename, :project_id => 1, :id => 'Another_page', | |||
post :rename, :params => { | |||
:project_id => 1, | |||
:id => 'Another_page', | |||
:wiki_page => { | |||
:wiki_id => project.wiki.id.to_s, | |||
:title => 'Another renamed page', | |||
:redirect_existing_links => 1 | |||
} | |||
} | |||
assert_redirected_to '/projects/private-child/wiki/Another_renamed_page' | |||
page = WikiPage.find(2) | |||
@@ -746,14 +839,14 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_destroy_a_page_without_children_should_not_ask_confirmation | |||
@request.session[:user_id] = 2 | |||
delete :destroy, :project_id => 1, :id => 'Child_2' | |||
delete :destroy, :params => {:project_id => 1, :id => 'Child_2'} | |||
assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |||
end | |||
def test_destroy_parent_should_ask_confirmation | |||
@request.session[:user_id] = 2 | |||
assert_no_difference('WikiPage.count') do | |||
delete :destroy, :project_id => 1, :id => 'Another_page' | |||
delete :destroy, :params => {:project_id => 1, :id => 'Another_page'} | |||
end | |||
assert_response :success | |||
assert_template 'destroy' | |||
@@ -767,7 +860,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_destroy_parent_with_nullify_should_delete_parent_only | |||
@request.session[:user_id] = 2 | |||
assert_difference('WikiPage.count', -1) do | |||
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'nullify' | |||
delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'nullify'} | |||
end | |||
assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |||
assert_nil WikiPage.find_by_id(2) | |||
@@ -776,7 +869,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_destroy_parent_with_cascade_should_delete_descendants | |||
@request.session[:user_id] = 2 | |||
assert_difference('WikiPage.count', -4) do | |||
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'destroy' | |||
delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'destroy'} | |||
end | |||
assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |||
assert_nil WikiPage.find_by_id(2) | |||
@@ -786,7 +879,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_destroy_parent_with_reassign | |||
@request.session[:user_id] = 2 | |||
assert_difference('WikiPage.count', -1) do | |||
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1 | |||
delete :destroy, :params => {:project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1} | |||
end | |||
assert_redirected_to :action => 'index', :project_id => 'ecookbook' | |||
assert_nil WikiPage.find_by_id(2) | |||
@@ -798,7 +891,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_difference 'WikiContent::Version.count', -1 do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_no_difference 'WikiPage.count' do | |||
delete :destroy_version, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 2 | |||
delete :destroy_version, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 2} | |||
assert_redirected_to '/projects/ecookbook/wiki/CookBook_documentation/history' | |||
end | |||
end | |||
@@ -810,7 +903,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
assert_no_difference 'WikiContent::Version.count' do | |||
assert_no_difference 'WikiContent.count' do | |||
assert_no_difference 'WikiPage.count' do | |||
delete :destroy_version, :project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 99 | |||
delete :destroy_version, :params => {:project_id => 'ecookbook', :id => 'CookBook_documentation', :version => 99} | |||
end | |||
end | |||
end | |||
@@ -818,7 +911,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index | |||
get :index, :project_id => 'ecookbook' | |||
get :index, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'index' | |||
pages = assigns(:pages) | |||
@@ -836,13 +929,13 @@ class WikiControllerTest < Redmine::ControllerTest | |||
end | |||
def test_index_should_include_atom_link | |||
get :index, :project_id => 'ecookbook' | |||
get :index, :params => {:project_id => 'ecookbook'} | |||
assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1' | |||
end | |||
def test_export_to_html | |||
@request.session[:user_id] = 2 | |||
get :export, :project_id => 'ecookbook' | |||
get :export, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_not_nil assigns(:pages) | |||
@@ -856,7 +949,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_export_to_pdf | |||
@request.session[:user_id] = 2 | |||
get :export, :project_id => 'ecookbook', :format => 'pdf' | |||
get :export, :params => {:project_id => 'ecookbook', :format => 'pdf'} | |||
assert_response :success | |||
assert_not_nil assigns(:pages) | |||
@@ -869,13 +962,13 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_export_without_permission_should_be_denied | |||
@request.session[:user_id] = 2 | |||
Role.find_by_name('Manager').remove_permission! :export_wiki_pages | |||
get :export, :project_id => 'ecookbook' | |||
get :export, :params => {:project_id => 'ecookbook'} | |||
assert_response 403 | |||
end | |||
def test_date_index | |||
get :date_index, :project_id => 'ecookbook' | |||
get :date_index, :params => {:project_id => 'ecookbook'} | |||
assert_response :success | |||
assert_template 'date_index' | |||
@@ -886,7 +979,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
end | |||
def test_not_found | |||
get :show, :project_id => 999 | |||
get :show, :params => {:project_id => 999} | |||
assert_response 404 | |||
end | |||
@@ -894,7 +987,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') | |||
assert !page.protected? | |||
@request.session[:user_id] = 2 | |||
post :protect, :project_id => 1, :id => page.title, :protected => '1' | |||
post :protect, :params => {:project_id => 1, :id => page.title, :protected => '1'} | |||
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page' | |||
assert page.reload.protected? | |||
end | |||
@@ -903,14 +996,14 @@ class WikiControllerTest < Redmine::ControllerTest | |||
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') | |||
assert page.protected? | |||
@request.session[:user_id] = 2 | |||
post :protect, :project_id => 1, :id => page.title, :protected => '0' | |||
post :protect, :params => {:project_id => 1, :id => page.title, :protected => '0'} | |||
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation' | |||
assert !page.reload.protected? | |||
end | |||
def test_show_page_with_edit_link | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1 | |||
get :show, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_template 'show' | |||
assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit' | |||
@@ -918,7 +1011,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_page_without_edit_link | |||
@request.session[:user_id] = 4 | |||
get :show, :project_id => 1 | |||
get :show, :params => {:project_id => 1} | |||
assert_response :success | |||
assert_template 'show' | |||
assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit', 0 | |||
@@ -926,7 +1019,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_pdf | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :format => 'pdf' | |||
get :show, :params => {:project_id => 1, :format => 'pdf'} | |||
assert_response :success | |||
assert_not_nil assigns(:page) | |||
assert_equal 'application/pdf', @response.content_type | |||
@@ -936,7 +1029,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_html | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :format => 'html' | |||
get :show, :params => {:project_id => 1, :format => 'html'} | |||
assert_response :success | |||
assert_not_nil assigns(:page) | |||
assert_equal 'text/html', @response.content_type | |||
@@ -947,7 +1040,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_versioned_html | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :format => 'html', :version => 2 | |||
get :show, :params => {:project_id => 1, :format => 'html', :version => 2} | |||
assert_response :success | |||
assert_not_nil assigns(:content) | |||
assert_equal 2, assigns(:content).version | |||
@@ -959,7 +1052,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_txt | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :format => 'txt' | |||
get :show, :params => {:project_id => 1, :format => 'txt'} | |||
assert_response :success | |||
assert_not_nil assigns(:page) | |||
assert_equal 'text/plain', @response.content_type | |||
@@ -970,7 +1063,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_show_versioned_txt | |||
@request.session[:user_id] = 2 | |||
get :show, :project_id => 1, :format => 'txt', :version => 2 | |||
get :show, :params => {:project_id => 1, :format => 'txt', :version => 2} | |||
assert_response :success | |||
assert_not_nil assigns(:content) | |||
assert_equal 2, assigns(:content).version | |||
@@ -983,7 +1076,7 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_edit_unprotected_page | |||
# Non members can edit unprotected wiki pages | |||
@request.session[:user_id] = 4 | |||
get :edit, :project_id => 1, :id => 'Another_page' | |||
get :edit, :params => {:project_id => 1, :id => 'Another_page'} | |||
assert_response :success | |||
assert_template 'edit' | |||
end | |||
@@ -991,30 +1084,32 @@ class WikiControllerTest < Redmine::ControllerTest | |||
def test_edit_protected_page_by_nonmember | |||
# Non members cannot edit protected wiki pages | |||
@request.session[:user_id] = 4 | |||
get :edit, :project_id => 1, :id => 'CookBook_documentation' | |||
get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'} | |||
assert_response 403 | |||
end | |||
def test_edit_protected_page_by_member | |||
@request.session[:user_id] = 2 | |||
get :edit, :project_id => 1, :id => 'CookBook_documentation' | |||
get :edit, :params => {:project_id => 1, :id => 'CookBook_documentation'} | |||
assert_response :success | |||
assert_template 'edit' | |||
end | |||
def test_history_of_non_existing_page_should_return_404 | |||
get :history, :project_id => 1, :id => 'Unknown_page' | |||
get :history, :params => {:project_id => 1, :id => 'Unknown_page'} | |||
assert_response 404 | |||
end | |||
def test_add_attachment | |||
@request.session[:user_id] = 2 | |||
assert_difference 'Attachment.count' do | |||
post :add_attachment, :project_id => 1, :id => 'CookBook_documentation', | |||
:attachments => { | |||
'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), | |||
'description' => 'test file'} | |||
} | |||
post :add_attachment, :params => { | |||
:project_id => 1, | |||
:id => 'CookBook_documentation', | |||
:attachments => { | |||
'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'} | |||
} | |||
} | |||
end | |||
attachment = Attachment.order('id DESC').first | |||
assert_equal Wiki.find(1).find_page('CookBook_documentation'), attachment.container |
@@ -29,7 +29,7 @@ class WikisControllerTest < Redmine::ControllerTest | |||
assert_nil Project.find(3).wiki | |||
assert_difference 'Wiki.count' do | |||
xhr :post, :edit, :id => 3, :wiki => { :start_page => 'Start page' } | |||
xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => 'Start page' }} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_equal 'text/javascript', response.content_type | |||
@@ -44,7 +44,7 @@ class WikisControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 1 | |||
assert_no_difference 'Wiki.count' do | |||
xhr :post, :edit, :id => 3, :wiki => { :start_page => '' } | |||
xhr :post, :edit, :params => {:id => 3, :wiki => { :start_page => '' }} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_equal 'text/javascript', response.content_type | |||
@@ -58,7 +58,7 @@ class WikisControllerTest < Redmine::ControllerTest | |||
@request.session[:user_id] = 1 | |||
assert_no_difference 'Wiki.count' do | |||
xhr :post, :edit, :id => 1, :wiki => { :start_page => 'Other start page' } | |||
xhr :post, :edit, :params => {:id => 1, :wiki => { :start_page => 'Other start page' }} | |||
assert_response :success | |||
assert_template 'edit' | |||
assert_equal 'text/javascript', response.content_type | |||
@@ -70,7 +70,7 @@ class WikisControllerTest < Redmine::ControllerTest | |||
def test_destroy | |||
@request.session[:user_id] = 1 | |||
post :destroy, :id => 1, :confirm => 1 | |||
post :destroy, :params => {:id => 1, :confirm => 1} | |||
assert_redirected_to :controller => 'projects', | |||
:action => 'settings', :id => 'ecookbook', :tab => 'wiki' | |||
assert_nil Project.find(1).wiki | |||
@@ -78,7 +78,7 @@ class WikisControllerTest < Redmine::ControllerTest | |||
def test_not_found | |||
@request.session[:user_id] = 1 | |||
post :destroy, :id => 999, :confirm => 1 | |||
post :destroy, :params => {:id => 999, :confirm => 1} | |||
assert_response 404 | |||
end | |||
end |
@@ -45,7 +45,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3) | |||
WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5) | |||
get :edit, :role_id => 2, :tracker_id => 1 | |||
get :edit, :params => {:role_id => 2, :tracker_id => 1} | |||
assert_response :success | |||
assert_template 'edit' | |||
@@ -65,14 +65,14 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
WorkflowTransition.delete_all | |||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1) | |||
get :edit, :role_id => 1, :tracker_id => 1 | |||
get :edit, :params => {:role_id => 1, :tracker_id => 1} | |||
assert_response :success | |||
assert_select 'td', 'New issue' | |||
assert_select 'input[type=checkbox][name=?][value="1"][checked=checked]', 'transitions[0][1][always]' | |||
end | |||
def test_get_edit_with_all_roles_and_all_trackers | |||
get :edit, :role_id => 'all', :tracker_id => 'all' | |||
get :edit, :params => {:role_id => 'all', :tracker_id => 'all'} | |||
assert_response :success | |||
assert_equal Role.sorted.to_a, assigns(:roles) | |||
assert_equal Tracker.sorted.to_a, assigns(:trackers) | |||
@@ -81,7 +81,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_get_edit_with_role_and_tracker_and_all_statuses | |||
WorkflowTransition.delete_all | |||
get :edit, :role_id => 2, :tracker_id => 1, :used_statuses_only => '0' | |||
get :edit, :params => {:role_id => 2, :tracker_id => 1, :used_statuses_only => '0'} | |||
assert_response :success | |||
assert_template 'edit' | |||
@@ -94,11 +94,14 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_edit | |||
WorkflowTransition.delete_all | |||
post :edit, :role_id => 2, :tracker_id => 1, | |||
post :edit, :params => { | |||
:role_id => 2, | |||
:tracker_id => 1, | |||
:transitions => { | |||
'4' => {'5' => {'always' => '1'}}, | |||
'3' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} | |||
} | |||
} | |||
assert_response 302 | |||
assert_equal 3, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count | |||
@@ -109,10 +112,13 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_edit_with_allowed_statuses_for_new_issues | |||
WorkflowTransition.delete_all | |||
post :edit, :role_id => 2, :tracker_id => 1, | |||
post :edit, :params => { | |||
:role_id => 2, | |||
:tracker_id => 1, | |||
:transitions => { | |||
'0' => {'1' => {'always' => '1'}, '2' => {'always' => '1'}} | |||
} | |||
} | |||
assert_response 302 | |||
assert WorkflowTransition.where(:role_id => 2, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1).any? | |||
@@ -123,13 +129,16 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_edit_with_additional_transitions | |||
WorkflowTransition.delete_all | |||
post :edit, :role_id => 2, :tracker_id => 1, | |||
post :edit, :params => { | |||
:role_id => 2, | |||
:tracker_id => 1, | |||
:transitions => { | |||
'4' => {'5' => {'always' => '1', 'author' => '0', 'assignee' => '0'}}, | |||
'3' => {'1' => {'always' => '0', 'author' => '1', 'assignee' => '0'}, | |||
'2' => {'always' => '0', 'author' => '0', 'assignee' => '1'}, | |||
'4' => {'always' => '0', 'author' => '1', 'assignee' => '1'}} | |||
} | |||
} | |||
assert_response 302 | |||
assert_equal 4, WorkflowTransition.where(:tracker_id => 1, :role_id => 2).count | |||
@@ -161,7 +170,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :field_name => 'fixed_version_id', :rule => 'required') | |||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 3, :field_name => 'fixed_version_id', :rule => 'readonly') | |||
get :permissions, :role_id => 1, :tracker_id => 2 | |||
get :permissions, :params => {:role_id => 1, :tracker_id => 2} | |||
assert_response :success | |||
assert_template 'permissions' | |||
@@ -202,7 +211,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_get_permissions_with_required_custom_field_should_not_show_required_option | |||
cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [1], :is_required => true) | |||
get :permissions, :role_id => 1, :tracker_id => 1 | |||
get :permissions, :params => {:role_id => 1, :tracker_id => 1} | |||
assert_response :success | |||
assert_template 'permissions' | |||
@@ -220,7 +229,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
cf2 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1]) | |||
cf3 = IssueCustomField.generate!(:tracker_ids => [1], :visible => false, :role_ids => [1, 2]) | |||
get :permissions, :role_id => 2, :tracker_id => 1 | |||
get :permissions, :params => {:role_id => 2, :tracker_id => 1} | |||
assert_response :success | |||
assert_template 'permissions' | |||
@@ -236,7 +245,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
WorkflowPermission.delete_all | |||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |||
get :permissions, :role_id => [1, 2], :tracker_id => 2 | |||
get :permissions, :params => {:role_id => [1, 2], :tracker_id => 2} | |||
assert_response :success | |||
assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do | |||
@@ -250,7 +259,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |||
WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'readonly') | |||
get :permissions, :role_id => [1, 2], :tracker_id => 2 | |||
get :permissions, :params => {:role_id => [1, 2], :tracker_id => 2} | |||
assert_response :success | |||
assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do | |||
@@ -264,7 +273,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |||
WorkflowPermission.create!(:role_id => 2, :tracker_id => 2, :old_status_id => 1, :field_name => 'assigned_to_id', :rule => 'required') | |||
get :permissions, :role_id => [1, 2], :tracker_id => 2 | |||
get :permissions, :params => {:role_id => [1, 2], :tracker_id => 2} | |||
assert_response :success | |||
assert_select 'select[name=?]', 'permissions[1][assigned_to_id]' do | |||
@@ -276,7 +285,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_get_permissions_with_role_and_tracker_and_all_statuses_should_show_all_statuses | |||
WorkflowTransition.delete_all | |||
get :permissions, :role_id => 1, :tracker_id => 2, :used_statuses_only => '0' | |||
get :permissions, :params => {:role_id => 1, :tracker_id => 2, :used_statuses_only => '0'} | |||
assert_response :success | |||
assert_equal IssueStatus.sorted.to_a, assigns(:statuses) | |||
end | |||
@@ -287,7 +296,7 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [2]) | |||
WorkflowPermission.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 1, :field_name => cf.id, :rule => 'required') | |||
get :permissions, :role_id => 1, :tracker_id => 2 | |||
get :permissions, :params => {:role_id => 1, :tracker_id => 2} | |||
assert_response :success | |||
assert_select 'td.required > select[name=?]', 'permissions[1][assigned_to_id]' | |||
assert_select 'td.required > select[name=?]', "permissions[1][#{cf.id}]" | |||
@@ -296,10 +305,14 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_permissions | |||
WorkflowPermission.delete_all | |||
post :permissions, :role_id => 1, :tracker_id => 2, :permissions => { | |||
'1' => {'assigned_to_id' => '', 'fixed_version_id' => 'required', 'due_date' => ''}, | |||
'2' => {'assigned_to_id' => 'readonly', 'fixed_version_id' => 'readonly', 'due_date' => ''}, | |||
'3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''} | |||
post :permissions, :params => { | |||
:role_id => 1, | |||
:tracker_id => 2, | |||
:permissions => { | |||
'1' => {'assigned_to_id' => '', 'fixed_version_id' => 'required', 'due_date' => ''}, | |||
'2' => {'assigned_to_id' => 'readonly', 'fixed_version_id' => 'readonly', 'due_date' => ''}, | |||
'3' => {'assigned_to_id' => '', 'fixed_version_id' => '', 'due_date' => ''} | |||
} | |||
} | |||
assert_response 302 | |||
@@ -335,8 +348,10 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_copy_one_to_one | |||
source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) | |||
post :copy, :source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['3'], :target_role_ids => ['1'] | |||
post :copy, :params => { | |||
:source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['3'], :target_role_ids => ['1'] | |||
} | |||
assert_response 302 | |||
assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) | |||
end | |||
@@ -344,8 +359,10 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_copy_one_to_many | |||
source_transitions = status_transitions(:tracker_id => 1, :role_id => 2) | |||
post :copy, :source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
post :copy, :params => { | |||
:source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
} | |||
assert_response 302 | |||
assert_equal source_transitions, status_transitions(:tracker_id => 2, :role_id => 1) | |||
assert_equal source_transitions, status_transitions(:tracker_id => 3, :role_id => 1) | |||
@@ -357,8 +374,10 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
source_t2 = status_transitions(:tracker_id => 2, :role_id => 2) | |||
source_t3 = status_transitions(:tracker_id => 3, :role_id => 2) | |||
post :copy, :source_tracker_id => 'any', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
post :copy, :params => { | |||
:source_tracker_id => 'any', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
} | |||
assert_response 302 | |||
assert_equal source_t2, status_transitions(:tracker_id => 2, :role_id => 1) | |||
assert_equal source_t3, status_transitions(:tracker_id => 3, :role_id => 1) | |||
@@ -368,9 +387,10 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_copy_with_incomplete_source_specification_should_fail | |||
assert_no_difference 'WorkflowRule.count' do | |||
post :copy, | |||
post :copy, :params => { | |||
:source_tracker_id => '', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'], :target_role_ids => ['1', '3'] | |||
} | |||
assert_response 200 | |||
assert_select 'div.flash.error', :text => 'Please select a source tracker or role' | |||
end | |||
@@ -378,9 +398,10 @@ class WorkflowsControllerTest < Redmine::ControllerTest | |||
def test_post_copy_with_incomplete_target_specification_should_fail | |||
assert_no_difference 'WorkflowRule.count' do | |||
post :copy, | |||
post :copy, :params => { | |||
:source_tracker_id => '1', :source_role_id => '2', | |||
:target_tracker_ids => ['2', '3'] | |||
} | |||
assert_response 200 | |||
assert_select 'div.flash.error', :text => 'Please select target tracker(s) and role(s)' | |||
end |
@@ -278,10 +278,10 @@ module Redmine | |||
end | |||
class ControllerTest < ActionController::TestCase | |||
def process(method, path, parameters={}, options={}, flash={}) | |||
if parameters.key?(:params) | |||
raise ArgumentError if options.present? | |||
super method, path, parameters[:params], parameters.except(:params) | |||
def process(method, path, parameters={}, session={}, flash={}) | |||
if parameters.key?(:params) || parameters.key?(:session) | |||
raise ArgumentError if session.present? | |||
super method, path, parameters[:params], parameters[:session], parameters.except(:params, :session) | |||
else | |||
super | |||
end |