diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-10-19 22:01:55 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-10-19 22:01:55 +0300 |
commit | 2c45b85aae9a47572bb49eafe1a5fd5f70ee4756 (patch) | |
tree | 4afee91b0f9054dbae70b41056e65fa9045da39c /spec/models | |
parent | 33127207f42579d629272d4df80d3ee0ecd10f90 (diff) | |
parent | 8e4301d982ce28d80e711865ac294a98ddce3ec6 (diff) |
Merge branch 'issue_828' into 'master'
Prevent wrong markdown on issue ids when project has Jira service activated
fixes gitlab-org/gitlab-ee#828
See merge request !6728
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/external_issue_spec.rb | 15 | ||||
-rw-r--r-- | spec/models/project_services/jira_service_spec.rb | 9 | ||||
-rw-r--r-- | spec/models/project_services/redmine_service_spec.rb | 8 |
3 files changed, 17 insertions, 15 deletions
diff --git a/spec/models/external_issue_spec.rb b/spec/models/external_issue_spec.rb index 4fc3b065592..ebba6e14578 100644 --- a/spec/models/external_issue_spec.rb +++ b/spec/models/external_issue_spec.rb @@ -10,21 +10,6 @@ describe ExternalIssue, models: true do it { is_expected.to include_module(Referable) } end - describe '.reference_pattern' do - it 'allows underscores in the project name' do - expect(ExternalIssue.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234' - end - - it 'allows numbers in the project name' do - expect(ExternalIssue.reference_pattern.match('EXT3_EXT-1234')[0]).to eq 'EXT3_EXT-1234' - end - - it 'requires the project name to begin with A-Z' do - expect(ExternalIssue.reference_pattern.match('3EXT_EXT-1234')).to eq nil - expect(ExternalIssue.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234' - end - end - describe '#to_reference' do it 'returns a String reference to the object' do expect(issue.to_reference).to eq issue.id diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index b48a3176007..6ff32aea018 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -30,6 +30,15 @@ describe JiraService, models: true do end end + describe '#reference_pattern' do + it_behaves_like 'allows project key on reference pattern' + + it 'does not allow # on the code' do + expect(subject.reference_pattern.match('#123')).to be_nil + expect(subject.reference_pattern.match('1#23#12')).to be_nil + end + end + describe "Execute" do let(:user) { create(:user) } let(:project) { create(:project) } diff --git a/spec/models/project_services/redmine_service_spec.rb b/spec/models/project_services/redmine_service_spec.rb index b8679cd2563..0a7b237a051 100644 --- a/spec/models/project_services/redmine_service_spec.rb +++ b/spec/models/project_services/redmine_service_spec.rb @@ -26,4 +26,12 @@ describe RedmineService, models: true do it { is_expected.not_to validate_presence_of(:new_issue_url) } end end + + describe '#reference_pattern' do + it_behaves_like 'allows project key on reference pattern' + + it 'does allow # on the reference' do + expect(subject.reference_pattern.match('#123')[:issue]).to eq('123') + end + end end |