Commit b2298416 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '330300-ajk-model-specs-23' into 'master'

Remove use of 'service' term from integration model specs

See merge request gitlab-org/gitlab!65033
parents 740f98bb ed844b85
......@@ -8,7 +8,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
let(:project) { create(:project) }
subject(:service) do
subject(:integration) do
described_class.create!(
project: project,
properties: {
......@@ -25,17 +25,17 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
end
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:token) }
it_behaves_like 'issue tracker service URL attribute', :project_url
it_behaves_like 'issue tracker integration URL attribute', :project_url
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
end
......@@ -47,7 +47,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
describe '.supported_events' do
it 'supports push, merge_request, and tag_push events' do
expect(service.supported_events).to eq %w(push merge_request tag_push)
expect(integration.supported_events).to eq %w(push merge_request tag_push)
end
end
......@@ -57,18 +57,18 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
end
it 'always activates SSL verification after saved' do
service.create_service_hook(enable_ssl_verification: false)
integration.create_service_hook(enable_ssl_verification: false)
service.enable_ssl_verification = false
service.active = true
integration.enable_ssl_verification = false
integration.active = true
expect { service.save! }
.to change { service.service_hook.enable_ssl_verification }.from(false).to(true)
expect { integration.save! }
.to change { integration.service_hook.enable_ssl_verification }.from(false).to(true)
end
describe '#webhook_url' do
it 'returns the webhook url' do
expect(service.webhook_url).to eq(
expect(integration.webhook_url).to eq(
'https://webhook.buildkite.com/deliver/secret-sauce-webhook-token'
)
end
......@@ -76,7 +76,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
describe '#commit_status_path' do
it 'returns the correct status page' do
expect(service.commit_status_path('2ab7834c')).to eq(
expect(integration.commit_status_path('2ab7834c')).to eq(
'https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=2ab7834c'
)
end
......@@ -84,7 +84,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
describe '#build_page' do
it 'returns the correct build page' do
expect(service.build_page('2ab7834c', nil)).to eq(
expect(integration.build_page('2ab7834c', nil)).to eq(
'https://buildkite.com/organization-name/example-pipeline/builds?commit=2ab7834c'
)
end
......@@ -92,9 +92,9 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
describe '#commit_status' do
it 'returns the contents of the reactive cache' do
stub_reactive_cache(service, { commit_status: 'foo' }, 'sha', 'ref')
stub_reactive_cache(integration, { commit_status: 'foo' }, 'sha', 'ref')
expect(service.commit_status('sha', 'ref')).to eq('foo')
expect(integration.commit_status('sha', 'ref')).to eq('foo')
end
end
......@@ -104,7 +104,7 @@ RSpec.describe Integrations::Buildkite, :use_clean_rails_memory_store_caching do
'https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=123'
end
subject { service.calculate_reactive_cache('123', 'unused')[:commit_status] }
subject { integration.calculate_reactive_cache('123', 'unused')[:commit_status] }
it 'sets commit status to :error when status is 500' do
stub_request(status: 500)
......
......@@ -9,7 +9,7 @@ RSpec.describe Integrations::CustomIssueTracker do
end
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
......@@ -17,12 +17,12 @@ RSpec.describe Integrations::CustomIssueTracker do
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) }
it_behaves_like 'issue tracker service URL attribute', :project_url
it_behaves_like 'issue tracker service URL attribute', :issues_url
it_behaves_like 'issue tracker service URL attribute', :new_issue_url
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
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
end
......
......@@ -6,7 +6,7 @@ RSpec.describe Integrations::EmailsOnPush do
let_it_be(:project) { create_default(:project).freeze }
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
......@@ -14,7 +14,7 @@ RSpec.describe Integrations::EmailsOnPush do
it { is_expected.to validate_presence_of(:recipients) }
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
end
......@@ -27,7 +27,7 @@ RSpec.describe Integrations::EmailsOnPush do
stub_const("#{described_class}::RECIPIENTS_LIMIT", 2)
end
subject(:service) { described_class.new(project: project, recipients: recipients, active: true) }
subject(:integration) { described_class.new(project: project, recipients: recipients, active: true) }
context 'valid number of recipients' do
let(:recipients) { 'foo@bar.com duplicate@example.com Duplicate@example.com invalid-email' }
......@@ -43,14 +43,14 @@ RSpec.describe Integrations::EmailsOnPush do
it { is_expected.not_to be_valid }
it 'adds an error message' do
service.valid?
integration.valid?
expect(service.errors).to contain_exactly('Recipients can\'t exceed 2')
expect(integration.errors).to contain_exactly('Recipients can\'t exceed 2')
end
context 'when service is not active' do
context 'when integration is not active' do
before do
service.active = false
integration.active = false
end
it { is_expected.to be_valid }
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Integrations::OpenProject do
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
......@@ -13,11 +13,11 @@ RSpec.describe Integrations::OpenProject do
it { is_expected.to validate_presence_of(:token) }
it { is_expected.to validate_presence_of(:project_identifier_code) }
it_behaves_like 'issue tracker service URL attribute', :url
it_behaves_like 'issue tracker service URL attribute', :api_url
it_behaves_like 'issue tracker integration URL attribute', :url
it_behaves_like 'issue tracker integration URL attribute', :api_url
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
end
......
......@@ -11,7 +11,7 @@ RSpec.describe Integrations::Pivotaltracker do
end
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
......@@ -19,7 +19,7 @@ RSpec.describe Integrations::Pivotaltracker do
it { is_expected.to validate_presence_of(:token) }
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
end
......@@ -29,9 +29,9 @@ RSpec.describe Integrations::Pivotaltracker do
end
describe 'Execute' do
let(:service) do
described_class.new.tap do |service|
service.token = 'secret_api_token'
let(:integration) do
described_class.new.tap do |integration|
integration.token = 'secret_api_token'
end
end
......@@ -59,7 +59,7 @@ RSpec.describe Integrations::Pivotaltracker do
end
it 'posts correct message' do
service.execute(push_data)
integration.execute(push_data)
expect(WebMock).to have_requested(:post, stubbed_hostname(url)).with(
body: {
'source_commit' => {
......@@ -77,22 +77,22 @@ RSpec.describe Integrations::Pivotaltracker do
end
context 'when allowed branches is specified' do
let(:service) do
super().tap do |service|
service.restrict_to_branch = 'master,v10'
let(:integration) do
super().tap do |integration|
integration.restrict_to_branch = 'master,v10'
end
end
it 'posts message if branch is in the list' do
service.execute(push_data(branch: 'master'))
service.execute(push_data(branch: 'v10'))
integration.execute(push_data(branch: 'master'))
integration.execute(push_data(branch: 'v10'))
expect(WebMock).to have_requested(:post, stubbed_hostname(url)).twice
end
it 'does not post message if branch is not in the list' do
service.execute(push_data(branch: 'mas'))
service.execute(push_data(branch: 'v11'))
integration.execute(push_data(branch: 'mas'))
integration.execute(push_data(branch: 'v11'))
expect(WebMock).not_to have_requested(:post, stubbed_hostname(url))
end
......
......@@ -9,7 +9,7 @@ RSpec.describe Integrations::Youtrack do
end
describe 'Validations' do
context 'when service is active' do
context 'when integration is active' do
before do
subject.active = true
end
......@@ -17,11 +17,11 @@ RSpec.describe Integrations::Youtrack do
it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:issues_url) }
it_behaves_like 'issue tracker service URL attribute', :project_url
it_behaves_like 'issue tracker service URL attribute', :issues_url
it_behaves_like 'issue tracker integration URL attribute', :project_url
it_behaves_like 'issue tracker integration URL attribute', :issues_url
end
context 'when service is inactive' do
context 'when integration is inactive' do
before do
subject.active = false
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