diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-10 13:59:26 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-10 13:59:26 +0100 |
commit | 1494abe982583c564969baaba7daa251ef333156 (patch) | |
tree | 681b777b50e645e6af0496bc808a2c071a4250ee /spec/models/environment_spec.rb | |
parent | 13a680e343bdcd905c9134c57202fdec7d436d96 (diff) | |
download | gitlab-ce-1494abe982583c564969baaba7daa251ef333156.tar.gz |
Allow to stop any environment
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r-- | spec/models/environment_spec.rb | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index a94e6d0165f..b860ba2a26c 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -99,8 +99,8 @@ describe Environment, models: true do end end - describe '#stoppable?' do - subject { environment.stoppable? } + describe '#can_run_stop_action?' do + subject { environment.can_run_stop_action? } context 'when no other actions' do it { is_expected.to be_falsey } @@ -129,17 +129,39 @@ describe Environment, models: true do end end - describe '#stop!' do + describe '#run_stop!' do let(:user) { create(:user) } - subject { environment.stop!(user) } + subject { environment.run_stop!(user) } before do - expect(environment).to receive(:stoppable?).and_call_original + expect(environment).to receive(:available?).and_call_original end context 'when no other actions' do - it { is_expected.to be_nil } + context 'environment is available' do + before do + environment.update(state: :available) + end + + it do + subject + + expect(environment).to be_stopped + end + end + + context 'environment is already stopped' do + before do + environment.update(state: :stopped) + end + + it do + subject + + expect(environment).to be_stopped + end + end end context 'when matching action is defined' do |