mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-23 17:01:13 +00:00
Fix sort projects table by custom field (#32769).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@19421 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d618229f09
commit
a853fc0e73
@ -70,7 +70,7 @@ class ProjectQuery < Query
|
|||||||
return @available_columns if @available_columns
|
return @available_columns if @available_columns
|
||||||
@available_columns = self.class.available_columns.dup
|
@available_columns = self.class.available_columns.dup
|
||||||
@available_columns += ProjectCustomField.visible.
|
@available_columns += ProjectCustomField.visible.
|
||||||
map {|cf| QueryAssociationCustomFieldColumn.new(:project, cf) }
|
map {|cf| QueryCustomFieldColumn.new(cf) }
|
||||||
@available_columns
|
@available_columns
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_index_as_list_should_format_column_value
|
def test_index_as_list_should_format_column_value
|
||||||
get :index, :params => {
|
get :index, :params => {
|
||||||
:c => ['name', 'status', 'short_description', 'homepage', 'parent_id', 'identifier', 'is_public', 'created_on', 'project.cf_3'],
|
:c => ['name', 'status', 'short_description', 'homepage', 'parent_id', 'identifier', 'is_public', 'created_on', 'cf_3'],
|
||||||
:display_type => 'list'
|
:display_type => 'list'
|
||||||
}
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -111,7 +111,7 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
assert_select 'td.identifier', :text => 'ecookbook'
|
assert_select 'td.identifier', :text => 'ecookbook'
|
||||||
assert_select 'td.is_public', :text => 'Yes'
|
assert_select 'td.is_public', :text => 'Yes'
|
||||||
assert_select 'td.created_on', :text => format_time(project.created_on)
|
assert_select 'td.created_on', :text => format_time(project.created_on)
|
||||||
assert_select 'td.project_cf_3.list', :text => 'Stable'
|
assert_select 'td.cf_3.list', :text => 'Stable'
|
||||||
end
|
end
|
||||||
assert_select 'tr[id=?]', 'project-4' do
|
assert_select 'tr[id=?]', 'project-4' do
|
||||||
assert_select 'td.parent_id a[href=?]', '/projects/ecookbook', :text => 'eCookbook'
|
assert_select 'td.parent_id a[href=?]', '/projects/ecookbook', :text => 'eCookbook'
|
||||||
@ -207,6 +207,29 @@ class ProjectsControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_index_sort_by_custom_field
|
||||||
|
@request.session[:user_id] = 1
|
||||||
|
|
||||||
|
cf = ProjectCustomField.find(3)
|
||||||
|
CustomValue.create!(:custom_field => cf, :customized => Project.find(2), :value => 'Beta')
|
||||||
|
|
||||||
|
get(
|
||||||
|
:index,
|
||||||
|
:params => {
|
||||||
|
:display_type => 'list',
|
||||||
|
:c => ['name', 'identifier', 'cf_3'],
|
||||||
|
:set_filter => 1,
|
||||||
|
:sort => "cf_#{cf.id}:asc"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
assert_equal(
|
||||||
|
['Beta', 'Stable'],
|
||||||
|
columns_values_in_list('cf_3').reject {|p| p.empty?}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def test_autocomplete_js
|
def test_autocomplete_js
|
||||||
get(
|
get(
|
||||||
:autocomplete,
|
:autocomplete,
|
||||||
|
|||||||
@ -58,6 +58,6 @@ class ProjectQueryTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_available_columns_should_include_project_custom_fields
|
def test_available_columns_should_include_project_custom_fields
|
||||||
query = ProjectQuery.new
|
query = ProjectQuery.new
|
||||||
assert_include :"project.cf_3", query.available_columns.map(&:name)
|
assert_include :cf_3, query.available_columns.map(&:name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user