Patch #43534 » 43534-v2.patch
| app/assets/javascripts/application-legacy.js | ||
|---|---|---|
|
if (!filterOptions) return;
|
||
|
if (filterOptions['remote'] && filterOptions['values'] == null) {
|
||
|
$.getJSON(filtersUrl, {'name': field}).done(function(data) {
|
||
|
var form = $('#query_form').filter('form').first();
|
||
|
var data = form.length ? form.serializeArray() : [];
|
||
|
data.push({name: 'name', value: field});
|
||
|
$.getJSON(filtersUrl, data).done(function(data) {
|
||
|
filterOptions['values'] = data;
|
||
|
addFilter(field, operator, values) ;
|
||
|
});
|
||
| app/controllers/queries_controller.rb | ||
|---|---|---|
|
if params[:project_id].present?
|
||
|
q.project = Project.find(params[:project_id])
|
||
|
end
|
||
|
q.build_from_params(params)
|
||
|
unless User.current.allowed_to?(q.class.view_permission, q.project, :global => true)
|
||
|
raise Unauthorized
|
||
| app/models/query.rb | ||
|---|---|---|
|
def fixed_version_values
|
||
|
versions = []
|
||
|
if project
|
||
|
versions = project.shared_versions.to_a
|
||
|
versions =
|
||
|
Version.visible.
|
||
|
where(project_statement).
|
||
|
includes(:project).
|
||
|
references(:project).
|
||
|
distinct.
|
||
|
to_a
|
||
|
else
|
||
|
versions = Version.visible.to_a
|
||
|
end
|
||
| test/functional/queries_controller_test.rb | ||
|---|---|---|
|
assert_include ["eCookbook - 2.0", "3", "open"], json
|
||
|
end
|
||
|
def test_filter_should_build_query_from_params
|
||
|
version = Version.create!(:project => Project.find(3), :name => 'Local subproject', :status => 'open')
|
||
|
@request.session[:user_id] = 2
|
||
|
get(
|
||
|
:filter,
|
||
|
:params => {
|
||
|
:project_id => 1,
|
||
|
:name => 'fixed_version_id',
|
||
|
:set_filter => '1',
|
||
|
:f => ['subproject_id'],
|
||
|
:op => {'subproject_id' => '='},
|
||
|
:v => {'subproject_id' => [version.project_id.to_s]}
|
||
|
}
|
||
|
)
|
||
|
assert_response :success
|
||
|
assert_equal 'application/json', response.media_type
|
||
|
json = ActiveSupport::JSON.decode(response.body)
|
||
|
assert_include ["#{version.project.name} - #{version.name}", version.id.to_s, "open"], json
|
||
|
end
|
||
|
def test_version_filter_time_entries_with_project_id_should_return_filter_values
|
||
|
@request.session[:user_id] = 2
|
||
|
get(
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
assert_include subproject_version.id.to_s, filter[:values].map(&:second)
|
||
|
end
|
||
|
def test_fixed_version_filter_should_include_subproject_versions_when_displaying_subproject_issues
|
||
|
with_settings :display_subprojects_issues => '1' do
|
||
|
subproject = Project.find(3)
|
||
|
version = Version.create!(:project => subproject, :name => 'Unshared subproject version')
|
||
|
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
||
|
filter = query.available_filters["fixed_version_id"]
|
||
|
assert_not_nil filter
|
||
|
assert_include version.id.to_s, filter[:values].map(&:second)
|
||
|
end
|
||
|
end
|
||
|
def test_fixed_version_filter_should_respect_selected_subprojects
|
||
|
subproject_1 = Project.find(3)
|
||
|
subproject_2 = Project.find(4)
|
||
|
version_1 = Version.create!(:project => subproject_1, :name => 'Subproject 1 version')
|
||
|
version_2 = Version.create!(:project => subproject_2, :name => 'Subproject 2 version')
|
||
|
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
||
|
query.add_filter('subproject_id', '=', [subproject_1.id.to_s])
|
||
|
filter = query.available_filters["fixed_version_id"]
|
||
|
assert_not_nil filter
|
||
|
values = filter[:values].map(&:second)
|
||
|
assert_include version_1.id.to_s, values
|
||
|
assert_not_include version_2.id.to_s, values
|
||
|
end
|
||
|
def test_fixed_version_filter_should_include_all_subproject_versions_when_filtering_any_subproject
|
||
|
with_settings :display_subprojects_issues => '0' do
|
||
|
subproject = Project.find(3)
|
||
|
version = Version.create!(:project => subproject, :name => 'Any subproject version')
|
||
|
query = IssueQuery.new(:project => Project.find(1), :name => '_')
|
||
|
query.add_filter('subproject_id', '*', [''])
|
||
|
filter = query.available_filters["fixed_version_id"]
|
||
|
assert_not_nil filter
|
||
|
assert_include version.id.to_s, filter[:values].map(&:second)
|
||
|
end
|
||
|
end
|
||
|
def test_query_with_multiple_custom_fields
|
||
|
query = IssueQuery.find(1)
|
||
|
assert query.valid?
|
||
- « Previous
- 1
- 2
- Next »