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

35 lines
903 B
Ruby
Raw Normal View History

2015-12-23 02:04:40 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Banzai::CrossProjectReference do
2015-12-23 02:04:40 +05:30
include described_class
2018-03-17 18:26:18 +05:30
describe '#parent_from_ref' do
2015-12-23 02:04:40 +05:30
context 'when no project was referenced' do
it 'returns the project from context' do
project = double
allow(self).to receive(:context).and_return({ project: project })
2018-03-17 18:26:18 +05:30
expect(parent_from_ref(nil)).to eq project
2015-12-23 02:04:40 +05:30
end
end
context 'when referenced project does not exist' do
it 'returns nil' do
2018-03-17 18:26:18 +05:30
expect(parent_from_ref('invalid/reference')).to be_nil
2015-12-23 02:04:40 +05:30
end
end
context 'when referenced project exists' do
it 'returns the referenced project' do
project2 = double('referenced project')
2017-09-10 17:25:29 +05:30
expect(Project).to receive(:find_by_full_path)
.with('cross/reference').and_return(project2)
2015-12-23 02:04:40 +05:30
2018-03-17 18:26:18 +05:30
expect(parent_from_ref('cross/reference')).to eq project2
2015-12-23 02:04:40 +05:30
end
end
end
end