blob: 11e044c2a18b71d69933fd7e84caf8a233b78fa1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Integrations::BaseThirdPartyWiki do
describe 'Validations' do
let_it_be_with_reload(:project) { create(:project) }
describe 'only one third party wiki per project' do
subject(:integration) { create(:shimo_integration, project: project, active: true) }
before_all do
create(:confluence_integration, project: project, active: true)
end
context 'when integration is changed manually by user' do
it 'executes the validation' do
valid = integration.valid?(:manual_change)
expect(valid).to be_falsey
error_message = 'Another third-party wiki is already in use. '\
'Only one third-party wiki integration can be active at a time'
expect(integration.errors[:base]).to include _(error_message)
end
end
context 'when integration is changed internally' do
it 'does not execute the validation' do
expect(integration.valid?).to be_truthy
end
end
context 'when integration is not on the project level' do
subject(:integration) { create(:shimo_integration, :instance, active: true) }
it 'executes the validation' do
expect(integration.valid?(:manual_change)).to be_truthy
end
end
end
end
end
|