Commit e5d89c10 authored by Robert Speicher's avatar Robert Speicher

Remove unnecessary current_user context from filter specs

parent 21cacb36
...@@ -2,20 +2,16 @@ require 'spec_helper' ...@@ -2,20 +2,16 @@ require 'spec_helper'
module Gitlab::Markdown module Gitlab::Markdown
describe CrossProjectReference do describe CrossProjectReference do
# context in the html-pipeline sense, not in the rspec sense
let(:context) do
{
current_user: double('user'),
project: double('project')
}
end
include described_class include described_class
describe '#project_from_ref' do describe '#project_from_ref' do
context 'when no project was referenced' do context 'when no project was referenced' do
it 'returns the project from context' do it 'returns the project from context' do
expect(project_from_ref(nil)).to eq context[:project] project = double
allow(self).to receive(:context).and_return({ project: project })
expect(project_from_ref(nil)).to eq project
end end
end end
...@@ -26,17 +22,13 @@ module Gitlab::Markdown ...@@ -26,17 +22,13 @@ module Gitlab::Markdown
end end
context 'when referenced project exists' do context 'when referenced project exists' do
let(:project2) { double('referenced project') } it 'returns the referenced project' do
project2 = double('referenced project')
before do
expect(Project).to receive(:find_with_namespace). expect(Project).to receive(:find_with_namespace).
with('cross/reference').and_return(project2) with('cross/reference').and_return(project2)
end
context 'and the user has permission to read it' do expect(project_from_ref('cross/reference')).to eq project2
it 'returns the referenced project' do
expect(project_from_ref('cross/reference')).to eq project2
end
end end
end end
end end
......
...@@ -80,20 +80,15 @@ module Gitlab::Markdown ...@@ -80,20 +80,15 @@ module Gitlab::Markdown
context 'mentioning a group' do context 'mentioning a group' do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:user) { create(:user) }
let(:reference) { group.to_reference } let(:reference) { group.to_reference }
before do
group.add_developer(user)
end
it 'links to the Group' do it 'links to the Group' do
doc = filter("Hey #{reference}", current_user: user) doc = filter("Hey #{reference}")
expect(doc.css('a').first.attr('href')).to eq urls.group_url(group) expect(doc.css('a').first.attr('href')).to eq urls.group_url(group)
end end
it 'includes a data-group-id attribute' do it 'includes a data-group-id attribute' do
doc = filter("Hey #{reference}", current_user: user) doc = filter("Hey #{reference}")
link = doc.css('a').first link = doc.css('a').first
expect(link).to have_attribute('data-group-id') expect(link).to have_attribute('data-group-id')
...@@ -101,7 +96,7 @@ module Gitlab::Markdown ...@@ -101,7 +96,7 @@ module Gitlab::Markdown
end end
it 'adds to the results hash' do it 'adds to the results hash' do
result = pipeline_result("Hey #{reference}", current_user: user) result = pipeline_result("Hey #{reference}")
expect(result[:references][:user]).to eq group.users expect(result[:references][:user]).to eq group.users
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment