summaryrefslogtreecommitdiff
path: root/spec/models/release_spec.rb
diff options
context:
space:
mode:
authorEtienne BaquƩ <ebaque@gitlab.com>2019-09-03 09:38:59 +0000
committerAndreas Brandl <abrandl@gitlab.com>2019-09-03 09:38:59 +0000
commita43ab8d6a430014e875deb3bff3fd8d8da256747 (patch)
tree25da7465575e53501737bb0d71709021173f7319 /spec/models/release_spec.rb
parentde4e2dcafceee485cba9ef6993062b00a4929d2f (diff)
downloadgitlab-ce-a43ab8d6a430014e875deb3bff3fd8d8da256747.tar.gz
Added relationships between Release and Milestone
Modified schema via migrations. Added one-to-one relationship between the two models. Added changelog file
Diffstat (limited to 'spec/models/release_spec.rb')
-rw-r--r--spec/models/release_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb
index e9d846e7291..29ce9f762b0 100644
--- a/spec/models/release_spec.rb
+++ b/spec/models/release_spec.rb
@@ -13,6 +13,7 @@ RSpec.describe Release do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:author).class_name('User') }
it { is_expected.to have_many(:links).class_name('Releases::Link') }
+ it { is_expected.to have_one(:milestone) }
end
describe 'validation' do
@@ -34,6 +35,20 @@ RSpec.describe Release do
expect(existing_release_without_name.name).to be_nil
end
end
+
+ context 'when a release is tied to a milestone for another project' do
+ it 'creates a validation error' do
+ release.milestone = build(:milestone, project: create(:project))
+ expect(release).not_to be_valid
+ end
+ end
+
+ context 'when a release is tied to a milestone linked to the same project' do
+ it 'is valid' do
+ release.milestone = build(:milestone, project: project)
+ expect(release).to be_valid
+ end
+ end
end
describe '#assets_count' do