Commit 24261f2d authored by Yorick Peterse's avatar Yorick Peterse

Add the method ExternalIssue#project_id

This method returns the project's ID, making ExternalIssue slightly more
compatible with Issue (which also defines the "project_id" method).
parent 467b346f
......@@ -29,6 +29,15 @@ class ExternalIssue
@project
end
def project_id
@project.id
end
# Pattern used to extract `JIRA-123` issue references from text
def self.reference_pattern
@reference_pattern ||= %r{(?<issue>\b([A-Z][A-Z0-9_]+-)\d+)}
end
def to_reference(_from_project = nil)
id
end
......
require 'spec_helper'
describe ExternalIssue, models: true do
let(:project) { double('project', to_reference: 'namespace1/project1') }
let(:project) { double('project', id: 1, to_reference: 'namespace1/project1') }
let(:issue) { described_class.new('EXT-1234', project) }
describe 'modules' do
......@@ -36,4 +36,10 @@ describe ExternalIssue, models: true do
end
end
end
describe '#project_id' do
it 'returns the ID of the project' do
expect(issue.project_id).to eq(project.id)
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