From 1494abe982583c564969baaba7daa251ef333156 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski <ayufan@ayufan.eu> Date: Thu, 10 Nov 2016 13:59:26 +0100 Subject: Allow to stop any environment --- spec/models/environment_spec.rb | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'spec/models') 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 -- cgit v1.2.1