summaryrefslogtreecommitdiffstats
path: root/test/functional/timelog_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-16 07:43:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-07-16 07:43:16 +0000
commit6cc6a918b4f36dbad445a5756f174b767e4ad61b (patch)
tree87704465c1a28284c466744eb6418cbd8adb1e22 /test/functional/timelog_controller_test.rb
parent11c85279ab2a8e660666e2c0c80025e2e2513940 (diff)
downloadredmine-6cc6a918b4f36dbad445a5756f174b767e4ad61b.tar.gz
redmine-6cc6a918b4f36dbad445a5756f174b767e4ad61b.zip
Pass parameters with :params in controller tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@15666 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/timelog_controller_test.rb')
-rw-r--r--test/functional/timelog_controller_test.rb372
1 files changed, 235 insertions, 137 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb
index 95c14295b..6a7219060 100644
--- a/test/functional/timelog_controller_test.rb
+++ b/test/functional/timelog_controller_test.rb
@@ -43,7 +43,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_new_with_project_id
@request.session[:user_id] = 3
- get :new, :project_id => 1
+ get :new, :params => {:project_id => 1}
assert_response :success
assert_template 'new'
assert_select 'input[name=?][type=hidden]', 'project_id'
@@ -53,7 +53,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_new_with_issue_id
@request.session[:user_id] = 3
- get :new, :issue_id => 2
+ get :new, :params => {:issue_id => 2}
assert_response :success
assert_template 'new'
assert_select 'input[name=?][type=hidden]', 'project_id', 0
@@ -63,7 +63,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_new_without_project_should_prefill_the_form
@request.session[:user_id] = 3
- get :new, :time_entry => {:project_id => '1'}
+ get :new, :params => {:time_entry => {:project_id => '1'}}
assert_response :success
assert_template 'new'
assert_select 'select[name=?]', 'time_entry[project_id]' do
@@ -81,7 +81,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_new_should_select_default_activity
@request.session[:user_id] = 3
- get :new, :project_id => 1
+ get :new, :params => {:project_id => 1}
assert_response :success
assert_select 'select[name=?]', 'time_entry[activity_id]' do
assert_select 'option[selected=selected]', :text => 'Development'
@@ -90,21 +90,21 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_new_should_only_show_active_time_entry_activities
@request.session[:user_id] = 3
- get :new, :project_id => 1
+ get :new, :params => {:project_id => 1}
assert_response :success
assert_select 'option', :text => 'Inactive Activity', :count => 0
end
def test_post_new_as_js_should_update_activity_options
@request.session[:user_id] = 3
- post :new, :time_entry => {:project_id => 1}, :format => 'js'
+ post :new, :params => {:time_entry => {:project_id => 1}, :format => 'js'}
assert_response :success
assert_include '#time_entry_activity_id', response.body
end
def test_get_edit_existing_time
@request.session[:user_id] = 2
- get :edit, :id => 2, :project_id => nil
+ get :edit, :params => {:id => 2, :project_id => nil}
assert_response :success
assert_template 'edit'
assert_select 'form[action=?]', '/time_entries/2'
@@ -116,7 +116,7 @@ class TimelogControllerTest < Redmine::ControllerTest
te.save!(:validate => false)
@request.session[:user_id] = 1
- get :edit, :project_id => 1, :id => 1
+ get :edit, :params => {:project_id => 1, :id => 1}
assert_response :success
assert_template 'edit'
# Blank option since nothing is pre-selected
@@ -126,13 +126,16 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_post_create
@request.session[:user_id] = 3
assert_difference 'TimeEntry.count' do
- post :create, :project_id => 1,
- :time_entry => {:comments => 'Some work on TimelogControllerTest',
- # Not the default activity
- :activity_id => '11',
- :spent_on => '2008-03-14',
- :issue_id => '1',
- :hours => '7.3'}
+ post :create, :params => {
+ :project_id => 1,
+ :time_entry => {:comments => 'Some work on TimelogControllerTest',
+ # Not the default activity
+ :activity_id => '11',
+ :spent_on => '2008-03-14',
+ :issue_id => '1',
+ :hours => '7.3'
+ }
+ }
assert_redirected_to '/projects/ecookbook/time_entries'
end
@@ -149,13 +152,17 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_post_create_with_blank_issue
@request.session[:user_id] = 3
assert_difference 'TimeEntry.count' do
- post :create, :project_id => 1,
- :time_entry => {:comments => 'Some work on TimelogControllerTest',
- # Not the default activity
- :activity_id => '11',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => '7.3'}
+ post :create, :params => {
+ :project_id => 1,
+ :time_entry => {
+ :comments => 'Some work on TimelogControllerTest',
+ # Not the default activity
+ :activity_id => '11',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ }
+ }
assert_redirected_to '/projects/ecookbook/time_entries'
end
@@ -174,9 +181,11 @@ class TimelogControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {
- :project_id => '1', :issue_id => '',
- :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '1', :issue_id => '',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
}
end
end
@@ -186,9 +195,11 @@ class TimelogControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {
- :project_id => '1', :issue_id => '',
- :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '1', :issue_id => '',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
}
end
end
@@ -198,9 +209,11 @@ class TimelogControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {
- :project_id => '', :issue_id => '1',
- :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '', :issue_id => '1',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
}
assert_select_error /Issue is invalid/
end
@@ -211,9 +224,11 @@ class TimelogControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {
- :project_id => '', :issue_id => '1',
- :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '', :issue_id => '1',
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
}
assert_select_error /Issue is invalid/
end
@@ -225,9 +240,11 @@ class TimelogControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 3
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {
- :project_id => '', :issue_id => issue.id.to_s,
- :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '', :issue_id => issue.id.to_s,
+ :activity_id => '11', :spent_on => '2008-03-14', :hours => '7.3'
+ }
}
end
assert_select_error /Issue is invalid/
@@ -239,12 +256,16 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_and_continue_at_project_level
@request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do
- post :create, :time_entry => {:project_id => '1',
- :activity_id => '11',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => '7.3'},
- :continue => '1'
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '1',
+ :activity_id => '11',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ },
+ :continue => '1'
+ }
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D=1'
end
end
@@ -252,12 +273,16 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_and_continue_at_issue_level
@request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do
- post :create, :time_entry => {:project_id => '',
- :activity_id => '11',
- :issue_id => '1',
- :spent_on => '2008-03-14',
- :hours => '7.3'},
- :continue => '1'
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '',
+ :activity_id => '11',
+ :issue_id => '1',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ },
+ :continue => '1'
+ }
assert_redirected_to '/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D='
end
end
@@ -265,12 +290,16 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_and_continue_with_project_id
@request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do
- post :create, :project_id => 1,
- :time_entry => {:activity_id => '11',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => '7.3'},
- :continue => '1'
+ post :create, :params => {
+ :project_id => 1,
+ :time_entry => {
+ :activity_id => '11',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ },
+ :continue => '1'
+ }
assert_redirected_to '/projects/ecookbook/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=&time_entry%5Bproject_id%5D='
end
end
@@ -278,12 +307,16 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_and_continue_with_issue_id
@request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do
- post :create, :issue_id => 1,
- :time_entry => {:activity_id => '11',
- :issue_id => '1',
- :spent_on => '2008-03-14',
- :hours => '7.3'},
- :continue => '1'
+ post :create, :params => {
+ :issue_id => 1,
+ :time_entry => {
+ :activity_id => '11',
+ :issue_id => '1',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ },
+ :continue => '1'
+ }
assert_redirected_to '/issues/1/time_entries/new?time_entry%5Bactivity_id%5D=11&time_entry%5Bissue_id%5D=1&time_entry%5Bproject_id%5D='
end
end
@@ -291,18 +324,21 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_without_log_time_permission_should_be_denied
@request.session[:user_id] = 2
Role.find_by_name('Manager').remove_permission! :log_time
- post :create, :project_id => 1,
- :time_entry => {:activity_id => '11',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => '7.3'}
-
+ post :create, :params => {
+ :project_id => 1,
+ :time_entry => {
+ :activity_id => '11',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ }
+ }
assert_response 403
end
def test_create_without_project_and_issue_should_fail
@request.session[:user_id] = 2
- post :create, :time_entry => {:issue_id => ''}
+ post :create, :params => {:time_entry => {:issue_id => ''}}
assert_response :success
assert_template 'new'
@@ -310,12 +346,15 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_with_failure
@request.session[:user_id] = 2
- post :create, :project_id => 1,
- :time_entry => {:activity_id => '',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => '7.3'}
-
+ post :create, :params => {
+ :project_id => 1,
+ :time_entry => {
+ :activity_id => '',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ }
+ }
assert_response :success
assert_template 'new'
end
@@ -323,11 +362,15 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_without_project
@request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do
- post :create, :time_entry => {:project_id => '1',
- :activity_id => '11',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => '7.3'}
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '1',
+ :activity_id => '11',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ }
+ }
end
assert_redirected_to '/projects/ecookbook/time_entries'
@@ -338,11 +381,15 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_without_project_should_fail_with_issue_not_inside_project
@request.session[:user_id] = 2
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {:project_id => '1',
- :activity_id => '11',
- :issue_id => '5',
- :spent_on => '2008-03-14',
- :hours => '7.3'}
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '1',
+ :activity_id => '11',
+ :issue_id => '5',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ }
+ }
end
assert_response :success
@@ -354,11 +401,15 @@ class TimelogControllerTest < Redmine::ControllerTest
Project.find(3).disable_module!(:time_tracking)
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {:project_id => '3',
- :activity_id => '11',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => '7.3'}
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '3',
+ :activity_id => '11',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => '7.3'
+ }
+ }
end
assert_response 403
@@ -367,11 +418,15 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_create_without_project_with_failure
@request.session[:user_id] = 2
assert_no_difference 'TimeEntry.count' do
- post :create, :time_entry => {:project_id => '1',
- :activity_id => '11',
- :issue_id => '',
- :spent_on => '2008-03-14',
- :hours => ''}
+ post :create, :params => {
+ :time_entry => {
+ :project_id => '1',
+ :activity_id => '11',
+ :issue_id => '',
+ :spent_on => '2008-03-14',
+ :hours => ''
+ }
+ }
end
assert_response :success
@@ -386,9 +441,13 @@ class TimelogControllerTest < Redmine::ControllerTest
assert_equal 2, entry.user_id
@request.session[:user_id] = 1
- put :update, :id => 1,
- :time_entry => {:issue_id => '2',
- :hours => '8'}
+ put :update, :params => {
+ :id => 1,
+ :time_entry => {
+ :issue_id => '2',
+ :hours => '8'
+ }
+ }
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
entry.reload
@@ -401,7 +460,12 @@ class TimelogControllerTest < Redmine::ControllerTest
entry = TimeEntry.generate!(:issue_id => 1)
@request.session[:user_id] = 1
- put :update, :id => entry.id, :time_entry => {:issue_id => '5'}
+ put :update, :params => {
+ :id => entry.id,
+ :time_entry => {
+ :issue_id => '5'
+ }
+ }
assert_response 302
entry.reload
@@ -414,14 +478,20 @@ class TimelogControllerTest < Redmine::ControllerTest
Project.find(3).disable_module!(:time_tracking)
@request.session[:user_id] = 1
- put :update, :id => entry.id, :time_entry => {:issue_id => '5'}
+ put :update, :params => {
+ :id => entry.id,
+ :time_entry => {
+ :issue_id => '5'
+ }
+ }
assert_response 200
assert_include "Issue is invalid", assigns(:time_entry).errors.full_messages
end
def test_get_bulk_edit
@request.session[:user_id] = 2
- get :bulk_edit, :ids => [1, 2]
+
+ get :bulk_edit, :params => {:ids => [1, 2]}
assert_response :success
assert_template 'bulk_edit'
@@ -444,7 +514,8 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_get_bulk_edit_on_different_projects
@request.session[:user_id] = 2
- get :bulk_edit, :ids => [1, 2, 6]
+
+ get :bulk_edit, :params => {:ids => [1, 2, 6]}
assert_response :success
assert_template 'bulk_edit'
end
@@ -455,14 +526,14 @@ class TimelogControllerTest < Redmine::ControllerTest
Role.find_by_name('Manager').add_permission! :edit_own_time_entries
ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id}
- get :bulk_edit, :ids => ids
+ get :bulk_edit, :params => {:ids => ids}
assert_response :success
end
def test_bulk_update
@request.session[:user_id] = 2
# update time entry activity
- post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9}
+ post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :activity_id => 9}}
assert_response 302
# check that the issues were updated
@@ -471,7 +542,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_bulk_update_with_failure
@request.session[:user_id] = 2
- post :bulk_update, :ids => [1, 2], :time_entry => { :hours => 'A'}
+ post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :hours => 'A'}}
assert_response 302
assert_match /Failed to save 2 time entrie/, flash[:error]
@@ -483,7 +554,7 @@ class TimelogControllerTest < Redmine::ControllerTest
Member.create!(:user_id => 2, :project_id => 3, :role_ids => [1])
# update time entry activity
- post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 }
+ post :bulk_update, :params => {:ids => [1, 2, 4], :time_entry => { :activity_id => 9 }}
assert_response 302
# check that the issues were updated
@@ -496,7 +567,8 @@ class TimelogControllerTest < Redmine::ControllerTest
action = { :controller => "timelog", :action => "bulk_update" }
assert user.allowed_to?(action, TimeEntry.find(1).project)
assert ! user.allowed_to?(action, TimeEntry.find(5).project)
- post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 }
+
+ post :bulk_update, :params => {:ids => [1, 5], :time_entry => { :activity_id => 9 }}
assert_response 403
end
@@ -506,7 +578,7 @@ class TimelogControllerTest < Redmine::ControllerTest
Role.find_by_name('Manager').add_permission! :edit_own_time_entries
ids = (0..1).map {TimeEntry.generate!(:user => User.find(2)).id}
- post :bulk_update, :ids => ids, :time_entry => { :activity_id => 9 }
+ post :bulk_update, :params => {:ids => ids, :time_entry => { :activity_id => 9 }}
assert_response 302
end
@@ -515,13 +587,13 @@ class TimelogControllerTest < Redmine::ControllerTest
Role.find_by_name('Manager').remove_permission! :edit_time_entries
Role.find_by_name('Manager').add_permission! :edit_own_time_entries
- post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9 }
+ post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :activity_id => 9 }}
assert_response 403
end
def test_bulk_update_custom_field
@request.session[:user_id] = 2
- post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }
+ post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }}
assert_response 302
assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value}
@@ -530,7 +602,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_bulk_update_clear_custom_field
field = TimeEntryCustomField.generate!(:field_format => 'string')
@request.session[:user_id] = 2
- post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} }
+ post :bulk_update, :params => {:ids => [1, 2], :time_entry => { :custom_field_values => {field.id.to_s => '__none__'} }}
assert_response 302
assert_equal ["", ""], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(field).value}
@@ -538,7 +610,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
@request.session[:user_id] = 2
- post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
+ post :bulk_update, :params => {:ids => [1,2], :back_url => '/time_entries'}
assert_response :redirect
assert_redirected_to '/time_entries'
@@ -546,7 +618,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
@request.session[:user_id] = 2
- post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
+ post :bulk_update, :params => {:ids => [1,2], :back_url => 'http://google.com'}
assert_response :redirect
assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier
@@ -555,14 +627,15 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_post_bulk_update_without_edit_permission_should_be_denied
@request.session[:user_id] = 2
Role.find_by_name('Manager').remove_permission! :edit_time_entries
- post :bulk_update, :ids => [1,2]
+ post :bulk_update, :params => {:ids => [1,2]}
assert_response 403
end
def test_destroy
@request.session[:user_id] = 2
- delete :destroy, :id => 1
+
+ delete :destroy, :params => {:id => 1}
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_successful_delete), flash[:notice]
assert_nil TimeEntry.find_by_id(1)
@@ -571,9 +644,9 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_destroy_should_fail
# simulate that this fails (e.g. due to a plugin), see #5700
TimeEntry.any_instance.expects(:destroy).returns(false)
-
@request.session[:user_id] = 2
- delete :destroy, :id => 1
+
+ delete :destroy, :params => {:id => 1}
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
assert_not_nil TimeEntry.find_by_id(1)
@@ -597,14 +670,14 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_index_my_spent_time
@request.session[:user_id] = 2
- get :index, :user_id => 'me'
+ get :index, :params => {:user_id => 'me'}
assert_response :success
assert_template 'index'
assert assigns(:entries).all? {|entry| entry.user_id == 2}
end
def test_index_at_project_level
- get :index, :project_id => 'ecookbook'
+ get :index, :params => {:project_id => 'ecookbook'}
assert_response :success
assert_template 'index'
assert_not_nil assigns(:entries)
@@ -620,7 +693,7 @@ class TimelogControllerTest < Redmine::ControllerTest
entry = TimeEntry.generate!(:project => Project.find(3))
with_settings :display_subprojects_issues => '0' do
- get :index, :project_id => 'ecookbook'
+ get :index, :params => {:project_id => 'ecookbook'}
assert_response :success
assert_template 'index'
assert_not_include entry, assigns(:entries)
@@ -631,7 +704,7 @@ class TimelogControllerTest < Redmine::ControllerTest
entry = TimeEntry.generate!(:project => Project.find(3))
with_settings :display_subprojects_issues => '0' do
- get :index, :project_id => 'ecookbook', :subproject_id => 3
+ get :index, :params => {:project_id => 'ecookbook', :subproject_id => 3}
assert_response :success
assert_template 'index'
assert_include entry, assigns(:entries)
@@ -644,7 +717,7 @@ class TimelogControllerTest < Redmine::ControllerTest
TimeEntry.generate!(:issue => issue, :hours => 3)
@request.session[:user_id] = 2
- get :index, :project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1
+ get :index, :params => {:project_id => 'ecookbook', :issue_id => issue.id.to_s, :set_filter => 1}
assert_select '.total-for-hours', :text => 'Hours: 7.00'
end
@@ -655,15 +728,17 @@ class TimelogControllerTest < Redmine::ControllerTest
TimeEntry.generate!(:issue => issue, :hours => 3)
@request.session[:user_id] = 2
- get :index, :project_id => 'ecookbook', :"issue.fixed_version_id" => version.id.to_s, :set_filter => 1
+ get :index, :params => {:project_id => 'ecookbook', :"issue.fixed_version_id" => version.id.to_s, :set_filter => 1}
assert_select '.total-for-hours', :text => 'Hours: 5.00'
end
def test_index_at_project_level_with_date_range
- get :index, :project_id => 'ecookbook',
+ get :index, :params => {
+ :project_id => 'ecookbook',
:f => ['spent_on'],
:op => {'spent_on' => '><'},
:v => {'spent_on' => ['2007-03-20', '2007-04-30']}
+ }
assert_response :success
assert_template 'index'
assert_not_nil assigns(:entries)
@@ -674,7 +749,11 @@ class TimelogControllerTest < Redmine::ControllerTest
end
def test_index_at_project_level_with_date_range_using_from_and_to_params
- get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30'
+ get :index, :params => {
+ :project_id => 'ecookbook',
+ :from => '2007-03-20',
+ :to => '2007-04-30'
+ }
assert_response :success
assert_template 'index'
assert_not_nil assigns(:entries)
@@ -685,10 +764,12 @@ class TimelogControllerTest < Redmine::ControllerTest
end
def test_index_at_project_level_with_period
- get :index, :project_id => 'ecookbook',
+ get :index, :params => {
+ :project_id => 'ecookbook',
:f => ['spent_on'],
:op => {'spent_on' => '>t-'},
:v => {'spent_on' => ['7']}
+ }
assert_response :success
assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries'
@@ -699,18 +780,22 @@ class TimelogControllerTest < Redmine::ControllerTest
t2 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00', :activity_id => 10)
t3 = TimeEntry.create!(:user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00', :activity_id => 10)
- get :index, :project_id => 1,
+ get :index, :params => {
+ :project_id => 1,
:f => ['spent_on'],
:op => {'spent_on' => '><'},
:v => {'spent_on' => ['2012-06-15', '2012-06-16']}
+ }
assert_response :success
assert_equal [t2, t1, t3], assigns(:entries)
- get :index, :project_id => 1,
+ get :index, :params => {
+ :project_id => 1,
:f => ['spent_on'],
:op => {'spent_on' => '><'},
:v => {'spent_on' => ['2012-06-15', '2012-06-16']},
:sort => 'spent_on'
+ }
assert_response :success
assert_equal [t3, t1, t2], assigns(:entries)
end
@@ -719,7 +804,11 @@ class TimelogControllerTest < Redmine::ControllerTest
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
- get :index, :f => ['issue.cf_2'], :op => {'issue.cf_2' => '='}, :v => {'issue.cf_2' => ['filter_on_issue_custom_field']}
+ get :index, :params => {
+ :f => ['issue.cf_2'],
+ :op => {'issue.cf_2' => '='},
+ :v => {'issue.cf_2' => ['filter_on_issue_custom_field']}
+ }
assert_response :success
assert_equal [entry], assigns(:entries)
end
@@ -728,7 +817,9 @@ class TimelogControllerTest < Redmine::ControllerTest
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
- get :index, :c => %w(project spent_on issue comments hours issue.cf_2)
+ get :index, :params => {
+ :c => %w(project spent_on issue comments hours issue.cf_2)
+ }
assert_response :success
assert_include :'issue.cf_2', assigns(:query).column_names
assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field'
@@ -739,7 +830,9 @@ class TimelogControllerTest < Redmine::ControllerTest
entry = TimeEntry.generate!(:hours => 2.5, :custom_field_values => {field.id => 'CF Value'})
field_name = "cf_#{field.id}"
- get :index, :c => ["hours", field_name]
+ get :index, :params => {
+ :c => ["hours", field_name]
+ }
assert_response :success
assert_include field_name.to_sym, assigns(:query).column_names
assert_select "td.#{field_name}", :text => 'CF Value'
@@ -752,7 +845,10 @@ class TimelogControllerTest < Redmine::ControllerTest
TimeEntry.generate!(:hours => 2.5, :custom_field_values => {field.id => 'CF Value 2'})
field_name = "cf_#{field.id}"
- get :index, :c => ["hours", field_name], :sort => field_name
+ get :index, :params => {
+ :c => ["hours", field_name],
+ :sort => field_name
+ }
assert_response :success
assert_include field_name.to_sym, assigns(:query).column_names
assert_select "th a.sort", :text => 'String Field'
@@ -768,14 +864,14 @@ class TimelogControllerTest < Redmine::ControllerTest
query.save!
@request.session[:user_id] = 2
- get :index, :project_id => 'ecookbook', :query_id => query.id
+ get :index, :params => {:project_id => 'ecookbook', :query_id => query.id}
assert_response :success
assert_select 'h2', :text => query.name
assert_select '#sidebar a.selected', :text => query.name
end
def test_index_atom_feed
- get :index, :project_id => 1, :format => 'atom'
+ get :index, :params => {:project_id => 1, :format => 'atom'}
assert_response :success
assert_equal 'application/atom+xml', @response.content_type
assert_not_nil assigns(:items)
@@ -783,11 +879,13 @@ class TimelogControllerTest < Redmine::ControllerTest
end
def test_index_at_project_level_should_include_csv_export_dialog
- get :index, :project_id => 'ecookbook',
+ get :index, :params => {
+ :project_id => 'ecookbook',
:f => ['spent_on'],
:op => {'spent_on' => '>='},
:v => {'spent_on' => ['2007-04-01']},
:c => ['spent_on', 'user']
+ }
assert_response :success
assert_select '#csv-export-options' do
@@ -815,7 +913,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_index_csv_all_projects
with_settings :date_format => '%m/%d/%Y' do
- get :index, :format => 'csv'
+ get :index, :params => {:format => 'csv'}
assert_response :success
assert_equal 'text/csv; header=present', response.content_type
end
@@ -823,7 +921,7 @@ class TimelogControllerTest < Redmine::ControllerTest
def test_index_csv
with_settings :date_format => '%m/%d/%Y' do
- get :index, :project_id => 1, :format => 'csv'
+ get :index, :params => {:project_id => 1, :format => 'csv'}
assert_response :success
assert_equal 'text/csv; header=present', response.content_type
end
@@ -833,7 +931,7 @@ class TimelogControllerTest < Redmine::ControllerTest
issue = Issue.find(1)
entry = TimeEntry.generate!(:issue => issue, :comments => "Issue column content test")
- get :index, :format => 'csv'
+ get :index, :params => {:format => 'csv'}
line = response.body.split("\n").detect {|l| l.include?(entry.comments)}
assert_not_nil line
assert_include "#{issue.tracker} #1: #{issue.subject}", line