diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-02 23:11:21 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-05-26 15:48:30 -0400 |
commit | c0faf91ff23815404a95cf4510b43dcf5e331c4f (patch) | |
tree | 81769f125569dd6ea012920544ada1e8666ba4e5 /spec/models/snippet_spec.rb | |
parent | b06dc74d611192744d34acda944d7ed9e554342a (diff) | |
download | gitlab-ce-c0faf91ff23815404a95cf4510b43dcf5e331c4f.tar.gz |
Add `to_reference` for models that support references
Now there is a single source of information for which attribute a model
uses to be referenced, and its special character.
Diffstat (limited to 'spec/models/snippet_spec.rb')
-rw-r--r-- | spec/models/snippet_spec.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index e37dcc75230..252320b798e 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -18,7 +18,17 @@ require 'spec_helper' describe Snippet do - describe "Associations" do + describe 'modules' do + subject { described_class } + + it { is_expected.to include_module(Gitlab::VisibilityLevel) } + it { is_expected.to include_module(Linguist::BlobHelper) } + it { is_expected.to include_module(Participable) } + it { is_expected.to include_module(Referable) } + it { is_expected.to include_module(Sortable) } + end + + describe 'associations' do it { is_expected.to belong_to(:author).class_name('User') } it { is_expected.to have_many(:notes).dependent(:destroy) } end @@ -37,4 +47,18 @@ describe Snippet do it { is_expected.to validate_presence_of(:content) } end + + describe '#to_reference' do + let(:project) { create(:empty_project) } + let(:snippet) { create(:snippet, project: project) } + + it 'returns a String reference to the object' do + expect(snippet.to_reference).to eq "$#{snippet.id}" + end + + it 'supports a cross-project reference' do + cross = double('project') + expect(snippet.to_reference(cross)).to eq "#{project.to_reference}$#{snippet.id}" + end + end end |