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