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 | |
parent | d6e00f5373e24deaa7f143f5445ae9461ef5f615 (diff) | |
download | gitlab-ce-43906336ff24e218cb1f7024d63a22367dd7e09a.tar.gz |
Fix tests and add has_environment?
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/build_spec.rb | 38 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 4 |
2 files changed, 36 insertions, 6 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 diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 2efe69d7adc..a7e90c8a381 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -4,14 +4,12 @@ describe Ci::Build, models: true do let(:build) { create(:ci_build) } let(:test_trace) { 'This is a test' } - describe 'ss' do it { is_expected.to belong_to(:runner) } it { is_expected.to belong_to(:trigger_request) } it { is_expected.to belong_to(:erased_by) } it { is_expected.to have_many(:deployments) } - end - + describe '#trace' do it 'obfuscates project runners token' do allow(build).to receive(:raw_trace).and_return("Test: #{build.project.runners_token}") |