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'
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
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
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)
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)
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
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)
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
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
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))
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'
end
def test_search_issues
- get :index, :q => 'issue', :issues => 1
+ get :index, :params => {:q => 'issue', :issues => 1}
assert_response :success
assert_template 'index'
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
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
@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?
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))
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))
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
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
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
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
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
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
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
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
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>/
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'
@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)
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
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
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
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
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
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
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]
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
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?
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'
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
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
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
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
: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)
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
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
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
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
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
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'
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)
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)
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)
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)
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)
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
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'
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)
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
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)
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)
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'
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")
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")
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
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
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")
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'
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
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
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'
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'
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
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
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
@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
@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
@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
@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
@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/
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
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
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
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
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'
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
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'
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
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
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
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
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
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'
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
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
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]
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
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
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
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}
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}
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'
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
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)
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)
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)
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)
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)
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
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)
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)
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'
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
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
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'
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'
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'
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)
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
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
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
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
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}"
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"
: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
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
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
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')
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'
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'
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'
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
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]
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]
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'
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)
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)
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)
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)
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
end
def test_show
- get :show, :id => 2
+ get :show, :params => {:id => 2}
assert_response :success
assert_template 'show'
assert_not_nil assigns(:version)
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'
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
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
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')
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
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'
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
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')
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)
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
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'
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'
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'
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
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
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
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))
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
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
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
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
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
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
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
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
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
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
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
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][]'
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][]'
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
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)
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
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
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
@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
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
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/
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/
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'
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'
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'
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
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'
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]'
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
@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]'
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
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
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
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'
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
@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'
@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')
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
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'
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'
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
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
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",
:version => 1
},
:wiki_page => {:parent_id => '1'}
+ }
end
end
end
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
:wiki_page => {
:parent_id => ""
}
+ }
end
end
end
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 => '',
:version => 1
},
:wiki_page => {:parent_id => '1'}
+ }
end
end
end
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 => '',
:version => 1
},
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}}
+ }
end
end
end
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
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
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
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
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",
},
:section => 2,
:section_hash => Digest::MD5.hexdigest("wrong hash")
+ }
end
end
end
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/
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/
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)
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)
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'
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'
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'
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'
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
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
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
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'
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)
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'
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)
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)
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)
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
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
end
def test_index
- get :index, :project_id => 'ecookbook'
+ get :index, :params => {:project_id => 'ecookbook'}
assert_response :success
assert_template 'index'
pages = assigns(:pages)
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)
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)
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'
end
def test_not_found
- get :show, :project_id => 999
+ get :show, :params => {:project_id => 999}
assert_response 404
end
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
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'
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
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
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
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
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
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
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
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
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
@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
@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
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
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
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'
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)
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'
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
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?
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
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'
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'
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'
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
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
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
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
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}]"
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
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
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)
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)
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
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
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