Patch #43534 » 43534-v2.patch
| app/assets/javascripts/application-legacy.js | ||
|---|---|---|
| 175 | 175 |
if (!filterOptions) return; |
| 176 | 176 | |
| 177 | 177 |
if (filterOptions['remote'] && filterOptions['values'] == null) {
|
| 178 |
$.getJSON(filtersUrl, {'name': field}).done(function(data) {
|
|
| 178 |
var form = $('#query_form').filter('form').first();
|
|
| 179 |
var data = form.length ? form.serializeArray() : []; |
|
| 180 |
data.push({name: 'name', value: field});
|
|
| 181 | ||
| 182 |
$.getJSON(filtersUrl, data).done(function(data) {
|
|
| 179 | 183 |
filterOptions['values'] = data; |
| 180 | 184 |
addFilter(field, operator, values) ; |
| 181 | 185 |
}); |
| app/controllers/queries_controller.rb | ||
|---|---|---|
| 95 | 95 |
if params[:project_id].present? |
| 96 | 96 |
q.project = Project.find(params[:project_id]) |
| 97 | 97 |
end |
| 98 |
q.build_from_params(params) |
|
| 98 | 99 | |
| 99 | 100 |
unless User.current.allowed_to?(q.class.view_permission, q.project, :global => true) |
| 100 | 101 |
raise Unauthorized |
| app/models/query.rb | ||
|---|---|---|
| 648 | 648 |
def fixed_version_values |
| 649 | 649 |
versions = [] |
| 650 | 650 |
if project |
| 651 |
versions = project.shared_versions.to_a |
|
| 651 |
versions = |
|
| 652 |
Version.visible. |
|
| 653 |
where(project_statement). |
|
| 654 |
includes(:project). |
|
| 655 |
references(:project). |
|
| 656 |
distinct. |
|
| 657 |
to_a |
|
| 652 | 658 |
else |
| 653 | 659 |
versions = Version.visible.to_a |
| 654 | 660 |
end |
| test/functional/queries_controller_test.rb | ||
|---|---|---|
| 823 | 823 |
assert_include ["eCookbook - 2.0", "3", "open"], json |
| 824 | 824 |
end |
| 825 | 825 | |
| 826 |
def test_filter_should_build_query_from_params |
|
| 827 |
version = Version.create!(:project => Project.find(3), :name => 'Local subproject', :status => 'open') |
|
| 828 | ||
| 829 |
@request.session[:user_id] = 2 |
|
| 830 |
get( |
|
| 831 |
:filter, |
|
| 832 |
:params => {
|
|
| 833 |
:project_id => 1, |
|
| 834 |
:name => 'fixed_version_id', |
|
| 835 |
:set_filter => '1', |
|
| 836 |
:f => ['subproject_id'], |
|
| 837 |
:op => {'subproject_id' => '='},
|
|
| 838 |
:v => {'subproject_id' => [version.project_id.to_s]}
|
|
| 839 |
} |
|
| 840 |
) |
|
| 841 | ||
| 842 |
assert_response :success |
|
| 843 |
assert_equal 'application/json', response.media_type |
|
| 844 |
json = ActiveSupport::JSON.decode(response.body) |
|
| 845 |
assert_include ["#{version.project.name} - #{version.name}", version.id.to_s, "open"], json
|
|
| 846 |
end |
|
| 847 | ||
| 826 | 848 |
def test_version_filter_time_entries_with_project_id_should_return_filter_values |
| 827 | 849 |
@request.session[:user_id] = 2 |
| 828 | 850 |
get( |
| test/unit/query_test.rb | ||
|---|---|---|
| 161 | 161 |
assert_include subproject_version.id.to_s, filter[:values].map(&:second) |
| 162 | 162 |
end |
| 163 | 163 | |
| 164 |
def test_fixed_version_filter_should_include_subproject_versions_when_displaying_subproject_issues |
|
| 165 |
with_settings :display_subprojects_issues => '1' do |
|
| 166 |
subproject = Project.find(3) |
|
| 167 |
version = Version.create!(:project => subproject, :name => 'Unshared subproject version') |
|
| 168 | ||
| 169 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 170 |
filter = query.available_filters["fixed_version_id"] |
|
| 171 | ||
| 172 |
assert_not_nil filter |
|
| 173 |
assert_include version.id.to_s, filter[:values].map(&:second) |
|
| 174 |
end |
|
| 175 |
end |
|
| 176 | ||
| 177 |
def test_fixed_version_filter_should_respect_selected_subprojects |
|
| 178 |
subproject_1 = Project.find(3) |
|
| 179 |
subproject_2 = Project.find(4) |
|
| 180 |
version_1 = Version.create!(:project => subproject_1, :name => 'Subproject 1 version') |
|
| 181 |
version_2 = Version.create!(:project => subproject_2, :name => 'Subproject 2 version') |
|
| 182 | ||
| 183 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 184 |
query.add_filter('subproject_id', '=', [subproject_1.id.to_s])
|
|
| 185 |
filter = query.available_filters["fixed_version_id"] |
|
| 186 | ||
| 187 |
assert_not_nil filter |
|
| 188 |
values = filter[:values].map(&:second) |
|
| 189 |
assert_include version_1.id.to_s, values |
|
| 190 |
assert_not_include version_2.id.to_s, values |
|
| 191 |
end |
|
| 192 | ||
| 193 |
def test_fixed_version_filter_should_include_all_subproject_versions_when_filtering_any_subproject |
|
| 194 |
with_settings :display_subprojects_issues => '0' do |
|
| 195 |
subproject = Project.find(3) |
|
| 196 |
version = Version.create!(:project => subproject, :name => 'Any subproject version') |
|
| 197 | ||
| 198 |
query = IssueQuery.new(:project => Project.find(1), :name => '_') |
|
| 199 |
query.add_filter('subproject_id', '*', [''])
|
|
| 200 |
filter = query.available_filters["fixed_version_id"] |
|
| 201 | ||
| 202 |
assert_not_nil filter |
|
| 203 |
assert_include version.id.to_s, filter[:values].map(&:second) |
|
| 204 |
end |
|
| 205 |
end |
|
| 206 | ||
| 164 | 207 |
def test_query_with_multiple_custom_fields |
| 165 | 208 |
query = IssueQuery.find(1) |
| 166 | 209 |
assert query.valid? |
- « Previous
- 1
- 2
- Next »