summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-06 15:19:52 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-06 17:15:15 +0200
commit6c0fc62ef5c4fa4535174a9f187b9853f0fb90ac (patch)
tree0db34e09c24d3b98baa48e4db6ac27e0b4324871 /spec/models
parente533d43a8c03a9b47a7016f3fea01a00ca797778 (diff)
downloadgitlab-ce-6c0fc62ef5c4fa4535174a9f187b9853f0fb90ac.tar.gz
Take branch access into account when stopping environment
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/environment_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 9e00f2247e8..fb7cee47ae8 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -155,6 +155,31 @@ describe Environment, models: true do
end
end
+ describe '#can_trigger_stop_action?' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+
+ let(:environment) do
+ create(:environment, :with_review_app, project: project)
+ end
+
+ context 'when user can trigger stop action' do
+ before do
+ project.add_developer(user)
+ end
+
+ it 'returns value that evaluates to true' do
+ expect(environment.can_trigger_stop_action?(user)).to be_truthy
+ end
+ end
+
+ context 'when user is not allowed to trigger stop action' do
+ it 'returns value that evaluates to false' do
+ expect(environment.can_trigger_stop_action?(user)).to be_falsey
+ end
+ end
+ end
+
describe '#stop_with_action!' do
let(:user) { create(:admin) }