diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-04-08 14:17:22 +0300 |
---|---|---|
committer | Alexandru Croitor <acroitor@gitlab.com> | 2019-05-15 10:15:16 +0300 |
commit | 5ec28dc387fb4adc3c5b65ac47819a8663186954 (patch) | |
tree | 4e40a2bf57265d1613ab207e18ab45ee2c4195a5 /spec/support/shared_examples | |
parent | 6bf5af2acd5e046d4235dee6473c214e91d86379 (diff) | |
download | gitlab-ce-5ec28dc387fb4adc3c5b65ac47819a8663186954.tar.gz |
Changes to issues api
When issues_controller endpoint was used for search, the parameters
passed to the controller were slightly different then the ones
passed to API. Because the searchbar UI is reused in different
places and builds the parameters passed to request in same way
we need to account for old parameter names.
Add issues_statistics api endpoints
Adds issue_statistics api endpoints for issue lists and returns
counts of issues for all, closed and opened states.
Expose more label attributes based on a param
When requesting issues list through API expose more attributes
for labels, like color, description if with_labels_data param is
being passed, avoiding this way to change response schema for users
that already use API.
https://gitlab.com/gitlab-org/gitlab-ce/issues/57402
Diffstat (limited to 'spec/support/shared_examples')
-rw-r--r-- | spec/support/shared_examples/requests/api/issues_shared_example_spec.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/api/issues_shared_example_spec.rb b/spec/support/shared_examples/requests/api/issues_shared_example_spec.rb new file mode 100644 index 00000000000..2454b1a9761 --- /dev/null +++ b/spec/support/shared_examples/requests/api/issues_shared_example_spec.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +shared_examples 'labeled issues with labels and label_name params' do + shared_examples 'returns label names' do + it 'returns label names' do + expect_paginated_array_response(issue.id) + expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title]) + end + end + + shared_examples 'returns basic label entity' do + it 'returns basic label entity' do + expect_paginated_array_response(issue.id) + expect(json_response.first['labels'].pluck('name')).to eq([label_c.title, label_b.title, label.title]) + expect(json_response.first['labels'].first).to match_schema('/public_api/v4/label_basic') + end + end + + context 'array of labeled issues when all labels match' do + let(:params) { { labels: "#{label.title},#{label_b.title},#{label_c.title}" } } + + it_behaves_like 'returns label names' + end + + context 'array of labeled issues when all labels match with labels param as array' do + let(:params) { { labels: [label.title, label_b.title, label_c.title] } } + + it_behaves_like 'returns label names' + end + + context 'array of labeled issues when all labels match the label_name param' do + let(:params) { { label_name: "#{label.title},#{label_b.title},#{label_c.title}" } } + + it_behaves_like 'returns label names' + end + + context 'array of labeled issues when all labels match with label_name param as array' do + let(:params) { { label_name: [label.title, label_b.title, label_c.title] } } + + it_behaves_like 'returns label names' + end + + context 'with labels data' do + context 'array of labeled issues when all labels match' do + let(:params) { { labels: "#{label.title},#{label_b.title},#{label_c.title}", with_labels_data: true } } + + it_behaves_like 'returns basic label entity' + end + + context 'array of labeled issues when all labels match with labels param as array' do + let(:params) { { labels: [label.title, label_b.title, label_c.title], with_labels_data: true } } + + it_behaves_like 'returns basic label entity' + end + + context 'array of labeled issues when all labels match the label_name param' do + let(:params) { { label_name: "#{label.title},#{label_b.title},#{label_c.title}", with_labels_data: true } } + + it_behaves_like 'returns basic label entity' + end + + context 'array of labeled issues when all labels match with label_name param as array' do + let(:params) { { label_name: [label.title, label_b.title, label_c.title], with_labels_data: true } } + + it_behaves_like 'returns basic label entity' + end + end +end |