Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAlexandru Croitor <acroitor@gitlab.com>2019-04-24 16:08:14 +0300
committerAlexandru Croitor <acroitor@gitlab.com>2019-05-15 10:15:17 +0300
commitf117c032ac6c414e6c1dfeab98184363c1f61608 (patch)
treed3c5beb5363112dccbd2fa0cbcff573121eafda3 /spec
parenta4fbf39eca4518598e893f6f1b81b8b69927c6f9 (diff)
Add params validations and remove extra params support
Remove label_name and milestone_title params support Add mutually_exclusive validation for author_id and author_username Add mutually_exclusive validation for assignee_id and assignee_username Add validation to allow single value for asignee_username on CE Add separate issue_stats_params helper for statistics params and reuse in issues_params.
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/issues/get_group_issues_spec.rb26
-rw-r--r--spec/requests/api/issues/get_project_issues_spec.rb26
-rw-r--r--spec/requests/api/issues/issues_spec.rb27
-rw-r--r--spec/support/shared_examples/requests/api/issues_shared_example_spec.rb26
4 files changed, 73 insertions, 32 deletions
diff --git a/spec/requests/api/issues/get_group_issues_spec.rb b/spec/requests/api/issues/get_group_issues_spec.rb
index aafe0f56dfb..8b02cf56e9f 100644
--- a/spec/requests/api/issues/get_group_issues_spec.rb
+++ b/spec/requests/api/issues/get_group_issues_spec.rb
@@ -619,11 +619,33 @@ describe API::Issues do
let!(:issue2) { create(:issue, author: user2, project: group_project, created_at: 2.days.ago) }
let!(:issue3) { create(:issue, author: user2, assignees: [assignee, another_assignee], project: group_project, created_at: 1.day.ago) }
- it 'returns issues with multiple assignees' do
- get api("/groups/#{group.id}/issues", user), params: { assignee_username: [assignee.username, another_assignee.username] }
+ it 'returns issues with by assignee_username' do
+ get api(base_url, user), params: { assignee_username: [assignee.username], scope: 'all' }
+ expect(issue3.reload.assignees.pluck(:id)).to match_array([assignee.id, another_assignee.id])
expect_paginated_array_response([issue3.id, group_confidential_issue.id])
end
+
+ it 'returns issues by assignee_username as string' do
+ get api(base_url, user), params: { assignee_username: assignee.username, scope: 'all' }
+
+ expect(issue3.reload.assignees.pluck(:id)).to match_array([assignee.id, another_assignee.id])
+ expect_paginated_array_response([issue3.id, group_confidential_issue.id])
+ end
+
+ it 'returns error when multiple assignees are passed' do
+ get api(base_url, user), params: { assignee_username: [assignee.username, another_assignee.username], scope: 'all' }
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response["error"]).to include("allows one value, but found 2")
+ end
+
+ it 'returns error when assignee_username and assignee_id are passed together' do
+ get api(base_url, user), params: { assignee_username: [assignee.username], assignee_id: another_assignee.id, scope: 'all' }
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response["error"]).to include("mutually exclusive")
+ end
end
end
end
diff --git a/spec/requests/api/issues/get_project_issues_spec.rb b/spec/requests/api/issues/get_project_issues_spec.rb
index afd5bd2257f..a07d7673345 100644
--- a/spec/requests/api/issues/get_project_issues_spec.rb
+++ b/spec/requests/api/issues/get_project_issues_spec.rb
@@ -490,11 +490,33 @@ describe API::Issues do
let!(:issue2) { create(:issue, author: user2, project: project, created_at: 2.days.ago) }
let!(:issue3) { create(:issue, author: user2, assignees: [assignee, another_assignee], project: project, created_at: 1.day.ago) }
- it 'returns issues with multiple assignees' do
- get api("#{base_url}/issues", user), params: { assignee_username: [assignee.username, another_assignee.username] }
+ it 'returns issues by assignee_username' do
+ get api("/issues", user), params: { assignee_username: [assignee.username], scope: 'all' }
+ expect(issue3.reload.assignees.pluck(:id)).to match_array([assignee.id, another_assignee.id])
expect_paginated_array_response([confidential_issue.id, issue3.id])
end
+
+ it 'returns issues by assignee_username as string' do
+ get api("/issues", user), params: { assignee_username: assignee.username, scope: 'all' }
+
+ expect(issue3.reload.assignees.pluck(:id)).to match_array([assignee.id, another_assignee.id])
+ expect_paginated_array_response([confidential_issue.id, issue3.id])
+ end
+
+ it 'returns error when multiple assignees are passed' do
+ get api("/issues", user), params: { assignee_username: [assignee.username, another_assignee.username], scope: 'all' }
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response["error"]).to include("allows one value, but found 2")
+ end
+
+ it 'returns error when assignee_username and assignee_id are passed together' do
+ get api("/issues", user), params: { assignee_username: [assignee.username], assignee_id: another_assignee.id, scope: 'all' }
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response["error"]).to include("mutually exclusive")
+ end
end
end
diff --git a/spec/requests/api/issues/issues_spec.rb b/spec/requests/api/issues/issues_spec.rb
index 6f916212672..24c53d9c68f 100644
--- a/spec/requests/api/issues/issues_spec.rb
+++ b/spec/requests/api/issues/issues_spec.rb
@@ -691,12 +691,33 @@ describe API::Issues do
let!(:issue2) { create(:issue, author: user2, project: project, created_at: 2.days.ago) }
let!(:issue3) { create(:issue, author: user2, assignees: [assignee, another_assignee], project: project, created_at: 1.day.ago) }
- it 'returns issues with multiple assignees' do
- get api("/issues", user), params: { assignee_username: [assignee.username, another_assignee.username], scope: 'all' }
+ it 'returns issues with by assignee_username' do
+ get api("/issues", user), params: { assignee_username: [assignee.username], scope: 'all' }
+
+ expect(issue3.reload.assignees.pluck(:id)).to match_array([assignee.id, another_assignee.id])
+ expect_paginated_array_response([confidential_issue.id, issue3.id])
+ end
+
+ it 'returns issues by assignee_username as string' do
+ get api("/issues", user), params: { assignee_username: assignee.username, scope: 'all' }
- expect(issue3.reload.assignees).to eq([assignee, another_assignee])
+ expect(issue3.reload.assignees.pluck(:id)).to match_array([assignee.id, another_assignee.id])
expect_paginated_array_response([confidential_issue.id, issue3.id])
end
+
+ it 'returns error when multiple assignees are passed' do
+ get api("/issues", user), params: { assignee_username: [assignee.username, another_assignee.username], scope: 'all' }
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response["error"]).to include("allows one value, but found 2")
+ end
+
+ it 'returns error when assignee_username and assignee_id are passed together' do
+ get api("/issues", user), params: { assignee_username: [assignee.username], assignee_id: another_assignee.id, scope: 'all' }
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response["error"]).to include("mutually exclusive")
+ end
end
end
end
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
index 2454b1a9761..d1c8e2208a3 100644
--- a/spec/support/shared_examples/requests/api/issues_shared_example_spec.rb
+++ b/spec/support/shared_examples/requests/api/issues_shared_example_spec.rb
@@ -28,19 +28,7 @@ shared_examples 'labeled issues with labels and label_name params' do
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 'when with_labels_data provided' 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 } }
@@ -52,17 +40,5 @@ shared_examples 'labeled issues with labels and label_name params' do
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