summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
authorLee Tickett <lee@tickett.net>2019-06-24 12:18:40 +0000
committerKamil TrzciƄski <ayufan@ayufan.eu>2019-06-24 12:18:40 +0000
commitec66f1b5ca20764abe21524792480755b614dbc7 (patch)
tree3ec0bcd669e9d015687effe037c18a3acf389952 /spec/requests
parentcf137da316175ed43a980f57e22a81c537a54169 (diff)
downloadgitlab-ce-ec66f1b5ca20764abe21524792480755b614dbc7.tar.gz
Add name & search parameters to project environments API
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/environments_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb
index 8fc7fdc8632..745f3c55ac8 100644
--- a/spec/requests/api/environments_spec.rb
+++ b/spec/requests/api/environments_spec.rb
@@ -34,6 +34,47 @@ describe API::Environments do
expect(json_response.first['project'].keys).to contain_exactly(*project_data_keys)
expect(json_response.first).not_to have_key("last_deployment")
end
+
+ context 'when filtering' do
+ let!(:environment2) { create(:environment, project: project) }
+
+ it 'returns environment by name' do
+ get api("/projects/#{project.id}/environments?name=#{environment.name}", user)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(1)
+ expect(json_response.first['name']).to eq(environment.name)
+ end
+
+ it 'returns no environment by non-existent name' do
+ get api("/projects/#{project.id}/environments?name=test", user)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(0)
+ end
+
+ it 'returns environments by name_like' do
+ get api("/projects/#{project.id}/environments?search=envir", user)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(2)
+ end
+
+ it 'returns no environment by non-existent name_like' do
+ get api("/projects/#{project.id}/environments?search=test", user)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.size).to eq(0)
+ end
+ end
end
context 'as non member' do