debian-mirror-gitlab/spec/lib/gitlab/markdown/cross_project_reference_spec.rb

37 lines
979 B
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
require 'spec_helper'
module Gitlab::Markdown
describe CrossProjectReference do
include described_class
describe '#project_from_ref' do
context 'when no project was referenced' do
it 'returns the project from context' do
2015-10-24 18:46:33 +05:30
project = double
allow(self).to receive(:context).and_return({ project: project })
expect(project_from_ref(nil)).to eq project
2015-09-11 14:41:01 +05:30
end
end
context 'when referenced project does not exist' do
it 'returns nil' do
expect(project_from_ref('invalid/reference')).to be_nil
end
end
context 'when referenced project exists' do
2015-10-24 18:46:33 +05:30
it 'returns the referenced project' do
project2 = double('referenced project')
2015-09-11 14:41:01 +05:30
expect(Project).to receive(:find_with_namespace).
with('cross/reference').and_return(project2)
2015-10-24 18:46:33 +05:30
expect(project_from_ref('cross/reference')).to eq project2
2015-09-11 14:41:01 +05:30
end
end
end
end
end