diff options
Diffstat (limited to 'spec/models/environment_spec.rb')
-rw-r--r-- | spec/models/environment_spec.rb | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 08c639957d3..9d9862aa3d3 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do it 'ensures environment tier when a new object is created' do environment = build(:environment, name: 'gprd', tier: nil) - expect { environment.save }.to change { environment.tier }.from(nil).to('production') + expect { environment.save! }.to change { environment.tier }.from(nil).to('production') end it 'ensures environment tier when an existing object is updated' do @@ -418,7 +418,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do context 'not in the same branch' do before do - deployment.update(sha: project.commit('feature').id) + deployment.update!(sha: project.commit('feature').id) end it 'returns false' do @@ -496,7 +496,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do context 'when no other actions' do context 'environment is available' do before do - environment.update(state: :available) + environment.update!(state: :available) end it do @@ -508,7 +508,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do context 'environment is already stopped' do before do - environment.update(state: :stopped) + environment.update!(state: :stopped) end it do @@ -1502,7 +1502,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do deployment = create(:deployment, :success, environment: environment, project: project) deployment.create_ref - expect { environment.destroy }.to change { project.commit(deployment.ref_path) }.to(nil) + expect { environment.destroy! }.to change { project.commit(deployment.ref_path) }.to(nil) end end @@ -1517,7 +1517,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do end it 'returns the environments count grouped by state with zero value' do - environment2.update(state: 'stopped') + environment2.update!(state: 'stopped') expect(project.environments.count_by_state).to eq({ stopped: 3, available: 0 }) end end @@ -1710,4 +1710,36 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do subject end end + + describe '#should_link_to_merge_requests?' do + subject { environment.should_link_to_merge_requests? } + + context 'when environment is foldered' do + context 'when environment is production tier' do + let(:environment) { create(:environment, project: project, name: 'production/aws') } + + it { is_expected.to eq(true) } + end + + context 'when environment is development tier' do + let(:environment) { create(:environment, project: project, name: 'review/feature') } + + it { is_expected.to eq(false) } + end + end + + context 'when environment is unfoldered' do + context 'when environment is production tier' do + let(:environment) { create(:environment, project: project, name: 'production') } + + it { is_expected.to eq(true) } + end + + context 'when environment is development tier' do + let(:environment) { create(:environment, project: project, name: 'development') } + + it { is_expected.to eq(true) } + end + end + end end |