Add controller specs for environments index action
This commit is contained in:
parent
bd01a5a47c
commit
4388d90370
1 changed files with 27 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Projects::EnvironmentsController do
|
describe Projects::EnvironmentsController do
|
||||||
|
include ApiHelpers
|
||||||
|
|
||||||
let(:environment) { create(:environment) }
|
let(:environment) { create(:environment) }
|
||||||
let(:project) { environment.project }
|
let(:project) { environment.project }
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
@ -11,6 +13,27 @@ describe Projects::EnvironmentsController do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET index' do
|
||||||
|
context 'when standardrequest has been made' do
|
||||||
|
it 'responds with status code 200' do
|
||||||
|
get :index, environment_params
|
||||||
|
|
||||||
|
expect(response).to be_ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when requesting JSON response' do
|
||||||
|
it 'responds with correct JSON' do
|
||||||
|
get :index, environment_params(format: :json)
|
||||||
|
|
||||||
|
first_environment = json_response.first
|
||||||
|
|
||||||
|
expect(first_environment).not_to be_empty
|
||||||
|
expect(first_environment['name']). to eq environment.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET show' do
|
describe 'GET show' do
|
||||||
context 'with valid id' do
|
context 'with valid id' do
|
||||||
it 'responds with a status code 200' do
|
it 'responds with a status code 200' do
|
||||||
|
@ -48,11 +71,9 @@ describe Projects::EnvironmentsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def environment_params
|
def environment_params(opts = {})
|
||||||
{
|
opts.reverse_merge(namespace_id: project.namespace,
|
||||||
namespace_id: project.namespace,
|
project_id: project,
|
||||||
project_id: project,
|
id: environment.id)
|
||||||
id: environment.id
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue