Commit 081b179b authored by Maxime Orefice's avatar Maxime Orefice Committed by Dmytro Zaporozhets

De-duplicate environment entity EE specs

parent db0673b1
...@@ -217,7 +217,6 @@ Gitlab/DuplicateSpecLocation: ...@@ -217,7 +217,6 @@ Gitlab/DuplicateSpecLocation:
- ee/spec/helpers/auth_helper_spec.rb - ee/spec/helpers/auth_helper_spec.rb
- ee/spec/lib/gitlab/gl_repository_spec.rb - ee/spec/lib/gitlab/gl_repository_spec.rb
- ee/spec/models/namespace_spec.rb - ee/spec/models/namespace_spec.rb
- ee/spec/serializers/environment_entity_spec.rb
- ee/spec/services/issues/create_service_spec.rb - ee/spec/services/issues/create_service_spec.rb
- ee/spec/services/merge_requests/create_service_spec.rb - ee/spec/services/merge_requests/create_service_spec.rb
- ee/spec/services/merge_requests/refresh_service_spec.rb - ee/spec/services/merge_requests/refresh_service_spec.rb
...@@ -225,7 +224,6 @@ Gitlab/DuplicateSpecLocation: ...@@ -225,7 +224,6 @@ Gitlab/DuplicateSpecLocation:
- ee/spec/services/system_hooks_service_spec.rb - ee/spec/services/system_hooks_service_spec.rb
- ee/spec/helpers/ee/auth_helper_spec.rb - ee/spec/helpers/ee/auth_helper_spec.rb
- ee/spec/models/ee/namespace_spec.rb - ee/spec/models/ee/namespace_spec.rb
- ee/spec/serializers/ee/environment_entity_spec.rb
- ee/spec/services/ee/issues/create_service_spec.rb - ee/spec/services/ee/issues/create_service_spec.rb
- ee/spec/services/ee/merge_requests/create_service_spec.rb - ee/spec/services/ee/merge_requests/create_service_spec.rb
- ee/spec/services/ee/merge_requests/refresh_service_spec.rb - ee/spec/services/ee/merge_requests/refresh_service_spec.rb
......
# frozen_string_literal: true
require 'spec_helper'
describe EnvironmentEntity do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:environment) { create(:environment, :with_review_app, ref: 'development', project: project) }
let(:protected_environment) { create(:protected_environment, name: environment.name, project: project) }
let(:entity) do
described_class.new(environment, request: double(current_user: user, project: project))
end
before do
project.repository.add_branch(user, 'development', project.commit.id)
end
describe '#can_stop' do
subject { entity.as_json[:can_stop] }
it_behaves_like 'protected environments access'
end
describe '#terminal_path' do
subject { entity.as_json.include?(:terminal_path) }
before do
allow(environment).to receive(:has_terminals?).and_return(true)
end
it_behaves_like 'protected environments access', false
end
end
...@@ -7,13 +7,10 @@ describe EnvironmentEntity do ...@@ -7,13 +7,10 @@ describe EnvironmentEntity do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:environment) { create(:environment) } let(:environment) { create(:environment) }
let(:project) { create(:project) }
before do
environment.project.add_maintainer(user)
end
let(:entity) do let(:entity) do
described_class.new(environment, request: double(current_user: user)) described_class.new(environment, request: double(current_user: user, project: project))
end end
describe '#as_json' do describe '#as_json' do
...@@ -28,6 +25,7 @@ describe EnvironmentEntity do ...@@ -28,6 +25,7 @@ describe EnvironmentEntity do
before do before do
allow(environment).to receive(:has_terminals?).and_return(true) allow(environment).to receive(:has_terminals?).and_return(true)
allow(environment).to receive(:rollout_status).and_return(kube_deployment_rollout_status) allow(environment).to receive(:rollout_status).and_return(kube_deployment_rollout_status)
environment.project.add_maintainer(user)
end end
it 'exposes rollout_status' do it 'exposes rollout_status' do
...@@ -45,5 +43,31 @@ describe EnvironmentEntity do ...@@ -45,5 +43,31 @@ describe EnvironmentEntity do
expect(subject).not_to include(:rollout_status) expect(subject).not_to include(:rollout_status)
end end
end end
context 'when environment has a review app' do
let(:project) { create(:project, :repository) }
let(:environment) { create(:environment, :with_review_app, ref: 'development', project: project) }
let(:protected_environment) { create(:protected_environment, name: environment.name, project: project) }
before do
project.repository.add_branch(user, 'development', project.commit.id)
end
describe '#can_stop' do
subject { entity.as_json[:can_stop] }
it_behaves_like 'protected environments access'
end
describe '#terminal_path' do
before do
allow(environment).to receive(:has_terminals?).and_return(true)
end
subject { entity.as_json.include?(:terminal_path) }
it_behaves_like 'protected environments access', false
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment