2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-21 11:13:14 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-05-20 05:10:30 -04:00
|
|
|
RSpec.describe Integrations::Redmine do
|
2016-04-21 11:13:14 -04:00
|
|
|
describe 'Validations' do
|
2019-09-16 11:06:26 -04:00
|
|
|
# if redmine is set in setting the urls are set to defaults
|
|
|
|
# therefore the validation passes as the values are not nil
|
|
|
|
before do
|
|
|
|
settings = {
|
|
|
|
'redmine' => {}
|
|
|
|
}
|
|
|
|
allow(Gitlab.config).to receive(:issues_tracker).and_return(settings)
|
|
|
|
end
|
|
|
|
|
2021-06-29 23:07:30 -04:00
|
|
|
context 'when integration is active' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
subject.active = true
|
|
|
|
end
|
2016-04-21 11:13:14 -04:00
|
|
|
|
|
|
|
it { is_expected.to validate_presence_of(:project_url) }
|
|
|
|
it { is_expected.to validate_presence_of(:issues_url) }
|
|
|
|
it { is_expected.to validate_presence_of(:new_issue_url) }
|
2019-09-16 11:06:26 -04:00
|
|
|
|
2021-06-29 23:07:30 -04:00
|
|
|
it_behaves_like 'issue tracker integration URL attribute', :project_url
|
|
|
|
it_behaves_like 'issue tracker integration URL attribute', :issues_url
|
|
|
|
it_behaves_like 'issue tracker integration URL attribute', :new_issue_url
|
2016-04-21 11:13:14 -04:00
|
|
|
end
|
|
|
|
|
2021-06-29 23:07:30 -04:00
|
|
|
context 'when integration is inactive' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
subject.active = false
|
|
|
|
end
|
2016-04-21 11:13:14 -04:00
|
|
|
|
|
|
|
it { is_expected.not_to validate_presence_of(:project_url) }
|
|
|
|
it { is_expected.not_to validate_presence_of(:issues_url) }
|
|
|
|
it { is_expected.not_to validate_presence_of(:new_issue_url) }
|
|
|
|
end
|
|
|
|
end
|
2016-10-06 18:05:27 -04:00
|
|
|
|
2017-06-30 08:47:53 -04:00
|
|
|
describe '.reference_pattern' do
|
2016-10-06 18:05:27 -04:00
|
|
|
it_behaves_like 'allows project key on reference pattern'
|
|
|
|
|
|
|
|
it 'does allow # on the reference' do
|
2017-06-30 08:47:53 -04:00
|
|
|
expect(described_class.reference_pattern.match('#123')[:issue]).to eq('123')
|
2016-10-06 18:05:27 -04:00
|
|
|
end
|
|
|
|
end
|
2016-04-21 11:13:14 -04:00
|
|
|
end
|