summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-04-01 15:08:52 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-04-01 15:08:52 +0000
commit83ed32e8d71fdb8c6a7492a4d82db2d52889534d (patch)
tree3350f753132d7a1d34c7bd83e0c5a4b6fae5db36 /test/functional
parent44344cfe8a8693ade7ecd855d20c2ce8857dc302 (diff)
downloadredmine-83ed32e8d71fdb8c6a7492a4d82db2d52889534d.tar.gz
redmine-83ed32e8d71fdb8c6a7492a4d82db2d52889534d.zip
Reuse ProjectQuery filters on the admin project list (#33422).
Patch by Takenori TAKAKI. git-svn-id: https://svn.redmine.org/redmine/trunk@21519 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/admin_controller_test.rb24
-rw-r--r--test/functional/queries_controller_test.rb54
2 files changed, 73 insertions, 5 deletions
diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb
index 9a9a73bda..9cebf8ca7 100644
--- a/test/functional/admin_controller_test.rb
+++ b/test/functional/admin_controller_test.rb
@@ -38,29 +38,43 @@ class AdminControllerTest < Redmine::ControllerTest
assert_select 'div.nodata'
end
- def test_projects
+ def test_projects_should_show_only_active_projects_by_default
+ p = Project.find(1)
+ p.update_column :status, 5
+
get :projects
assert_response :success
assert_select 'tr.project.closed', 0
+ assert_select 'tr.project', 5
+ assert_select 'tr.project td.name', :text => 'OnlineStore'
+ assert_select 'tr.project td.name', :text => p.name, :count => 0
end
def test_projects_with_status_filter
+ p = Project.find(1)
+ p.update_column :status, 5
get(
:projects,
:params => {
- :status => 1
+ 'set_filter' => '1',
+ 'f' => ['status'],
+ 'op' => {'status' => '='},
+ 'v' => {'status' => ['5']}
}
)
assert_response :success
- assert_select 'tr.project.closed', 0
+ assert_select 'tr.project', 1
+ assert_select 'tr.project td.name', :text => p.name
end
def test_projects_with_name_filter
get(
:projects,
:params => {
- :name => 'store',
- :status => ''
+ 'set_filter' => '1',
+ 'f' => ['status', 'name'],
+ 'op' => {'status' => '=', 'name' => '~'},
+ 'v' => {'status' => ['1'], 'name' => ['store']}
}
)
assert_response :success
diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb
index 02dba38ad..561cf212b 100644
--- a/test/functional/queries_controller_test.rb
+++ b/test/functional/queries_controller_test.rb
@@ -585,6 +585,33 @@ class QueriesControllerTest < Redmine::ControllerTest
assert q.valid?
end
+ def test_create_admin_projects_query_should_redirect_to_admin_projects
+ @request.session[:user_id] = 1
+
+ q = new_record(ProjectQuery) do
+ post(
+ :create,
+ :params => {
+ :type => 'ProjectQuery',
+ :default_columns => '1',
+ :f => ["status"],
+ :op => {
+ "status" => "="
+ },
+ :v => {
+ "status" => ['1']
+ },
+ :query => {
+ "name" => "test_new_project_public_query", "visibility" => "2"
+ },
+ :admin_projects => 1
+ }
+ )
+ end
+
+ assert_redirected_to :controller => 'admin', :action => 'projects', :query_id => q.id, :admin_projects => 1
+ end
+
def test_edit_global_public_query
@request.session[:user_id] = 1
get(:edit, :params => {:id => 4})
@@ -690,6 +717,33 @@ class QueriesControllerTest < Redmine::ControllerTest
assert q.valid?
end
+ def test_update_admin_projects_query
+ q = ProjectQuery.create(:name => 'project_query')
+ @request.session[:user_id] = 1
+
+ put(
+ :update,
+ :params => {
+ :id => q.id,
+ :default_columns => '1',
+ :fields => ["status"],
+ :operators => {
+ "status" => "="
+ },
+ :values => {
+ "status" => ['1']
+ },
+ :query => {
+ "name" => "test_project_query_updated", "visibility" => "2"
+ },
+ :admin_projects => 1
+ }
+ )
+
+ assert_redirected_to :controller => 'admin', :action => 'projects', :query_id => q.id, :admin_projects => 1
+ assert Query.find_by_name('test_project_query_updated')
+ end
+
def test_update_with_failure
@request.session[:user_id] = 1
put(