diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-17 12:08:28 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-17 12:08:28 +0100 |
commit | 43906336ff24e218cb1f7024d63a22367dd7e09a (patch) | |
tree | 326f69374123c68075942d45180b4c887376ba04 /spec/models/build_spec.rb | |
parent | d6e00f5373e24deaa7f143f5445ae9461ef5f615 (diff) | |
download | gitlab-ce-43906336ff24e218cb1f7024d63a22367dd7e09a.tar.gz |
Fix tests and add has_environment?
Diffstat (limited to 'spec/models/build_spec.rb')
-rw-r--r-- | spec/models/build_spec.rb | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index 731a2274d9e..ef07f2275b1 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -1053,6 +1053,26 @@ describe Ci::Build, models: true do end end + describe '#has_environment?' do + subject { build.has_environment? } + + context 'when environment is defined' do + before do + build.update(environment: 'review') + end + + it { is_expected.to be_truthy } + end + + context 'when environment is not defined' do + before do + build.update(environment: nil) + end + + it { is_expected.to be_falsey } + end + end + describe '#starts_environment?' do subject { build.starts_environment? } @@ -1061,7 +1081,17 @@ describe Ci::Build, models: true do build.update(environment: 'review') end - it { is_expected.to be_truthy } + context 'no action is defined' do + it { is_expected.to be_truthy } + end + + context 'and start action is defined' do + before do + build.update(options: { environment: { action: 'start' } } ) + end + + it { is_expected.to be_truthy } + end end context 'when environment is not defined' do @@ -1106,11 +1136,13 @@ describe Ci::Build, models: true do describe '#last_deployment' do subject { build.last_deployment } - context 'when multiple deployments is created returns latest one' do + context 'when multiple deployments are created' do let!(:deployment1) { create(:deployment, deployable: build) } let!(:deployment2) { create(:deployment, deployable: build) } - it { is_expected.to eq(deployment2) } + it 'returns the latest one' do + is_expected.to eq(deployment2) + end end end |