diff options
author | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-08-03 14:37:39 +0300 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-08-11 22:29:57 +0300 |
commit | b497b0ce3fc3c1882639f9c7d55f7991ce41f15d (patch) | |
tree | 353668ef819c38e3e9a208530a36501b4c524313 /spec/models | |
parent | 826862d48ef80ddd849b9e3cb05ef37ba7be41e9 (diff) |
Incorporate feedback
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/deployment_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 15 |
3 files changed, 45 insertions, 0 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 7df3df4bb9e..107f8b38acf 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -15,4 +15,24 @@ describe Deployment, models: true do it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } + + describe '#deployed_to?' do + let(:project) { create(:project) } + let(:environment) { create(:environment, project: project) } + let(:deployment) do + create(:deployment, environment: environment, sha: '5f923865dde3436854e9ceb9cdb7815618d4e849') + end + + context 'when there is no project commit' do + it 'returns false' do + expect(deployment.deployed_to?('random-branch')).to be false + end + end + + context 'when they share the same tree branch' do + it 'returns true' do + expect(deployment.deployed_to?('HEAD')).to be true + end + end + end end diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 8a84ac0a7c7..e65b4f82eff 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -30,4 +30,14 @@ describe Environment, models: true do expect(env.external_url).to be_nil end end + + describe '#deployed_from?' do + let(:environment) { create(:environment) } + + context 'without a last deployment' do + it "returns false" do + expect(environment.deployed_from?('HEAD')).to be false + end + end + end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 3270b877c1a..0727dd29951 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -674,6 +674,21 @@ describe MergeRequest, models: true do end end + describe "#environments" do + let(:project) { create(:project) } + + let!(:deployment) { create(:deployment, environment: environment, sha: '5f923865dde3436854e9ceb9cdb7815618d4e849') } + + let!(:environment) { create(:environment, project: project) } + let!(:environment1) { create(:environment, project: project) } + + let(:merge_request) { create(:merge_request, source_project: project) } + + it 'selects deployed environments' do + expect(merge_request.environments).to eq [environment] + end + end + describe "#reload_diff" do let(:note) { create(:diff_note_on_merge_request, project: subject.project, noteable: subject) } |