diff options
author | Etienne BaquƩ <ebaque@gitlab.com> | 2019-09-03 09:38:59 +0000 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2019-09-03 09:38:59 +0000 |
commit | a43ab8d6a430014e875deb3bff3fd8d8da256747 (patch) | |
tree | 25da7465575e53501737bb0d71709021173f7319 /spec/models/milestone_spec.rb | |
parent | de4e2dcafceee485cba9ef6993062b00a4929d2f (diff) | |
download | gitlab-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/milestone_spec.rb')
-rw-r--r-- | spec/models/milestone_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 3704a2d468d..64030f5b92a 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -54,11 +54,31 @@ describe Milestone do expect(milestone.errors[:due_date]).to include("date must not be after 9999-12-31") end end + + describe 'milestone_release' do + let(:milestone) { build(:milestone, project: project) } + + context 'when it is tied to a release for another project' do + it 'creates a validation error' do + other_project = create(:project) + milestone.release = build(:release, project: other_project) + expect(milestone).not_to be_valid + end + end + + context 'when it is tied to a release for the same project' do + it 'is valid' do + milestone.release = build(:release, project: project) + expect(milestone).to be_valid + end + end + end end describe "Associations" do it { is_expected.to belong_to(:project) } it { is_expected.to have_many(:issues) } + it { is_expected.to have_one(:release) } end let(:project) { create(:project, :public) } |