diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-30 06:07:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-30 06:07:17 +0000 |
commit | 28fd41cf28bfac77fe877b6cce83594c1f9f21a1 (patch) | |
tree | f40a522a22db6518445b243b5244207416665f01 /spec | |
parent | dbb27a91536f29550f7714356ab499d318e9d7e2 (diff) | |
download | gitlab-ce-28fd41cf28bfac77fe877b6cce83594c1f9f21a1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
24 files changed, 375 insertions, 73 deletions
diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index dc27bfbef50..3402bda5a41 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -18,7 +18,7 @@ RSpec.describe 'OAuth Login', :js, :allow_forgery_protection do providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook, :cas3, :auth0, :authentiq, :salesforce] - around(:all) do |example| + around do |example| with_omniauth_full_host { example.run } end diff --git a/spec/frontend/search/mock_data.js b/spec/frontend/search/mock_data.js index fbe01f372b0..ad082e98a41 100644 --- a/spec/frontend/search/mock_data.js +++ b/spec/frontend/search/mock_data.js @@ -63,3 +63,5 @@ export const MOCK_SORT_OPTIONS = [ }, }, ]; + +export const MOCK_LS_KEY = 'mock-ls-key'; diff --git a/spec/frontend/search/store/actions_spec.js b/spec/frontend/search/store/actions_spec.js index bb711b3af81..8c53d913108 100644 --- a/spec/frontend/search/store/actions_spec.js +++ b/spec/frontend/search/store/actions_spec.js @@ -5,9 +5,11 @@ import createFlash from '~/flash'; import axios from '~/lib/utils/axios_utils'; import * as urlUtils from '~/lib/utils/url_utility'; import * as actions from '~/search/store/actions'; +import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY } from '~/search/store/constants'; import * as types from '~/search/store/mutation_types'; import createState from '~/search/store/state'; -import { MOCK_QUERY, MOCK_GROUPS, MOCK_PROJECT, MOCK_PROJECTS } from '../mock_data'; +import * as storeUtils from '~/search/store/utils'; +import { MOCK_QUERY, MOCK_GROUPS, MOCK_PROJECT, MOCK_PROJECTS, MOCK_GROUP } from '../mock_data'; jest.mock('~/flash'); jest.mock('~/lib/utils/url_utility', () => ({ @@ -141,4 +143,86 @@ describe('Global Search Store Actions', () => { }); }); }); + + describe('loadFrequentGroups', () => { + beforeEach(() => { + storeUtils.loadDataFromLS = jest.fn().mockReturnValue(MOCK_GROUPS); + }); + + it(`calls loadDataFromLS with ${GROUPS_LOCAL_STORAGE_KEY} and LOAD_FREQUENT_ITEMS mutation`, async () => { + await testAction({ + action: actions.loadFrequentGroups, + state, + expectedMutations: [ + { + type: types.LOAD_FREQUENT_ITEMS, + payload: { key: GROUPS_LOCAL_STORAGE_KEY, data: MOCK_GROUPS }, + }, + ], + }); + + expect(storeUtils.loadDataFromLS).toHaveBeenCalledWith(GROUPS_LOCAL_STORAGE_KEY); + }); + }); + + describe('loadFrequentProjects', () => { + beforeEach(() => { + storeUtils.loadDataFromLS = jest.fn().mockReturnValue(MOCK_PROJECTS); + }); + + it(`calls loadDataFromLS with ${PROJECTS_LOCAL_STORAGE_KEY} and LOAD_FREQUENT_ITEMS mutation`, async () => { + await testAction({ + action: actions.loadFrequentProjects, + state, + expectedMutations: [ + { + type: types.LOAD_FREQUENT_ITEMS, + payload: { key: PROJECTS_LOCAL_STORAGE_KEY, data: MOCK_PROJECTS }, + }, + ], + }); + + expect(storeUtils.loadDataFromLS).toHaveBeenCalledWith(PROJECTS_LOCAL_STORAGE_KEY); + }); + }); + + describe('setFrequentGroup', () => { + beforeEach(() => { + storeUtils.setFrequentItemToLS = jest.fn(); + }); + + it(`calls setFrequentItemToLS with ${GROUPS_LOCAL_STORAGE_KEY} and item data`, async () => { + await testAction({ + action: actions.setFrequentGroup, + payload: MOCK_GROUP, + state, + }); + + expect(storeUtils.setFrequentItemToLS).toHaveBeenCalledWith( + GROUPS_LOCAL_STORAGE_KEY, + state.frequentItems, + MOCK_GROUP, + ); + }); + }); + + describe('setFrequentProject', () => { + beforeEach(() => { + storeUtils.setFrequentItemToLS = jest.fn(); + }); + + it(`calls setFrequentItemToLS with ${PROJECTS_LOCAL_STORAGE_KEY} and item data`, async () => { + await testAction({ + action: actions.setFrequentProject, + payload: MOCK_PROJECT, + state, + }); + + expect(storeUtils.setFrequentItemToLS).toHaveBeenCalledWith( + PROJECTS_LOCAL_STORAGE_KEY, + state.frequentItems, + MOCK_PROJECT, + ); + }); + }); }); diff --git a/spec/frontend/search/store/mutations_spec.js b/spec/frontend/search/store/mutations_spec.js index df94ba40ff2..a60718a972d 100644 --- a/spec/frontend/search/store/mutations_spec.js +++ b/spec/frontend/search/store/mutations_spec.js @@ -71,4 +71,13 @@ describe('Global Search Store Mutations', () => { expect(state.query[payload.key]).toBe(payload.value); }); }); + + describe('LOAD_FREQUENT_ITEMS', () => { + it('sets frequentItems[key] to data', () => { + const payload = { key: 'test-key', data: [1, 2, 3] }; + mutations[types.LOAD_FREQUENT_ITEMS](state, payload); + + expect(state.frequentItems[payload.key]).toStrictEqual(payload.data); + }); + }); }); diff --git a/spec/frontend/search/store/utils_spec.js b/spec/frontend/search/store/utils_spec.js new file mode 100644 index 00000000000..e5364500464 --- /dev/null +++ b/spec/frontend/search/store/utils_spec.js @@ -0,0 +1,147 @@ +import { useLocalStorageSpy } from 'helpers/local_storage_helper'; +import { MAX_FREQUENCY } from '~/search/store/constants'; +import { loadDataFromLS, setFrequentItemToLS } from '~/search/store/utils'; +import { MOCK_LS_KEY, MOCK_GROUPS } from '../mock_data'; + +useLocalStorageSpy(); +jest.mock('~/lib/utils/accessor', () => ({ + isLocalStorageAccessSafe: jest.fn().mockReturnValue(true), +})); + +describe('Global Search Store Utils', () => { + afterEach(() => { + localStorage.clear(); + }); + + describe('loadDataFromLS', () => { + let res; + + describe('with valid data', () => { + beforeEach(() => { + localStorage.setItem(MOCK_LS_KEY, JSON.stringify(MOCK_GROUPS)); + res = loadDataFromLS(MOCK_LS_KEY); + }); + + it('returns parsed array', () => { + expect(res).toStrictEqual(MOCK_GROUPS); + }); + }); + + describe('with invalid data', () => { + beforeEach(() => { + localStorage.setItem(MOCK_LS_KEY, '[}'); + res = loadDataFromLS(MOCK_LS_KEY); + }); + + it('wipes local storage and returns an empty array', () => { + expect(localStorage.removeItem).toHaveBeenCalledWith(MOCK_LS_KEY); + expect(res).toStrictEqual([]); + }); + }); + }); + + describe('setFrequentItemToLS', () => { + const frequentItems = {}; + + describe('with existing data', () => { + describe(`when frequency is less than ${MAX_FREQUENCY}`, () => { + beforeEach(() => { + frequentItems[MOCK_LS_KEY] = [{ id: MOCK_GROUPS[0].id, frequency: 1 }]; + setFrequentItemToLS(MOCK_LS_KEY, frequentItems, MOCK_GROUPS[0]); + }); + + it('adds 1 to the frequency and calls localStorage.setItem', () => { + expect(localStorage.setItem).toHaveBeenCalledWith( + MOCK_LS_KEY, + JSON.stringify([{ id: MOCK_GROUPS[0].id, frequency: 2 }]), + ); + }); + }); + + describe(`when frequency is equal to ${MAX_FREQUENCY}`, () => { + beforeEach(() => { + frequentItems[MOCK_LS_KEY] = [{ id: MOCK_GROUPS[0].id, frequency: MAX_FREQUENCY }]; + setFrequentItemToLS(MOCK_LS_KEY, frequentItems, MOCK_GROUPS[0]); + }); + + it(`does not further increase frequency past ${MAX_FREQUENCY} and calls localStorage.setItem`, () => { + expect(localStorage.setItem).toHaveBeenCalledWith( + MOCK_LS_KEY, + JSON.stringify([{ id: MOCK_GROUPS[0].id, frequency: MAX_FREQUENCY }]), + ); + }); + }); + }); + + describe('with no existing data', () => { + beforeEach(() => { + frequentItems[MOCK_LS_KEY] = []; + setFrequentItemToLS(MOCK_LS_KEY, frequentItems, MOCK_GROUPS[0]); + }); + + it('adds a new entry with frequency 1 and calls localStorage.setItem', () => { + expect(localStorage.setItem).toHaveBeenCalledWith( + MOCK_LS_KEY, + JSON.stringify([{ id: MOCK_GROUPS[0].id, frequency: 1 }]), + ); + }); + }); + + describe('with multiple entries', () => { + beforeEach(() => { + frequentItems[MOCK_LS_KEY] = [ + { id: MOCK_GROUPS[0].id, frequency: 1 }, + { id: MOCK_GROUPS[1].id, frequency: 1 }, + ]; + setFrequentItemToLS(MOCK_LS_KEY, frequentItems, MOCK_GROUPS[1]); + }); + + it('sorts the array by most frequent', () => { + expect(localStorage.setItem).toHaveBeenCalledWith( + MOCK_LS_KEY, + JSON.stringify([ + { id: MOCK_GROUPS[1].id, frequency: 2 }, + { id: MOCK_GROUPS[0].id, frequency: 1 }, + ]), + ); + }); + }); + + describe('with max entries', () => { + beforeEach(() => { + frequentItems[MOCK_LS_KEY] = [ + { id: 1, frequency: 5 }, + { id: 2, frequency: 4 }, + { id: 3, frequency: 3 }, + { id: 4, frequency: 2 }, + { id: 5, frequency: 1 }, + ]; + setFrequentItemToLS(MOCK_LS_KEY, frequentItems, { id: 6 }); + }); + + it('removes the least frequent', () => { + expect(localStorage.setItem).toHaveBeenCalledWith( + MOCK_LS_KEY, + JSON.stringify([ + { id: 1, frequency: 5 }, + { id: 2, frequency: 4 }, + { id: 3, frequency: 3 }, + { id: 4, frequency: 2 }, + { id: 6, frequency: 1 }, + ]), + ); + }); + }); + + describe('with null data loaded in', () => { + beforeEach(() => { + frequentItems[MOCK_LS_KEY] = null; + setFrequentItemToLS(MOCK_LS_KEY, frequentItems, MOCK_GROUPS[0]); + }); + + it('wipes local storage', () => { + expect(localStorage.removeItem).toHaveBeenCalledWith(MOCK_LS_KEY); + }); + }); + }); +}); diff --git a/spec/frontend/search/topbar/components/group_filter_spec.js b/spec/frontend/search/topbar/components/group_filter_spec.js index 15b46f9c058..3b460402537 100644 --- a/spec/frontend/search/topbar/components/group_filter_spec.js +++ b/spec/frontend/search/topbar/components/group_filter_spec.js @@ -1,13 +1,14 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { MOCK_GROUP, MOCK_QUERY } from 'jest/search/mock_data'; import { visitUrl, setUrlParams } from '~/lib/utils/url_utility'; +import { GROUPS_LOCAL_STORAGE_KEY } from '~/search/store/constants'; import GroupFilter from '~/search/topbar/components/group_filter.vue'; import SearchableDropdown from '~/search/topbar/components/searchable_dropdown.vue'; import { ANY_OPTION, GROUP_DATA, PROJECT_DATA } from '~/search/topbar/constants'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); jest.mock('~/lib/utils/url_utility', () => ({ visitUrl: jest.fn(), @@ -19,6 +20,8 @@ describe('GroupFilter', () => { const actionSpies = { fetchGroups: jest.fn(), + setFrequentGroup: jest.fn(), + loadFrequentGroups: jest.fn(), }; const defaultProps = { @@ -35,7 +38,6 @@ describe('GroupFilter', () => { }); wrapper = shallowMount(GroupFilter, { - localVue, store, propsData: { ...defaultProps, @@ -77,14 +79,35 @@ describe('GroupFilter', () => { }); }); - describe('when @change is emitted', () => { + describe('when @change is emitted with Any', () => { + beforeEach(() => { + createComponent(); + + findSearchableDropdown().vm.$emit('change', ANY_OPTION); + }); + + it('calls setUrlParams with group null, project id null, and then calls visitUrl', () => { + expect(setUrlParams).toHaveBeenCalledWith({ + [GROUP_DATA.queryParam]: null, + [PROJECT_DATA.queryParam]: null, + }); + + expect(visitUrl).toHaveBeenCalled(); + }); + + it('does not call setFrequentGroup', () => { + expect(actionSpies.setFrequentGroup).not.toHaveBeenCalled(); + }); + }); + + describe('when @change is emitted with a group', () => { beforeEach(() => { createComponent(); findSearchableDropdown().vm.$emit('change', MOCK_GROUP); }); - it('calls calls setUrlParams with group id, project id null, and visitUrl', () => { + it('calls setUrlParams with group id, project id null, and then calls visitUrl', () => { expect(setUrlParams).toHaveBeenCalledWith({ [GROUP_DATA.queryParam]: MOCK_GROUP.id, [PROJECT_DATA.queryParam]: null, @@ -92,6 +115,10 @@ describe('GroupFilter', () => { expect(visitUrl).toHaveBeenCalled(); }); + + it(`calls setFrequentGroup with the group and ${GROUPS_LOCAL_STORAGE_KEY}`, () => { + expect(actionSpies.setFrequentGroup).toHaveBeenCalledWith(expect.any(Object), MOCK_GROUP); + }); }); }); @@ -118,4 +145,14 @@ describe('GroupFilter', () => { }); }); }); + + describe('onCreate', () => { + beforeEach(() => { + createComponent(); + }); + + it('calls loadFrequentGroups', () => { + expect(actionSpies.loadFrequentGroups).toHaveBeenCalledTimes(1); + }); + }); }); diff --git a/spec/frontend/search/topbar/components/project_filter_spec.js b/spec/frontend/search/topbar/components/project_filter_spec.js index 3bd0769b34a..d260df4120b 100644 --- a/spec/frontend/search/topbar/components/project_filter_spec.js +++ b/spec/frontend/search/topbar/components/project_filter_spec.js @@ -1,13 +1,14 @@ -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; +import Vue from 'vue'; import Vuex from 'vuex'; import { MOCK_PROJECT, MOCK_QUERY } from 'jest/search/mock_data'; import { visitUrl, setUrlParams } from '~/lib/utils/url_utility'; +import { PROJECTS_LOCAL_STORAGE_KEY } from '~/search/store/constants'; import ProjectFilter from '~/search/topbar/components/project_filter.vue'; import SearchableDropdown from '~/search/topbar/components/searchable_dropdown.vue'; import { ANY_OPTION, GROUP_DATA, PROJECT_DATA } from '~/search/topbar/constants'; -const localVue = createLocalVue(); -localVue.use(Vuex); +Vue.use(Vuex); jest.mock('~/lib/utils/url_utility', () => ({ visitUrl: jest.fn(), @@ -19,6 +20,8 @@ describe('ProjectFilter', () => { const actionSpies = { fetchProjects: jest.fn(), + setFrequentProject: jest.fn(), + loadFrequentProjects: jest.fn(), }; const defaultProps = { @@ -35,7 +38,6 @@ describe('ProjectFilter', () => { }); wrapper = shallowMount(ProjectFilter, { - localVue, store, propsData: { ...defaultProps, @@ -84,12 +86,16 @@ describe('ProjectFilter', () => { findSearchableDropdown().vm.$emit('change', ANY_OPTION); }); - it('calls setUrlParams with project id, not group id, then calls visitUrl', () => { + it('calls setUrlParams with null, no group id, then calls visitUrl', () => { expect(setUrlParams).toHaveBeenCalledWith({ - [PROJECT_DATA.queryParam]: ANY_OPTION.id, + [PROJECT_DATA.queryParam]: null, }); expect(visitUrl).toHaveBeenCalled(); }); + + it('does not call setFrequentProject', () => { + expect(actionSpies.setFrequentProject).not.toHaveBeenCalled(); + }); }); describe('with a Project', () => { @@ -104,6 +110,13 @@ describe('ProjectFilter', () => { }); expect(visitUrl).toHaveBeenCalled(); }); + + it(`calls setFrequentProject with the group and ${PROJECTS_LOCAL_STORAGE_KEY}`, () => { + expect(actionSpies.setFrequentProject).toHaveBeenCalledWith( + expect.any(Object), + MOCK_PROJECT, + ); + }); }); }); }); @@ -131,4 +144,14 @@ describe('ProjectFilter', () => { }); }); }); + + describe('onCreate', () => { + beforeEach(() => { + createComponent(); + }); + + it('calls loadFrequentProjects', () => { + expect(actionSpies.loadFrequentProjects).toHaveBeenCalledTimes(1); + }); + }); }); diff --git a/spec/graphql/types/global_id_type_spec.rb b/spec/graphql/types/global_id_type_spec.rb index bab786161ac..cdf09dd9cc9 100644 --- a/spec/graphql/types/global_id_type_spec.rb +++ b/spec/graphql/types/global_id_type_spec.rb @@ -102,7 +102,7 @@ RSpec.describe Types::GlobalIDType do end context 'with a deprecation' do - around(:all) do |example| + around do |example| # Unset all previously memoized GlobalIDTypes to allow us to define one # that will use the constants stubbed in the `before` block. previous_id_types = Types::GlobalIDType.instance_variable_get(:@id_types) diff --git a/spec/models/integration_spec.rb b/spec/models/integration_spec.rb index 190c0b9b2e4..9ff32a7a1a0 100644 --- a/spec/models/integration_spec.rb +++ b/spec/models/integration_spec.rb @@ -915,7 +915,7 @@ RSpec.describe Integration do described_class.available_integration_names(include_project_specific: false) end - it 'does not call dev_services_names with include_dev false' do + it 'does not call dev_integration_names with include_dev false' do expect(described_class).to receive(:integration_names).and_call_original expect(described_class).not_to receive(:dev_integration_names) expect(described_class).to receive(:project_specific_integration_names).and_call_original diff --git a/spec/models/integrations/drone_ci_spec.rb b/spec/models/integrations/drone_ci_spec.rb index 137f078edca..037d9681e0e 100644 --- a/spec/models/integrations/drone_ci_spec.rb +++ b/spec/models/integrations/drone_ci_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do it { is_expected.to validate_presence_of(:token) } it { is_expected.to validate_presence_of(:drone_url) } - it_behaves_like 'issue tracker service URL attribute', :drone_url + it_behaves_like 'issue tracker integration URL attribute', :drone_url end context 'inactive' do @@ -66,7 +66,7 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do end end - describe "service page/path methods" do + describe "integration page/path methods" do include_context :drone_ci_integration it { expect(drone.build_page(sha, branch)).to eq(build_page) } diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 11637de6c37..2769a139c2a 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1898,7 +1898,7 @@ RSpec.describe MergeRequest, factory_default: :keep do context 'has ci' do it 'returns true if MR has head_pipeline_id and commits' do - allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil } + allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { nil } allow(merge_request).to receive(:head_pipeline_id) { double } allow(merge_request).to receive(:has_no_commits?) { false } @@ -1906,7 +1906,7 @@ RSpec.describe MergeRequest, factory_default: :keep do end it 'returns true if MR has any pipeline and commits' do - allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil } + allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { nil } allow(merge_request).to receive(:head_pipeline_id) { nil } allow(merge_request).to receive(:has_no_commits?) { false } allow(merge_request).to receive(:all_pipelines) { [double] } @@ -1914,8 +1914,8 @@ RSpec.describe MergeRequest, factory_default: :keep do expect(merge_request.has_ci?).to be(true) end - it 'returns true if MR has CI service and commits' do - allow(merge_request).to receive_message_chain(:source_project, :ci_service) { double } + it 'returns true if MR has CI integration and commits' do + allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { double } allow(merge_request).to receive(:head_pipeline_id) { nil } allow(merge_request).to receive(:has_no_commits?) { false } allow(merge_request).to receive(:all_pipelines) { [] } @@ -1925,8 +1925,8 @@ RSpec.describe MergeRequest, factory_default: :keep do end context 'has no ci' do - it 'returns false if MR has no CI service nor pipeline, and no commits' do - allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil } + it 'returns false if MR has no CI integration nor pipeline, and no commits' do + allow(merge_request).to receive_message_chain(:source_project, :ci_integration) { nil } allow(merge_request).to receive(:head_pipeline_id) { nil } allow(merge_request).to receive(:all_pipelines) { [] } allow(merge_request).to receive(:has_no_commits?) { true } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 2461f2afe0f..525632bd5ad 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -5418,7 +5418,7 @@ RSpec.describe Project, factory_default: :keep do end end - describe '#execute_services' do + describe '#execute_integrations' do let(:integration) { create(:integrations_slack, push_events: true, merge_requests_events: false, active: true) } it 'executes integrations with the specified scope' do @@ -5428,7 +5428,7 @@ RSpec.describe Project, factory_default: :keep do expect(instance).to receive(:async_execute).with(data).once end - integration.project.execute_services(data, :push_hooks) + integration.project.execute_integrations(data, :push_hooks) end it 'does not execute integration that don\'t match the specified scope' do @@ -5438,7 +5438,7 @@ RSpec.describe Project, factory_default: :keep do end end - integration.project.execute_services(anything, :merge_request_hooks) + integration.project.execute_integrations(anything, :merge_request_hooks) end end @@ -5469,16 +5469,16 @@ RSpec.describe Project, factory_default: :keep do end end - describe '#has_active_services?' do + describe '#has_active_integrations?' do let_it_be(:project) { create(:project) } - it { expect(project.has_active_services?).to be_falsey } + it { expect(project.has_active_integrations?).to be_falsey } it 'returns true when a matching service exists' do create(:custom_issue_tracker_integration, push_events: true, merge_requests_events: false, project: project) - expect(project.has_active_services?(:merge_request_hooks)).to be_falsey - expect(project.has_active_services?).to be_truthy + expect(project.has_active_integrations?(:merge_request_hooks)).to be_falsey + expect(project.has_active_integrations?).to be_truthy end end @@ -5911,7 +5911,7 @@ RSpec.describe Project, factory_default: :keep do allow(subject).to receive(:disabled_integrations).and_return(%w[prometheus]) end - it 'returns only enabled services sorted' do + it 'returns only enabled integrations sorted' do expect(subject.find_or_initialize_integrations).to match [ have_attributes(title: 'JetBrains TeamCity'), have_attributes(title: 'Pushover') @@ -5955,7 +5955,7 @@ RSpec.describe Project, factory_default: :keep do create(:prometheus_integration, :template, api_url: 'https://prometheus.template.com/') end - it 'builds the service from the instance integration' do + it 'builds the integration from the instance integration' do expect(subject.find_or_initialize_integration('prometheus').api_url).to eq('https://prometheus.instance.com/') end end @@ -5965,13 +5965,13 @@ RSpec.describe Project, factory_default: :keep do create(:prometheus_integration, :template, api_url: 'https://prometheus.template.com/') end - it 'builds the service from the template' do + it 'builds the integration from the template' do expect(subject.find_or_initialize_integration('prometheus').api_url).to eq('https://prometheus.template.com/') end end context 'without an exisiting integration, or instance-level or template' do - it 'builds the service' do + it 'builds the integration' do expect(subject.find_or_initialize_integration('prometheus')).to be_a(::Integrations::Prometheus) expect(subject.find_or_initialize_integration('prometheus').api_url).to be_nil end @@ -6662,16 +6662,16 @@ RSpec.describe Project, factory_default: :keep do create(:prometheus_integration, project: project, manual_configuration: manual_configuration) end - context 'when project has an activated prometheus service' do + context 'when project has an activated prometheus integration' do let(:manual_configuration) { true } it { is_expected.to be_truthy } end - context 'when project has an inactive prometheus service' do + context 'when project has an inactive prometheus integration' do let(:manual_configuration) { false } - it 'the service is marked as inactive' do + it 'the integration is marked as inactive' do expect(subject).to be_falsey end end diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index c64f9e8465f..b3ec184d08c 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -11,17 +11,17 @@ RSpec.describe MergeRequestPresenter do subject { described_class.new(resource).ci_status } context 'when no head pipeline' do - it 'return status using CiService' do - ci_service = double(Integrations::MockCi) + it 'return status from Ci integration' do + ci_integration = double(Integrations::MockCi) ci_status = double allow(resource.source_project) - .to receive(:ci_service) - .and_return(ci_service) + .to receive(:ci_integration) + .and_return(ci_integration) allow(resource).to receive(:head_pipeline).and_return(nil) - expect(ci_service).to receive(:commit_status) + expect(ci_integration).to receive(:commit_status) .with(resource.diff_head_sha, resource.source_branch) .and_return(ci_status) diff --git a/spec/services/git/base_hooks_service_spec.rb b/spec/services/git/base_hooks_service_spec.rb index 4ab27c7ab05..539c294a2e7 100644 --- a/spec/services/git/base_hooks_service_spec.rb +++ b/spec/services/git/base_hooks_service_spec.rb @@ -59,7 +59,7 @@ RSpec.describe Git::BaseHooksService do end end - describe 'project hooks and services' do + describe 'project hooks and integrations' do context 'hooks' do before do expect(project).to receive(:has_active_hooks?).and_return(active) @@ -88,45 +88,45 @@ RSpec.describe Git::BaseHooksService do end end - context 'services' do + context 'with integrations' do before do - expect(project).to receive(:has_active_services?).and_return(active) + expect(project).to receive(:has_active_integrations?).and_return(active) end - context 'active services' do + context 'with active integrations' do let(:active) { true } it 'executes the services' do expect(subject).to receive(:push_data).at_least(:once).and_call_original - expect(project).to receive(:execute_services) + expect(project).to receive(:execute_integrations) subject.execute end end - context 'inactive services' do + context 'with inactive integrations' do let(:active) { false } it 'does not execute the services' do expect(subject).not_to receive(:push_data) - expect(project).not_to receive(:execute_services) + expect(project).not_to receive(:execute_integrations) subject.execute end end end - context 'execute_project_hooks param set to false' do + context 'when execute_project_hooks param is set to false' do before do params[:execute_project_hooks] = false allow(project).to receive(:has_active_hooks?).and_return(true) - allow(project).to receive(:has_active_services?).and_return(true) + allow(project).to receive(:has_active_integrations?).and_return(true) end - it 'does not execute hooks and services' do + it 'does not execute hooks and integrations' do expect(project).not_to receive(:execute_hooks) - expect(project).not_to receive(:execute_services) + expect(project).not_to receive(:execute_integrations) subject.execute end diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 4a285600d42..9a70de80123 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -323,7 +323,7 @@ RSpec.describe Issues::CloseService do context 'when issue is not confidential' do it 'executes issue hooks' do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) - expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks) + expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :issue_hooks) described_class.new(project: project, current_user: user).close_issue(issue) end @@ -334,7 +334,7 @@ RSpec.describe Issues::CloseService do issue = create(:issue, :confidential, project: project) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) - expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) + expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks) described_class.new(project: project, current_user: user).close_issue(issue) end diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index 8ace5f08988..b073ffd291f 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -230,7 +230,7 @@ RSpec.describe Issues::CreateService do opts = { title: 'Title', description: 'Description', confidential: false } expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) - expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks) + expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :issue_hooks) described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute end @@ -239,7 +239,7 @@ RSpec.describe Issues::CreateService do opts = { title: 'Title', description: 'Description', confidential: true } expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) - expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) + expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks) described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute end diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index 746a9105531..d58c27289c2 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -65,7 +65,7 @@ RSpec.describe Issues::ReopenService do context 'when issue is not confidential' do it 'executes issue hooks' do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) - expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks) + expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :issue_hooks) described_class.new(project: project, current_user: user).execute(issue) end @@ -76,7 +76,7 @@ RSpec.describe Issues::ReopenService do issue = create(:issue, :confidential, :closed, project: project) expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) - expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) + expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks) described_class.new(project: project, current_user: user).execute(issue) end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 2f7aaf3f7f8..054f390f325 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -537,7 +537,7 @@ RSpec.describe Issues::UpdateService, :mailer do it 'executes confidential issue hooks' do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks) - expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks) + expect(project).to receive(:execute_integrations).with(an_instance_of(Hash), :confidential_issue_hooks) update_issue(confidential: true) end diff --git a/spec/services/merge_requests/handle_assignees_change_service_spec.rb b/spec/services/merge_requests/handle_assignees_change_service_spec.rb index f9eed6eea2d..c43f5db6059 100644 --- a/spec/services/merge_requests/handle_assignees_change_service_spec.rb +++ b/spec/services/merge_requests/handle_assignees_change_service_spec.rb @@ -104,9 +104,9 @@ RSpec.describe MergeRequests::HandleAssigneesChangeService do context 'when execute_hooks option is set to true' do let(:options) { { execute_hooks: true } } - it 'execute hooks and services' do + it 'executes hooks and integrations' do expect(merge_request.project).to receive(:execute_hooks).with(anything, :merge_request_hooks) - expect(merge_request.project).to receive(:execute_services).with(anything, :merge_request_hooks) + expect(merge_request.project).to receive(:execute_integrations).with(anything, :merge_request_hooks) expect(service).to receive(:enqueue_jira_connect_messages_for).with(merge_request) execute diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb index 07ef08d36c4..17001733c5b 100644 --- a/spec/services/notes/post_process_service_spec.rb +++ b/spec/services/notes/post_process_service_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Notes::PostProcessService do it do expect(project).to receive(:execute_hooks) - expect(project).to receive(:execute_services) + expect(project).to receive(:execute_integrations) described_class.new(@note).execute end @@ -29,16 +29,16 @@ RSpec.describe Notes::PostProcessService do context 'with a confidential issue' do let(:issue) { create(:issue, :confidential, project: project) } - it "doesn't call note hooks/services" do + it "doesn't call note hooks/integrations" do expect(project).not_to receive(:execute_hooks).with(anything, :note_hooks) - expect(project).not_to receive(:execute_services).with(anything, :note_hooks) + expect(project).not_to receive(:execute_integrations).with(anything, :note_hooks) described_class.new(@note).execute end - it "calls confidential-note hooks/services" do + it "calls confidential-note hooks/integrations" do expect(project).to receive(:execute_hooks).with(anything, :confidential_note_hooks) - expect(project).to receive(:execute_services).with(anything, :confidential_note_hooks) + expect(project).to receive(:execute_integrations).with(anything, :confidential_note_hooks) described_class.new(@note).execute end diff --git a/spec/support/omniauth_strategy.rb b/spec/support/omniauth_strategy.rb index 116db82febd..5d5ee7dc1db 100644 --- a/spec/support/omniauth_strategy.rb +++ b/spec/support/omniauth_strategy.rb @@ -29,7 +29,7 @@ end RSpec.configure do |config| config.include StrategyHelpers, type: :strategy - config.around(:all, type: :strategy) do |example| + config.around(type: :strategy) do |example| StrategyHelpers.without_test_mode do example.run end diff --git a/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb b/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb index 218a3462c35..92a7d7ab3a3 100644 --- a/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb +++ b/spec/support/shared_examples/services/alert_management/alert_processing/alert_firing_shared_examples.rb @@ -13,7 +13,7 @@ RSpec.shared_examples 'creates an alert management alert or errors' do it 'executes the alert service hooks' do expect_next_instance_of(AlertManagement::Alert) do |alert| - expect(alert).to receive(:execute_services) + expect(alert).to receive(:execute_integrations) end subject @@ -84,7 +84,7 @@ end # - `alert`, the alert for which events should be incremented RSpec.shared_examples 'adds an alert management alert event' do specify do - expect(alert).not_to receive(:execute_services) + expect(alert).not_to receive(:execute_integrations) expect { subject }.to change { alert.reload.events }.by(1) diff --git a/spec/support/shared_examples/services/alert_management/alert_processing/incident_creation_shared_examples.rb b/spec/support/shared_examples/services/alert_management/alert_processing/incident_creation_shared_examples.rb index c6ac07b6dd5..98834f01ce2 100644 --- a/spec/support/shared_examples/services/alert_management/alert_processing/incident_creation_shared_examples.rb +++ b/spec/support/shared_examples/services/alert_management/alert_processing/incident_creation_shared_examples.rb @@ -20,7 +20,7 @@ end RSpec.shared_examples 'processes incident issues' do |with_issue: false| before do allow_next_instance_of(AlertManagement::Alert) do |alert| - allow(alert).to receive(:execute_services) + allow(alert).to receive(:execute_integrations) end end diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index f702070d2f7..04a38874905 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -378,7 +378,7 @@ RSpec.describe PostReceive do allow(Project).to receive(:find_by).and_return(project) expect(project).to receive(:execute_hooks).twice - expect(project).to receive(:execute_services).twice + expect(project).to receive(:execute_integrations).twice perform end |