diff options
author | Sean McGivern <sean@gitlab.com> | 2017-08-03 12:50:06 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-08-07 11:55:00 +0100 |
commit | 149528f472f3d2f3865ae01c764b81c6a97f9380 (patch) | |
tree | 8c9e38e7071b0a0002d3741259a7318e7a0427e5 /spec/models | |
parent | 03b816f3e845c9b25d3588336fc1616238465deb (diff) | |
download | gitlab-ce-149528f472f3d2f3865ae01c764b81c6a97f9380.tar.gz |
Support references to group milestones
Group milestones can only be referred to by name, not IID. They also do not
support cross-project references.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/milestone_spec.rb | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index b48aa9558d5..d3da0107d5c 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -230,16 +230,40 @@ describe Milestone do end describe '#to_reference' do - let(:project) { build(:project, name: 'sample-project') } - let(:milestone) { build(:milestone, iid: 1, project: project) } + let(:group) { build_stubbed(:group) } + let(:project) { build_stubbed(:project, name: 'sample-project') } + let(:another_project) { build_stubbed(:project, name: 'another-project', namespace: project.namespace) } + + context 'for a project milestone' do + let(:milestone) { build_stubbed(:milestone, iid: 1, project: project, name: 'milestone') } + + it 'returns a String reference to the object' do + expect(milestone.to_reference).to eq '%1' + end + + it 'returns a reference by name when the format is set to :name' do + expect(milestone.to_reference(format: :name)).to eq '%"milestone"' + end - it 'returns a String reference to the object' do - expect(milestone.to_reference).to eq "%1" + it 'supports a cross-project reference' do + expect(milestone.to_reference(another_project)).to eq 'sample-project%1' + end end - it 'supports a cross-project reference' do - another_project = build(:project, name: 'another-project', namespace: project.namespace) - expect(milestone.to_reference(another_project)).to eq "sample-project%1" + context 'for a group milestone' do + let(:milestone) { build_stubbed(:milestone, iid: 1, group: group, name: 'milestone') } + + it 'returns nil with the default format' do + expect(milestone.to_reference).to be_nil + end + + it 'returns a reference by name when the format is set to :name' do + expect(milestone.to_reference(format: :name)).to eq '%"milestone"' + end + + it 'does not supports cross-project references' do + expect(milestone.to_reference(another_project, format: :name)).to eq '%"milestone"' + end end end |