summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-10-24 14:40:03 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-10-24 14:40:03 +0000
commit471130119404c69d9cf238e20d2b1f7c0affc88e (patch)
tree0e811cde7d65c08edf3b00f876f59e6e20c6c300 /test
parent96966d0b6c327b9ae3225ed390c62724da139ec5 (diff)
downloadredmine-471130119404c69d9cf238e20d2b1f7c0affc88e.tar.gz
redmine-471130119404c69d9cf238e20d2b1f7c0affc88e.zip
fix source indent of QueriesControllerTest
git-svn-id: http://svn.redmine.org/redmine/trunk@20183 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/functional/queries_controller_test.rb251
1 files changed, 146 insertions, 105 deletions
diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb
index 88fe5048a..d0f9e9284 100644
--- a/test/functional/queries_controller_test.rb
+++ b/test/functional/queries_controller_test.rb
@@ -39,9 +39,7 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_new_project_query
@request.session[:user_id] = 2
- get :new, :params => {
- :project_id => 1
- }
+ get(:new, :params => {:project_id => 1})
assert_response :success
assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]'
@@ -63,38 +61,27 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_new_on_invalid_project
@request.session[:user_id] = 2
- get :new, :params => {
- :project_id => 'invalid'
- }
+ get(:new, :params => {:project_id => 'invalid'})
assert_response 404
end
def test_new_should_not_render_show_inline_columns_option_for_query_without_available_inline_columns
@request.session[:user_id] = 1
- get :new, :params => {
- :type => 'ProjectQuery'
- }
-
+ get(:new, :params => {:type => 'ProjectQuery'})
assert_response :success
assert_select 'p[class=?]', 'block_columns', 0
end
def test_new_should_not_render_show_totals_option_for_query_without_totable_columns
@request.session[:user_id] = 1
- get :new, :params => {
- :type => 'ProjectQuery'
- }
-
+ get(:new, :params => {:type => 'ProjectQuery'})
assert_response :success
assert_select 'p[class=?]', 'totables_columns', 0
end
def test_new_time_entry_query
@request.session[:user_id] = 2
- get :new, :params => {
- :project_id => 1,
- :type => 'TimeEntryQuery'
- }
+ get(:new, :params => {:project_id => 1, :type => 'TimeEntryQuery'})
assert_response :success
assert_select 'input[name=type][value=?]', 'TimeEntryQuery'
assert_select 'p[class=?]', 'totable_columns', 1
@@ -103,19 +90,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_new_project_query_for_projects
@request.session[:user_id] = 1
- get :new, :params => {
- :type => 'ProjectQuery'
- }
+ get(:new, :params => {:type => 'ProjectQuery'})
assert_response :success
assert_select 'input[name=type][value=?]', 'ProjectQuery'
end
def test_new_project_query_should_not_render_roles_visibility_options
@request.session[:user_id] = 1
- get :new, :params => {
- :type => 'ProjectQuery'
- }
-
+ get(:new, :params => {:type => 'ProjectQuery'})
assert_response :success
assert_select 'input[id=?]', 'query_visibility_0', 1
assert_select 'input[id=?]', 'query_visibility_2', 1
@@ -124,32 +106,34 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_new_project_query_should_not_render_for_all_projects_option
@request.session[:user_id] = 1
- get :new, :params => {
- :type => 'ProjectQuery'
- }
-
+ get(:new, :params => {:type => 'ProjectQuery'})
assert_response :success
assert_select 'input[name=?]', 'for_all_projects', 0
end
def test_new_time_entry_query_should_select_spent_time_from_main_menu
@request.session[:user_id] = 2
- get :new, :params => {
+ get(
+ :new,
+ :params => {
:project_id => 1,
:type => 'TimeEntryQuery'
}
+ )
assert_response :success
assert_select '#main-menu a.time-entries.selected'
end
def test_new_time_entry_query_with_issue_tracking_module_disabled_should_be_allowed
Project.find(1).disable_module! :issue_tracking
-
@request.session[:user_id] = 2
- get :new, :params => {
+ get(
+ :new,
+ :params => {
:project_id => 1,
:type => 'TimeEntryQuery'
}
+ )
assert_response :success
end
@@ -190,7 +174,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_project_public_query
@request.session[:user_id] = 2
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:default_columns => '1',
:f => ["status_id", "assigned_to_id"],
@@ -204,7 +190,7 @@ class QueriesControllerTest < Redmine::ControllerTest
"name" => "test_new_project_public_query", "visibility" => "2"
}
}
-
+ )
q = Query.find_by_name('test_new_project_public_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
assert q.is_public?
@@ -214,7 +200,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_project_private_query
@request.session[:user_id] = 3
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
@@ -228,7 +216,7 @@ class QueriesControllerTest < Redmine::ControllerTest
"name" => "test_new_project_private_query", "visibility" => "0"
}
}
-
+ )
q = Query.find_by_name('test_new_project_private_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
assert !q.is_public?
@@ -238,7 +226,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_project_roles_query
@request.session[:user_id] = 2
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
@@ -249,10 +239,12 @@ class QueriesControllerTest < Redmine::ControllerTest
"assigned_to_id" => ["1"], "status_id" => ["1"]
},
:query => {
- "name" => "test_create_project_roles_query", "visibility" => "1", "role_ids" => ["1", "2", ""]
+ "name" => "test_create_project_roles_query",
+ "visibility" => "1",
+ "role_ids" => ["1", "2", ""]
}
}
-
+ )
q = Query.find_by_name('test_create_project_roles_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q
assert_equal Query::VISIBILITY_ROLES, q.visibility
@@ -261,7 +253,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_global_private_query_with_custom_columns
@request.session[:user_id] = 3
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:fields => ["status_id", "assigned_to_id"],
:operators => {
"assigned_to_id" => "=", "status_id" => "o"
@@ -274,7 +268,7 @@ class QueriesControllerTest < Redmine::ControllerTest
},
:c => ["", "tracker", "subject", "priority", "category"]
}
-
+ )
q = Query.find_by_name('test_new_global_private_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
assert !q.is_public?
@@ -285,7 +279,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_global_query_with_custom_filters
@request.session[:user_id] = 3
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:fields => ["assigned_to_id"],
:operators => {
"assigned_to_id" => "="
@@ -297,7 +293,7 @@ class QueriesControllerTest < Redmine::ControllerTest
"name" => "test_new_global_query"
}
}
-
+ )
q = Query.find_by_name('test_new_global_query')
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q
assert !q.is_public?
@@ -308,7 +304,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_with_sort
@request.session[:user_id] = 1
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:default_columns => '1',
:operators => {
"status_id" => "o"
@@ -320,10 +318,11 @@ class QueriesControllerTest < Redmine::ControllerTest
:name => "test_new_with_sort",
:visibility => "2",
:sort_criteria => {
- "0" => ["due_date", "desc"], "1" => ["tracker", ""]}
+ "0" => ["due_date", "desc"], "1" => ["tracker", ""]
+ }
}
}
-
+ )
query = Query.find_by_name("test_new_with_sort")
assert_not_nil query
assert_equal [['due_date', 'desc'], ['tracker', 'asc']], query.sort_criteria
@@ -332,12 +331,15 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_with_failure
@request.session[:user_id] = 2
assert_no_difference '::Query.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:query => {
:name => ''
}
}
+ )
end
assert_response :success
@@ -349,10 +351,13 @@ class QueriesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
assert_no_difference '::Query.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:query => {:name => 'Foo'}
}
+ )
end
assert_response 403
end
@@ -362,9 +367,7 @@ class QueriesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
assert_no_difference '::Query.count' do
- post :create, :params => {
- :query => {:name => 'Foo'}
- }
+ post(:create, :params => {:query => {:name => 'Foo'}})
end
assert_response 403
end
@@ -372,7 +375,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_global_query_from_gantt
@request.session[:user_id] = 1
assert_difference 'IssueQuery.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:gantt => 1,
:operators => {
"status_id" => "o"
@@ -387,6 +392,7 @@ class QueriesControllerTest < Redmine::ControllerTest
:draw_selected_columns => '1'
}
}
+ )
assert_response 302
end
query = IssueQuery.order('id DESC').first
@@ -399,7 +405,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_project_query_from_gantt
@request.session[:user_id] = 1
assert_difference 'IssueQuery.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:gantt => 1,
:operators => {
@@ -415,6 +423,7 @@ class QueriesControllerTest < Redmine::ControllerTest
:draw_selected_columns => '0'
}
}
+ )
assert_response 302
end
query = IssueQuery.order('id DESC').first
@@ -427,12 +436,15 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_project_public_query_should_force_private_without_manage_public_queries_permission
@request.session[:user_id] = 3
query = new_record(Query) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:query => {
"name" => "name", "visibility" => "2"
}
}
+ )
assert_response 302
end
assert_not_nil query.project
@@ -442,13 +454,16 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_global_public_query_should_force_private_without_manage_public_queries_permission
@request.session[:user_id] = 3
query = new_record(Query) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:query_is_for_all => '1',
:query => {
"name" => "name", "visibility" => "2"
}
}
+ )
assert_response 302
end
assert_nil query.project
@@ -458,12 +473,15 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_project_public_query_with_manage_public_queries_permission
@request.session[:user_id] = 2
query = new_record(Query) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:query => {
"name" => "name", "visibility" => "2"
}
}
+ )
assert_response 302
end
assert_not_nil query.project
@@ -473,13 +491,16 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_global_public_query_should_force_private_with_manage_public_queries_permission
@request.session[:user_id] = 2
query = new_record(Query) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:query_is_for_all => '1',
:query => {
"name" => "name", "visibility" => "2"
}
}
+ )
assert_response 302
end
assert_nil query.project
@@ -489,13 +510,16 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_create_global_public_query_by_admin
@request.session[:user_id] = 1
query = new_record(Query) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:query_is_for_all => '1',
:query => {
"name" => "name", "visibility" => "2"
}
}
+ )
assert_response 302
end
assert_nil query.project
@@ -506,7 +530,9 @@ class QueriesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 2
q = new_record(TimeEntryQuery) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:project_id => 'ecookbook',
:type => 'TimeEntryQuery',
:default_columns => '1',
@@ -521,6 +547,7 @@ class QueriesControllerTest < Redmine::ControllerTest
"name" => "test_new_project_public_query", "visibility" => "2"
}
}
+ )
end
assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :query_id => q.id
@@ -533,7 +560,9 @@ class QueriesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = 1
q = new_record(ProjectQuery) do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:type => 'ProjectQuery',
:default_columns => '1',
:f => ["status"],
@@ -547,6 +576,7 @@ class QueriesControllerTest < Redmine::ControllerTest
"name" => "test_new_project_public_query", "visibility" => "2"
}
}
+ )
end
assert_redirected_to :controller => 'projects', :action => 'index', :query_id => q.id
@@ -557,9 +587,7 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_edit_global_public_query
@request.session[:user_id] = 1
- get :edit, :params => {
- :id => 4
- }
+ get(:edit, :params => {:id => 4})
assert_response :success
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
@@ -568,9 +596,7 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_edit_global_private_query
@request.session[:user_id] = 3
- get :edit, :params => {
- :id => 3
- }
+ get(:edit, :params => {:id => 3})
assert_response :success
assert_select 'input[name=?]', 'query[visibility]', 0
@@ -579,9 +605,7 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_edit_project_private_query
@request.session[:user_id] = 3
- get :edit, :params => {
- :id => 2
- }
+ get(:edit, :params => {:id => 2})
assert_response :success
assert_select 'input[name=?]', 'query[visibility]', 0
@@ -590,9 +614,7 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_edit_project_public_query
@request.session[:user_id] = 2
- get :edit, :params => {
- :id => 1
- }
+ get(:edit, :params => {:id => 1})
assert_response :success
assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]'
@@ -601,9 +623,7 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_edit_sort_criteria
@request.session[:user_id] = 1
- get :edit, :params => {
- :id => 5
- }
+ get(:edit, :params => {:id => 5})
assert_response :success
assert_select 'select[name=?]', 'query[sort_criteria][0][]' do
@@ -614,15 +634,15 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_edit_invalid_query
@request.session[:user_id] = 2
- get :edit, :params => {
- :id => 99
- }
+ get(:edit, :params => {:id => 99})
assert_response 404
end
def test_update_global_private_query
@request.session[:user_id] = 3
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => 3,
:default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
@@ -636,7 +656,7 @@ class QueriesControllerTest < Redmine::ControllerTest
"name" => "test_edit_global_private_query", "visibility" => "2"
}
}
-
+ )
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3
q = Query.find_by_name('test_edit_global_private_query')
assert !q.is_public?
@@ -646,7 +666,9 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_update_global_public_query
@request.session[:user_id] = 1
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => 4,
:default_columns => '1',
:fields => ["status_id", "assigned_to_id"],
@@ -660,7 +682,7 @@ class QueriesControllerTest < Redmine::ControllerTest
"name" => "test_edit_global_public_query", "visibility" => "2"
}
}
-
+ )
assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4
q = Query.find_by_name('test_edit_global_public_query')
assert q.is_public?
@@ -670,41 +692,42 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_update_with_failure
@request.session[:user_id] = 1
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => 4,
:query => {
:name => ''
}
}
+ )
assert_response :success
assert_select_error /Name cannot be blank/
end
def test_destroy
@request.session[:user_id] = 2
- delete :destroy, :params => {
- :id => 1
- }
+ delete(:destroy, :params => {:id => 1})
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil
assert_nil Query.find_by_id(1)
end
def test_backslash_should_be_escaped_in_filters
@request.session[:user_id] = 2
- get :new, :params => {
- :subject => 'foo/bar'
- }
+ get(:new, :params => {:subject => 'foo/bar'})
assert_response :success
assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body
end
def test_filter_with_project_id_should_return_filter_values
@request.session[:user_id] = 2
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:name => 'fixed_version_id'
}
-
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -713,12 +736,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_version_filter_time_entries_with_project_id_should_return_filter_values
@request.session[:user_id] = 2
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:type => 'TimeEntryQuery',
:name => 'issue.fixed_version_id'
}
-
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -728,12 +753,13 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_version_filter_without_project_id_should_return_all_visible_fixed_versions
# Remove "jsmith" user from "Private child of eCookbook" project
Project.find(5).memberships.find_by(:user_id => 2).destroy
-
@request.session[:user_id] = 2
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:name => 'fixed_version_id'
}
-
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -749,12 +775,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_subproject_filter_time_entries_with_project_id_should_return_filter_values
@request.session[:user_id] = 2
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:type => 'TimeEntryQuery',
:name => 'subproject_id'
}
-
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -764,11 +792,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_assignee_filter_should_return_active_and_locked_users_grouped_by_status
@request.session[:user_id] = 1
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:type => 'IssueQuery',
:name => 'assigned_to_id'
}
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -782,11 +813,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_author_filter_should_return_active_and_locked_users_grouped_by_status
@request.session[:user_id] = 1
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:type => 'IssueQuery',
:name => 'author_id'
}
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -801,11 +835,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_user_filter_should_return_active_and_locked_users_grouped_by_status
@request.session[:user_id] = 1
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:type => 'TimeEntryQuery',
:name => 'user_id'
}
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -820,12 +857,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_watcher_filter_without_permission_should_show_only_me
# This user does not have view_issue_watchers permission
@request.session[:user_id] = 7
-
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:type => 'IssueQuery',
:name => 'watcher_id'
}
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)
@@ -837,12 +876,14 @@ class QueriesControllerTest < Redmine::ControllerTest
def test_watcher_filter_with_permission_should_show_members_and_groups
# This user has view_issue_watchers permission
@request.session[:user_id] = 1
-
- get :filter, :params => {
+ get(
+ :filter,
+ :params => {
:project_id => 1,
:type => 'IssueQuery',
:name => 'watcher_id'
}
+ )
assert_response :success
assert_equal 'application/json', response.media_type
json = ActiveSupport::JSON.decode(response.body)