diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 0846d70..37cd48f 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -21,7 +21,7 @@ class IssueQuery < Query self.view_permission = :view_issues self.available_columns = [ - QueryColumn.new(:id, :sortable => "#{Issue.table_name}.id", :default_order => 'desc', :caption => '#', :frozen => true), + QueryColumn.new(:id, :sortable => "#{Issue.table_name}.id", :default_order => 'desc', :caption => '#'), QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true), QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true), QueryColumn.new(:parent, :sortable => ["#{Issue.table_name}.root_id", "#{Issue.table_name}.lft ASC"], :default_order => 'desc', :caption => :field_parent_issue), diff --git a/config/settings.yml b/config/settings.yml index 807f9b7..11db558 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -191,6 +191,7 @@ mail_handler_api_key: issue_list_default_columns: serialized: true default: + - id - tracker - status - priority diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 142ccc3..d01fc95 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -217,7 +217,7 @@ class IssuesControllerTest < Redmine::ControllerTest :f => [filter_name], :op => {filter_name => '='}, :v => {filter_name => ['Foo']}, - :c => ['project'] + :c => ['id', 'project'] assert_response :success assert_equal [3, 5], issues_in_list.map(&:project_id).uniq.sort @@ -455,10 +455,10 @@ class IssuesControllerTest < Redmine::ControllerTest assert_response :success assert_equal 'text/csv; header=present', @response.content_type - assert response.body.starts_with?("#,") + assert response.body.starts_with?("Project,") lines = response.body.chomp.split("\n") - # default columns + id and project - assert_equal Setting.issue_list_default_columns.size + 2, lines[0].split(',').size + # default columns + project + assert_equal Setting.issue_list_default_columns.size + 1, lines[0].split(',').size end def test_index_csv_with_project @@ -495,7 +495,7 @@ class IssuesControllerTest < Redmine::ControllerTest issue = Issue.create!(:project_id => 1, :tracker_id => 1, :subject => 'test_index_csv_with_spent_time_column', :author_id => 2) TimeEntry.create!(:project => issue.project, :issue => issue, :hours => 7.33, :user => User.find(2), :spent_on => Date.today) - get :index, :format => 'csv', :set_filter => '1', :c => %w(subject spent_hours) + get :index, :format => 'csv', :set_filter => '1', :c => %w(id subject spent_hours) assert_response :success assert_equal 'text/csv; header=present', @response.content_type lines = @response.body.chomp.split("\n") @@ -549,7 +549,7 @@ class IssuesControllerTest < Redmine::ControllerTest child = Issue.generate!(:parent_issue_id => parent.id) with_settings :default_language => 'en' do - get :index, :format => 'csv', :c => %w(parent) + get :index, :format => 'csv', :c => %w(id parent) end lines = response.body.split("\n") assert_include "#{child.id},#{parent.id}", lines @@ -561,8 +561,8 @@ class IssuesControllerTest < Redmine::ControllerTest str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5') issue = Issue.generate!(:subject => str_utf8) - get :index, :project_id => 1, - :f => ['subject'], + get :index, :project_id => 1, + :f => ['subject'], :op => '=', :values => [str_utf8], :format => 'csv' assert_equal 'text/csv; header=present', @response.content_type @@ -580,10 +580,10 @@ class IssuesControllerTest < Redmine::ControllerTest str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8') issue = Issue.generate!(:subject => str_utf8) - get :index, :project_id => 1, - :f => ['subject'], + get :index, :project_id => 1, + :f => ['subject'], :op => '=', :values => [str_utf8], - :c => ['status', 'subject'], + :c => ['id', 'status', 'subject'], :format => 'csv', :set_filter => 1 assert_equal 'text/csv; header=present', @response.content_type @@ -603,10 +603,10 @@ class IssuesControllerTest < Redmine::ControllerTest str1 = "test_index_csv_tw" issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5') - get :index, :project_id => 1, - :f => ['subject'], + get :index, :project_id => 1, + :f => ['subject'], :op => '=', :values => [str1], - :c => ['estimated_hours', 'subject'], + :c => ['id', 'estimated_hours', 'subject'], :format => 'csv', :set_filter => 1 assert_equal 'text/csv; header=present', @response.content_type @@ -620,10 +620,10 @@ class IssuesControllerTest < Redmine::ControllerTest str1 = "test_index_csv_fr" issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5') - get :index, :project_id => 1, - :f => ['subject'], + get :index, :project_id => 1, + :f => ['subject'], :op => '=', :values => [str1], - :c => ['estimated_hours', 'subject'], + :c => ['id', 'estimated_hours', 'subject'], :format => 'csv', :set_filter => 1 assert_equal 'text/csv; header=present', @response.content_type @@ -694,34 +694,34 @@ class IssuesControllerTest < Redmine::ControllerTest Setting.issue_list_default_columns = %w(subject author) get :index, :sort => 'tracker' end - + def test_index_sort_by_assigned_to get :index, :sort => 'assigned_to' assert_response :success - + assignees = issues_in_list.map(&:assigned_to).compact assert_equal assignees.sort, assignees assert_select 'table.issues.sort-by-assigned-to.sort-asc' end - + def test_index_sort_by_assigned_to_desc get :index, :sort => 'assigned_to:desc' assert_response :success - + assignees = issues_in_list.map(&:assigned_to).compact assert_equal assignees.sort.reverse, assignees assert_select 'table.issues.sort-by-assigned-to.sort-desc' end - + def test_index_group_by_assigned_to get :index, :group_by => 'assigned_to', :sort => 'priority' assert_response :success end - + def test_index_sort_by_author get :index, :sort => 'author', :c => ['author'] assert_response :success - + authors = issues_in_list.map(&:author) assert_equal authors.sort, authors end @@ -729,30 +729,30 @@ class IssuesControllerTest < Redmine::ControllerTest def test_index_sort_by_author_desc get :index, :sort => 'author:desc' assert_response :success - + authors = issues_in_list.map(&:author) assert_equal authors.sort.reverse, authors end - + def test_index_group_by_author get :index, :group_by => 'author', :sort => 'priority' assert_response :success end - + def test_index_sort_by_spent_hours get :index, :sort => 'spent_hours:desc' assert_response :success hours = issues_in_list.map(&:spent_hours) assert_equal hours.sort.reverse, hours end - + def test_index_sort_by_total_spent_hours get :index, :sort => 'total_spent_hours:desc' assert_response :success hours = issues_in_list.map(&:total_spent_hours) assert_equal hours.sort.reverse, hours end - + def test_index_sort_by_total_estimated_hours get :index, :sort => 'total_estimated_hours:desc' assert_response :success @@ -767,7 +767,7 @@ class IssuesControllerTest < Redmine::ControllerTest CustomValue.create!(:custom_field => cf, :customized => Issue.find(3), :value => '3') CustomValue.create!(:custom_field => cf, :customized => Issue.find(5), :value => '') - get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id" + get :index, :project_id => 1, :c => ["id"], :set_filter => 1, :sort => "cf_#{cf.id},id" assert_response :success assert_equal [2, 3, 1], issues_in_list.select {|issue| issue.custom_field_value(cf).present?}.map(&:id) @@ -778,8 +778,8 @@ class IssuesControllerTest < Redmine::ControllerTest get :index, :set_filter => 1, :c => columns assert_response :success - # query should use specified columns + id and checkbox - assert_select 'table.issues thead th', columns.size + 2 + # query should use specified columns + checkbox + assert_select 'table.issues thead th', columns.size + 1 # columns should be stored in session assert_kind_of Hash, session[:issue_query] @@ -799,7 +799,7 @@ class IssuesControllerTest < Redmine::ControllerTest get :index, :set_filter => 1 # query should use specified columns - assert_equal ["#", "Project", "Tracker", "Subject", "Assignee"], columns_in_issues_list + assert_equal ["Project", "Tracker", "Subject", "Assignee"], columns_in_issues_list end def test_index_without_project_and_explicit_default_columns_should_not_add_project_column @@ -816,12 +816,12 @@ class IssuesControllerTest < Redmine::ControllerTest with_settings :issue_list_default_columns => columns do get :index, :project_id => 1, :set_filter => 1 - assert_equal ["#", "Assignee", "Subject", "Status", "Tracker"], columns_in_issues_list + assert_equal ["Assignee", "Subject", "Status", "Tracker"], columns_in_issues_list end end def test_index_with_custom_field_column - columns = %w(tracker subject cf_2) + columns = %w(id tracker subject cf_2) get :index, :set_filter => 1, :c => columns assert_response :success @@ -915,7 +915,7 @@ class IssuesControllerTest < Redmine::ControllerTest IssueRelation.create!(:relation_type => "blocks", :issue_from => Issue.find(1), :issue_to => Issue.find(11)) IssueRelation.create!(:relation_type => "blocks", :issue_from => Issue.find(12), :issue_to => Issue.find(2)) - get :index, :set_filter => 1, :c => %w(subject relations) + get :index, :set_filter => 1, :c => %w(id subject relations) assert_response :success assert_select "tr#issue-1 td.relations" do assert_select "span", 3 @@ -931,7 +931,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select "span", 0 end - get :index, :set_filter => 1, :c => %w(relations), :format => 'csv' + get :index, :set_filter => 1, :c => %w(id relations), :format => 'csv' assert_response :success assert_equal 'text/csv; header=present', response.content_type lines = response.body.chomp.split("\n") @@ -939,7 +939,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_include '2,Blocked by #12', lines assert_include '3,""', lines - get :index, :set_filter => 1, :c => %w(subject relations), :format => 'pdf' + get :index, :set_filter => 1, :c => %w(id subject relations), :format => 'pdf' assert_response :success assert_equal 'application/pdf', response.content_type end @@ -947,8 +947,8 @@ class IssuesControllerTest < Redmine::ControllerTest def test_index_with_description_column get :index, :set_filter => 1, :c => %w(subject description) - assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject - assert_select 'td.description[colspan="3"]', :text => 'Unable to print recipes' + assert_select 'table.issues thead th', 2 # columns: chekbox subject + assert_select 'td.description[colspan="2"]', :text => 'Unable to print recipes' get :index, :set_filter => 1, :c => %w(subject description), :format => 'pdf' assert_response :success @@ -1089,7 +1089,7 @@ class IssuesControllerTest < Redmine::ControllerTest def test_index_should_not_include_new_issue_tab_for_project_without_trackers with_settings :new_item_menu_tab => '1' do Project.find(1).trackers.clear - + @request.session[:user_id] = 2 get :index, :project_id => 1 assert_select '#main-menu a.new-issue', 0 @@ -1101,7 +1101,7 @@ class IssuesControllerTest < Redmine::ControllerTest role = Role.find(1) role.remove_permission! :add_issues role.add_permission! :copy_issues - + @request.session[:user_id] = 2 get :index, :project_id => 1 assert_select '#main-menu a.new-issue', 0 @@ -1377,7 +1377,7 @@ class IssuesControllerTest < Redmine::ControllerTest def test_show_should_display_prev_next_links_with_query_and_sort_on_association @request.session[:query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil} - + %w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort| @request.session['issues_index_sort'] = assoc_sort @@ -1610,7 +1610,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_show_export_to_pdf - issue = Issue.find(3) + issue = Issue.find(3) assert issue.relations.select{|r| r.other_issue(issue).visible?}.present? get :show, :id => 3, :format => 'pdf' assert_response :success @@ -2021,7 +2021,7 @@ class IssuesControllerTest < Redmine::ControllerTest get :new, :project_id => 'invalid' assert_response 404 end - + def test_new_with_parent_id_should_only_propose_valid_trackers @request.session[:user_id] = 2 t = Tracker.find(3) @@ -2570,7 +2570,7 @@ class IssuesControllerTest < Redmine::ControllerTest :custom_field_values => {'2' => 'Value for field 2'}} end assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id - + assert_equal 1, ActionMailer::Base.deliveries.size end end @@ -2844,7 +2844,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook' assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore' end - assert_select 'input[name=?][value=?]', 'issue[subject]', orig.subject + assert_select 'input[name=?][value=?]', 'issue[subject]', orig.subject assert_select 'input[name=copy_from][value="1"]' end end @@ -3119,7 +3119,7 @@ class IssuesControllerTest < Redmine::ControllerTest def test_get_edit_should_display_the_time_entry_form_with_log_time_permission @request.session[:user_id] = 2 Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time] - + get :edit, :id => 1 assert_select 'input[name=?]', 'time_entry[hours]' end @@ -3127,7 +3127,7 @@ class IssuesControllerTest < Redmine::ControllerTest def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission @request.session[:user_id] = 2 Role.find_by_name('Manager').remove_permission! :log_time - + get :edit, :id => 1 assert_select 'input[name=?]', 'time_entry[hours]', 0 end @@ -3772,7 +3772,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_response :redirect assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id end - + def test_put_update_should_redirect_with_previous_and_next_issue_ids_params @request.session[:user_id] = 2 @@ -3826,17 +3826,17 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'select[name=?]', 'issue[project_id]' assert_select 'input[name=?]', 'issue[parent_issue_id]' - + # Project specific custom field, date type field = CustomField.find(9) assert !field.is_for_all? assert_equal 'date', field.field_format assert_select 'input[name=?]', 'issue[custom_field_values][9]' - + # System wide custom field assert CustomField.find(1).is_for_all? assert_select 'select[name=?]', 'issue[custom_field_values][1]' - + # Be sure we don't display inactive IssuePriorities assert ! IssuePriority.find(15).active? assert_select 'select[name=?]', 'issue[priority_id]' do @@ -4009,7 +4009,7 @@ class IssuesControllerTest < Redmine::ControllerTest :issue => {:priority_id => '', :assigned_to_id => group.id, :custom_field_values => {'2' => ''}} - + assert_response 302 assert_equal [group, group], Issue.where(:id => [1, 2]).collect {|i| i.assigned_to} end @@ -4315,7 +4315,7 @@ class IssuesControllerTest < Redmine::ControllerTest assert_select 'option[value="2"]' end end - + def test_bulk_copy_to_another_project @request.session[:user_id] = 2 assert_difference 'Issue.count', 2 do @@ -4368,7 +4368,7 @@ class IssuesControllerTest < Redmine::ControllerTest :assigned_to_id => 3) ] assert_difference 'Issue.count', issues.size do - post :bulk_update, :ids => issues.map(&:id), :copy => '1', + post :bulk_update, :ids => issues.map(&:id), :copy => '1', :issue => { :project_id => '', :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' @@ -4396,7 +4396,7 @@ class IssuesControllerTest < Redmine::ControllerTest @request.session[:user_id] = 2 assert_difference 'Issue.count', 2 do assert_no_difference 'Project.find(1).issues.count' do - post :bulk_update, :ids => [1, 2], :copy => '1', + post :bulk_update, :ids => [1, 2], :copy => '1', :issue => { :project_id => '2', :tracker_id => '', :assigned_to_id => '2', :status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31' diff --git a/test/functional/issues_custom_fields_visibility_test.rb b/test/functional/issues_custom_fields_visibility_test.rb index 6ebe0c4..4643152 100644 --- a/test/functional/issues_custom_fields_visibility_test.rb +++ b/test/functional/issues_custom_fields_visibility_test.rb @@ -206,7 +206,7 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest Issue.generate!(:project => p1, :tracker_id => 1, :custom_field_values => {@field2.id => 'ValueC'}) @request.session[:user_id] = user.id - get :index, :c => ["subject", "cf_#{@field2.id}"] + get :index, :c => ["id", "subject", "cf_#{@field2.id}"] assert_select 'td', :text => 'ValueA' assert_select 'td', :text => 'ValueB', :count => 0 assert_select 'td', :text => 'ValueC' diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index 4a88127..218cef8 100644 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -122,7 +122,7 @@ class QueriesControllerTest < Redmine::ControllerTest :operators => {"assigned_to_id" => "=", "status_id" => "o"}, :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, :query => {"name" => "test_new_global_private_query", "visibility" => "0"}, - :c => ["", "tracker", "subject", "priority", "category"] + :c => ["", "id", "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 diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index d6fa254..f62d9f5 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -943,7 +943,7 @@ class QueryTest < ActiveSupport::TestCase def test_filter_on_parent Issue.delete_all parent = Issue.generate_with_descendants! - + query = IssueQuery.new(:name => '_') query.filters = {"parent_id" => {:operator => '=', :values => [parent.id.to_s]}} @@ -973,7 +973,7 @@ class QueryTest < ActiveSupport::TestCase parent = Issue.generate_with_descendants! child, leaf = parent.children.sort_by(&:id) grandchild = child.children.first - + query = IssueQuery.new(:name => '_') query.filters = {"child_id" => {:operator => '=', :values => [grandchild.id.to_s]}} @@ -1037,7 +1037,7 @@ class QueryTest < ActiveSupport::TestCase def test_set_column_names q = IssueQuery.new - q.column_names = ['tracker', :subject, '', 'unknonw_column'] + q.column_names = ['id', 'tracker', :subject, '', 'unknonw_column'] assert_equal [:id, :tracker, :subject], q.columns.collect {|c| c.name} end @@ -1063,7 +1063,7 @@ class QueryTest < ActiveSupport::TestCase def test_inline_and_block_columns q = IssueQuery.new - q.column_names = ['subject', 'description', 'tracker'] + q.column_names = ['id', 'subject', 'description', 'tracker'] assert_equal [:id, :subject, :tracker], q.inline_columns.map(&:name) assert_equal [:description], q.block_columns.map(&:name)