2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-05-02 23:11:21 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe ExternalIssue do
|
2016-10-11 11:37:19 -04:00
|
|
|
let(:project) { double('project', id: 1, to_reference: 'namespace1/project1') }
|
2015-05-02 23:11:21 -04:00
|
|
|
let(:issue) { described_class.new('EXT-1234', project) }
|
|
|
|
|
|
|
|
describe 'modules' do
|
|
|
|
subject { described_class }
|
|
|
|
|
|
|
|
it { is_expected.to include_module(Referable) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#to_reference' do
|
|
|
|
it 'returns a String reference to the object' do
|
|
|
|
expect(issue.to_reference).to eq issue.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#title' do
|
|
|
|
it 'returns a title' do
|
|
|
|
expect(issue.title).to eq "External Issue #{issue}"
|
|
|
|
end
|
|
|
|
end
|
2016-03-22 05:56:44 -04:00
|
|
|
|
|
|
|
describe '#reference_link_text' do
|
2016-04-12 04:01:52 -04:00
|
|
|
context 'if issue id has a prefix' do
|
|
|
|
it 'returns the issue ID' do
|
|
|
|
expect(issue.reference_link_text).to eq 'EXT-1234'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'if issue id is a number' do
|
2019-01-16 07:09:29 -05:00
|
|
|
let(:issue) { described_class.new('1234', project) }
|
2019-12-18 19:08:01 -05:00
|
|
|
|
2016-04-12 04:01:52 -04:00
|
|
|
it 'returns the issue ID prefixed by #' do
|
|
|
|
expect(issue.reference_link_text).to eq '#1234'
|
|
|
|
end
|
2016-03-22 05:56:44 -04:00
|
|
|
end
|
|
|
|
end
|
2016-10-11 11:37:19 -04:00
|
|
|
|
|
|
|
describe '#project_id' do
|
|
|
|
it 'returns the ID of the project' do
|
|
|
|
expect(issue.project_id).to eq(project.id)
|
|
|
|
end
|
|
|
|
end
|
2017-03-03 09:25:52 -05:00
|
|
|
|
|
|
|
describe '#hash' do
|
|
|
|
it 'returns the hash of its [class, to_s] pair' do
|
|
|
|
issue_2 = described_class.new(issue.to_s, project)
|
|
|
|
|
|
|
|
expect(issue.hash).to eq(issue_2.hash)
|
|
|
|
end
|
|
|
|
end
|
2015-05-02 23:11:21 -04:00
|
|
|
end
|