diff options
Diffstat (limited to 'spec/models/snippet_spec.rb')
-rw-r--r-- | spec/models/snippet_spec.rb | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index da1f2653676..6a5456fce3f 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -41,8 +41,8 @@ RSpec.describe Snippet do is_expected .to validate_length_of(:content) - .is_at_most(Gitlab::CurrentSettings.snippet_size_limit) - .with_message("is too long (2 Bytes). The maximum size is 1 Byte.") + .is_at_most(Gitlab::CurrentSettings.snippet_size_limit) + .with_message("is too long (2 Bytes). The maximum size is 1 Byte.") end context 'content validations' do @@ -145,7 +145,7 @@ RSpec.describe Snippet do describe '#to_reference' do context 'when snippet belongs to a project' do - let(:project) { build(:project, name: 'sample-project') } + let(:project) { build(:project) } let(:snippet) { build(:snippet, id: 1, project: project) } it 'returns a String reference to the object' do @@ -153,8 +153,8 @@ RSpec.describe Snippet do end it 'supports a cross-project reference' do - another_project = build(:project, name: 'another-project', namespace: project.namespace) - expect(snippet.to_reference(another_project)).to eq "sample-project$1" + another_project = build(:project, namespace: project.namespace) + expect(snippet.to_reference(another_project)).to eq "#{project.path}$1" end end @@ -166,7 +166,7 @@ RSpec.describe Snippet do end it 'still returns shortest reference when project arg present' do - another_project = build(:project, name: 'another-project') + another_project = build(:project) expect(snippet.to_reference(another_project)).to eq "$1" end end @@ -492,17 +492,21 @@ RSpec.describe Snippet do let_it_be(:snippet) { create(:snippet, content: 'foo', project: project) } let_it_be(:note1) do - create(:note_on_project_snippet, - noteable: snippet, - project: project, - note: 'a') + create( + :note_on_project_snippet, + noteable: snippet, + project: project, + note: 'a' + ) end let_it_be(:note2) do - create(:note_on_project_snippet, - noteable: snippet, - project: project, - note: 'b') + create( + :note_on_project_snippet, + noteable: snippet, + project: project, + note: 'b' + ) end it 'includes the snippet author and note authors' do |