summaryrefslogtreecommitdiff
path: root/spec/requests/api/pipelines_spec.rb
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-03-15 00:10:37 +0900
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-03 02:11:51 +0900
commit2075d7ce52ea9d5885fb1bb1ca70eee2e7898c31 (patch)
tree6468811c4265e1ca27d5ef1903b1798236d79999 /spec/requests/api/pipelines_spec.rb
parent2894f293a28f06d22c392a6bc2bf19403b496fe0 (diff)
downloadgitlab-ce-2075d7ce52ea9d5885fb1bb1ca70eee2e7898c31.tar.gz
Unveil iteration
Diffstat (limited to 'spec/requests/api/pipelines_spec.rb')
-rw-r--r--spec/requests/api/pipelines_spec.rb39
1 files changed, 29 insertions, 10 deletions
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb
index e5f1765490b..c1077368559 100644
--- a/spec/requests/api/pipelines_spec.rb
+++ b/spec/requests/api/pipelines_spec.rb
@@ -43,24 +43,43 @@ describe API::Pipelines do
end
context 'when scope is passed' do
- %w[running pending finished branches tags].each do |target|
+ %w[running pending].each do |target|
it "returns only scope=#{target} pipelines" do
get api("/projects/#{project.id}/pipelines?scope=#{target}", user)
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.count).to be > 0
- if target == 'running' || target == 'pending'
- json_response.each { |r| expect(r['status']).to eq(target) }
- elsif target == 'finished'
- json_response.each { |r| expect(r['status']).to be_in(%w[success failed canceled]) }
- elsif target == 'branches'
- expect(json_response.last['sha']).to eq(Ci::Pipeline.where(tag: false).last.sha)
- elsif target == 'tags'
- expect(json_response.last['sha']).to eq(Ci::Pipeline.where(tag: true).last.sha)
- end
+ json_response.each { |r| expect(r['status']).to eq(target) }
end
end
+
+ it "returns only scope=finished pipelines" do
+ get api("/projects/#{project.id}/pipelines?scope=finished", user)
+
+ expect(response).to have_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response.count).to be > 0
+ json_response.each { |r| expect(r['status']).to be_in(%w[success failed canceled]) }
+ end
+
+ it "returns only scope=branches pipelines" do
+ get api("/projects/#{project.id}/pipelines?scope=branches", user)
+
+ expect(response).to have_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response.count).to be > 0
+ expect(json_response.last['sha']).to eq(Ci::Pipeline.where(tag: false).last.sha)
+ end
+
+ it "returns only scope=tags pipelines" do
+ get api("/projects/#{project.id}/pipelines?scope=tags", user)
+
+ expect(response).to have_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response.count).to be > 0
+ expect(json_response.last['sha']).to eq(Ci::Pipeline.where(tag: true).last.sha)
+ end
end
context 'when status is passed' do