diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/issues_controller_test.rb | 14 | ||||
-rw-r--r-- | test/functional/queries_controller_test.rb | 27 | ||||
-rw-r--r-- | test/functional/timelog_controller_test.rb | 10 |
3 files changed, 44 insertions, 7 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 176fd42e5..d571d4bda 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -399,9 +399,9 @@ class IssuesControllerTest < ActionController::TestCase def test_index_with_query_id_and_project_id_should_set_session_query get :index, :project_id => 1, :query_id => 4 assert_response :success - assert_kind_of Hash, session[:query] - assert_equal 4, session[:query][:id] - assert_equal 1, session[:query][:project_id] + assert_kind_of Hash, session[:issue_query] + assert_equal 4, session[:issue_query][:id] + assert_equal 1, session[:issue_query][:project_id] end def test_index_with_invalid_query_id_should_respond_404 @@ -411,7 +411,7 @@ class IssuesControllerTest < ActionController::TestCase def test_index_with_cross_project_query_in_session_should_show_project_issues q = IssueQuery.create!(:name => "test", :user_id => 2, :visibility => IssueQuery::VISIBILITY_PRIVATE, :project => nil) - @request.session[:query] = {:id => q.id, :project_id => 1} + @request.session[:issue_query] = {:id => q.id, :project_id => 1} with_settings :display_subprojects_issues => '0' do get :index, :project_id => 1 @@ -832,9 +832,9 @@ class IssuesControllerTest < ActionController::TestCase assert_equal columns, query.column_names.map(&:to_s) # columns should be stored in session - assert_kind_of Hash, session[:query] - assert_kind_of Array, session[:query][:column_names] - assert_equal columns, session[:query][:column_names].map(&:to_s) + assert_kind_of Hash, session[:issue_query] + assert_kind_of Array, session[:issue_query][:column_names] + assert_equal columns, session[:issue_query][:column_names].map(&:to_s) # ensure only these columns are kept in the selected columns list assert_select 'select#selected_columns option' do diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index c7ad25850..27eb48a92 100644 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -58,6 +58,13 @@ class QueriesControllerTest < ActionController::TestCase assert_response 404 end + def test_new_time_entry_query + @request.session[:user_id] = 2 + get :new, :project_id => 1, :type => 'TimeEntryQuery' + assert_response :success + assert_select 'input[name=type][value=?]', 'TimeEntryQuery' + end + def test_create_project_public_query @request.session[:user_id] = 2 post :create, @@ -263,6 +270,26 @@ class QueriesControllerTest < ActionController::TestCase assert_equal Query::VISIBILITY_PUBLIC, query.visibility end + def test_create_project_public_time_entry_query + @request.session[:user_id] = 2 + + q = new_record(TimeEntryQuery) do + post :create, + :project_id => 'ecookbook', + :type => 'TimeEntryQuery', + :default_columns => '1', + :f => ["spent_on"], + :op => {"spent_on" => "="}, + :v => { "spent_on" => ["2016-07-14"]}, + :query => {"name" => "test_new_project_public_query", "visibility" => "2"} + end + + assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :query_id => q.id + assert q.is_public? + assert q.has_default_columns? + assert q.valid? + end + def test_edit_global_public_query @request.session[:user_id] = 1 get :edit, :id => 4 diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index c3e96793d..5ee683f4c 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -759,6 +759,16 @@ class TimelogControllerTest < ActionController::TestCase assert_equal values.sort, values end + def test_index_with_query + query = TimeEntryQuery.new(:project_id => 1, :name => 'Time Entry Query', :visibility => 2) + query.save! + @request.session[:user_id] = 2 + + get :index, :project_id => 'ecookbook', :query_id => query.id + assert_response :success + assert_select 'h2', :text => query.name + end + def test_index_atom_feed get :index, :project_id => 1, :format => 'atom' assert_response :success |