diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-13 15:07:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-13 15:07:18 +0300 |
commit | c3eeb6a8d6a4b11f0bc5e5eb1ed43b0726f1ea26 (patch) | |
tree | 7283014bb12ce53b57d2703b229095ad58e6d820 /spec | |
parent | 10e15ac3c2798956ff6a43d7b36bdf86c68aa817 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
20 files changed, 171 insertions, 78 deletions
diff --git a/spec/factories/integrations.rb b/spec/factories/integrations.rb index 5beb495516f..a927f0fb501 100644 --- a/spec/factories/integrations.rb +++ b/spec/factories/integrations.rb @@ -319,6 +319,15 @@ FactoryBot.define do token { 'squash_tm_token' } end + factory :telegram_integration, class: 'Integrations::Telegram' do + project + type { 'Integrations::Telegram' } + active { true } + + token { '123456:ABC-DEF1234' } + room { '@channel' } + end + # this is for testing storing values inside properties, which is deprecated and will be removed in # https://gitlab.com/gitlab-org/gitlab/issues/29404 trait :without_properties_callback do diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb index c0c573d2f20..05e492e7021 100644 --- a/spec/features/profiles/password_spec.rb +++ b/spec/features/profiles/password_spec.rb @@ -86,10 +86,11 @@ RSpec.describe 'Profile > Password', feature_category: :user_profile do Rails.application.reload_routes! end - it 'renders 404' do + it 'renders 404', :js do visit edit_profile_password_path - expect(page).to have_gitlab_http_status(:not_found) + expect(page).to have_title('Not Found') + expect(page).to have_content('Page Not Found') end end end diff --git a/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb b/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb index 458f4925051..9d9620c1461 100644 --- a/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb +++ b/spec/features/projects/integrations/user_uses_inherited_settings_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'User uses inherited settings', :js, feature_category: :integrations do include JiraIntegrationHelpers + include ListboxHelpers include_context 'project integration activation' @@ -24,8 +25,7 @@ RSpec.describe 'User uses inherited settings', :js, feature_category: :integrati expect(page).to have_field('Web URL', with: parent_settings[:url], readonly: true) expect(page).to have_field('New API token or password', with: '', readonly: true) - click_on 'Use default settings' - click_on 'Use custom settings' + select_from_listbox('Use custom settings', from: 'Use default settings') expect(page).not_to have_button('Use default settings') expect(page).to have_field('Web URL', with: project_settings[:url], readonly: false) @@ -55,8 +55,7 @@ RSpec.describe 'User uses inherited settings', :js, feature_category: :integrati expect(page).to have_field('URL', with: project_settings[:url], readonly: false) expect(page).to have_field('New API token or password', with: '', readonly: false) - click_on 'Use custom settings' - click_on 'Use default settings' + select_from_listbox('Use default settings', from: 'Use custom settings') expect(page).not_to have_button('Use custom settings') expect(page).to have_field('URL', with: parent_settings[:url], readonly: true) diff --git a/spec/frontend/boards/board_list_helper.js b/spec/frontend/boards/board_list_helper.js index 43cf6ead1c1..e3cdec1ab6e 100644 --- a/spec/frontend/boards/board_list_helper.js +++ b/spec/frontend/boards/board_list_helper.js @@ -39,7 +39,7 @@ export default function createComponent({ Vue.use(Vuex); const fakeApollo = createMockApollo([ - [listQuery, jest.fn().mockResolvedValue(boardListQueryResponse(issuesCount))], + [listQuery, jest.fn().mockResolvedValue(boardListQueryResponse({ issuesCount }))], ...apolloQueryHandlers, ]); diff --git a/spec/frontend/boards/mock_data.js b/spec/frontend/boards/mock_data.js index 68f665e004c..447aacd9cea 100644 --- a/spec/frontend/boards/mock_data.js +++ b/spec/frontend/boards/mock_data.js @@ -964,11 +964,14 @@ export const issueBoardListsQueryResponse = { }, }; -export const boardListQueryResponse = (issuesCount = 20) => ({ +export const boardListQueryResponse = ({ + listId = 'gid://gitlab/List/5', + issuesCount = 20, +} = {}) => ({ data: { boardList: { __typename: 'BoardList', - id: 'gid://gitlab/BoardList/5', + id: listId, totalWeight: 5, issuesCount, }, diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js index b8d3be28ca6..f3800ce8324 100644 --- a/spec/frontend/boards/stores/actions_spec.js +++ b/spec/frontend/boards/stores/actions_spec.js @@ -1340,8 +1340,8 @@ describe('updateIssueOrder', () => { }; jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ data: { - issueMoveList: { - issue: rawIssue, + issuableMoveList: { + issuable: rawIssue, errors: [], }, }, @@ -1355,8 +1355,8 @@ describe('updateIssueOrder', () => { it('should commit MUTATE_ISSUE_SUCCESS mutation when successful', () => { jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ data: { - issueMoveList: { - issue: rawIssue, + issuableMoveList: { + issuable: rawIssue, errors: [], }, }, @@ -1387,8 +1387,8 @@ describe('updateIssueOrder', () => { it('should commit SET_ERROR and dispatch undoMoveIssueCard', () => { jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ data: { - issueMoveList: { - issue: {}, + issuableMoveList: { + issuable: {}, errors: [{ foo: 'bar' }], }, }, diff --git a/spec/frontend/environments/environment_delete_spec.js b/spec/frontend/environments/environment_delete_spec.js index 530f9f55088..ea402f26426 100644 --- a/spec/frontend/environments/environment_delete_spec.js +++ b/spec/frontend/environments/environment_delete_spec.js @@ -1,4 +1,4 @@ -import { GlDropdownItem } from '@gitlab/ui'; +import { GlDisclosureDropdownItem } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; @@ -21,7 +21,7 @@ describe('External URL Component', () => { }); }; - const findDropdownItem = () => wrapper.findComponent(GlDropdownItem); + const findDropdownItem = () => wrapper.findComponent(GlDisclosureDropdownItem); describe('event hub', () => { beforeEach(() => { @@ -30,13 +30,13 @@ describe('External URL Component', () => { it('should render a dropdown item to delete the environment', () => { expect(findDropdownItem().exists()).toBe(true); - expect(wrapper.text()).toEqual('Delete environment'); - expect(findDropdownItem().attributes('variant')).toBe('danger'); + expect(findDropdownItem().props('item').text).toBe('Delete environment'); + expect(findDropdownItem().props('item').extraAttrs.variant).toBe('danger'); }); it('emits requestDeleteEnvironment in the event hub when button is clicked', () => { jest.spyOn(eventHub, '$emit'); - findDropdownItem().vm.$emit('click'); + findDropdownItem().vm.$emit('action'); expect(eventHub.$emit).toHaveBeenCalledWith('requestDeleteEnvironment', resolvedEnvironment); }); }); @@ -55,13 +55,13 @@ describe('External URL Component', () => { it('should render a dropdown item to delete the environment', () => { expect(findDropdownItem().exists()).toBe(true); - expect(wrapper.text()).toEqual('Delete environment'); - expect(findDropdownItem().attributes('variant')).toBe('danger'); + expect(findDropdownItem().props('item').text).toBe('Delete environment'); + expect(findDropdownItem().props('item').extraAttrs.variant).toBe('danger'); }); it('emits requestDeleteEnvironment in the event hub when button is clicked', () => { jest.spyOn(mockApollo.defaultClient, 'mutate'); - findDropdownItem().vm.$emit('click'); + findDropdownItem().vm.$emit('action'); expect(mockApollo.defaultClient.mutate).toHaveBeenCalledWith({ mutation: setEnvironmentToDelete, variables: { environment: resolvedEnvironment }, diff --git a/spec/frontend/environments/environment_pin_spec.js b/spec/frontend/environments/environment_pin_spec.js index ee195b41bc8..bf371978d72 100644 --- a/spec/frontend/environments/environment_pin_spec.js +++ b/spec/frontend/environments/environment_pin_spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; -import { GlDropdownItem } from '@gitlab/ui'; +import { GlDisclosureDropdownItem } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import cancelAutoStopMutation from '~/environments/graphql/mutations/cancel_auto_stop.mutation.graphql'; import createMockApollo from 'helpers/mock_apollo_helper'; @@ -18,6 +18,8 @@ describe('Pin Component', () => { const autoStopUrl = '/root/auto-stop-env-test/-/environments/38/cancel_auto_stop'; + const findDropdownItem = () => wrapper.findComponent(GlDisclosureDropdownItem); + describe('without graphql', () => { beforeEach(() => { factory({ @@ -28,14 +30,13 @@ describe('Pin Component', () => { }); it('should render the component with descriptive text', () => { - expect(wrapper.text()).toBe('Prevent auto-stopping'); + expect(findDropdownItem().props('item').text).toBe('Prevent auto-stopping'); }); it('should emit onPinClick when clicked', () => { const eventHubSpy = jest.spyOn(eventHub, '$emit'); - const item = wrapper.findComponent(GlDropdownItem); - item.vm.$emit('click'); + findDropdownItem().vm.$emit('action'); expect(eventHubSpy).toHaveBeenCalledWith('cancelAutoStop', autoStopUrl); }); @@ -57,14 +58,13 @@ describe('Pin Component', () => { }); it('should render the component with descriptive text', () => { - expect(wrapper.text()).toBe('Prevent auto-stopping'); + expect(findDropdownItem().props('item').text).toBe('Prevent auto-stopping'); }); it('should emit onPinClick when clicked', () => { jest.spyOn(mockApollo.defaultClient, 'mutate'); - const item = wrapper.findComponent(GlDropdownItem); - item.vm.$emit('click'); + findDropdownItem().vm.$emit('action'); expect(mockApollo.defaultClient.mutate).toHaveBeenCalledWith({ mutation: cancelAutoStopMutation, diff --git a/spec/frontend/environments/environment_rollback_spec.js b/spec/frontend/environments/environment_rollback_spec.js index 5d36209f8a6..653be6c1fde 100644 --- a/spec/frontend/environments/environment_rollback_spec.js +++ b/spec/frontend/environments/environment_rollback_spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; -import { GlDropdownItem } from '@gitlab/ui'; +import { GlDisclosureDropdownItem } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import RollbackComponent from '~/environments/components/environment_rollback.vue'; import eventHub from '~/environments/event_hub'; @@ -8,10 +8,14 @@ import setEnvironmentToRollback from '~/environments/graphql/mutations/set_envir import createMockApollo from 'helpers/mock_apollo_helper'; describe('Rollback Component', () => { + let wrapper; + const retryUrl = 'https://gitlab.com/retry'; + const findDropdownItem = () => wrapper.findComponent(GlDisclosureDropdownItem); + it('Should render Re-deploy label when isLastDeployment is true', () => { - const wrapper = shallowMount(RollbackComponent, { + wrapper = shallowMount(RollbackComponent, { propsData: { retryUrl, isLastDeployment: true, @@ -19,11 +23,11 @@ describe('Rollback Component', () => { }, }); - expect(wrapper.text()).toBe('Re-deploy to environment'); + expect(findDropdownItem().props('item').text).toBe('Re-deploy to environment'); }); it('Should render Rollback label when isLastDeployment is false', () => { - const wrapper = shallowMount(RollbackComponent, { + wrapper = shallowMount(RollbackComponent, { propsData: { retryUrl, isLastDeployment: false, @@ -31,12 +35,12 @@ describe('Rollback Component', () => { }, }); - expect(wrapper.text()).toBe('Rollback environment'); + expect(findDropdownItem().props('item').text).toBe('Rollback environment'); }); it('should emit a "rollback" event on button click', () => { const eventHubSpy = jest.spyOn(eventHub, '$emit'); - const wrapper = shallowMount(RollbackComponent, { + wrapper = shallowMount(RollbackComponent, { propsData: { retryUrl, environment: { @@ -44,9 +48,8 @@ describe('Rollback Component', () => { }, }, }); - const button = wrapper.findComponent(GlDropdownItem); - button.vm.$emit('click'); + findDropdownItem().vm.$emit('action'); expect(eventHubSpy).toHaveBeenCalledWith('requestRollbackEnvironment', { retryUrl, @@ -63,7 +66,8 @@ describe('Rollback Component', () => { const environment = { name: 'test', }; - const wrapper = shallowMount(RollbackComponent, { + + wrapper = shallowMount(RollbackComponent, { propsData: { retryUrl, graphql: true, @@ -71,8 +75,8 @@ describe('Rollback Component', () => { }, apolloProvider, }); - const button = wrapper.findComponent(GlDropdownItem); - button.vm.$emit('click'); + + findDropdownItem().vm.$emit('action'); expect(apolloProvider.defaultClient.mutate).toHaveBeenCalledWith({ mutation: setEnvironmentToRollback, diff --git a/spec/frontend/environments/environment_terminal_button_spec.js b/spec/frontend/environments/environment_terminal_button_spec.js index ab9f370595f..0a5ac96d26f 100644 --- a/spec/frontend/environments/environment_terminal_button_spec.js +++ b/spec/frontend/environments/environment_terminal_button_spec.js @@ -17,7 +17,7 @@ describe('Terminal Component', () => { }); it('should render a link to open a web terminal with the provided path', () => { - const link = wrapper.findByRole('menuitem', { name: __('Terminal') }); + const link = wrapper.findByRole('link', { name: __('Terminal') }); expect(link.attributes('href')).toBe(terminalPath); }); diff --git a/spec/frontend/environments/new_environment_item_spec.js b/spec/frontend/environments/new_environment_item_spec.js index 02100046167..eb6990ba8a8 100644 --- a/spec/frontend/environments/new_environment_item_spec.js +++ b/spec/frontend/environments/new_environment_item_spec.js @@ -201,7 +201,7 @@ describe('~/environments/components/new_environment_item.vue', () => { it('shows the option to rollback/re-deploy if available', () => { wrapper = createWrapper({ apolloProvider: createApolloProvider() }); - const rollback = wrapper.findByRole('menuitem', { + const rollback = wrapper.findByRole('button', { name: s__('Environments|Re-deploy to environment'), }); @@ -214,7 +214,7 @@ describe('~/environments/components/new_environment_item.vue', () => { apolloProvider: createApolloProvider(), }); - const rollback = wrapper.findByRole('menuitem', { + const rollback = wrapper.findByRole('button', { name: s__('Environments|Re-deploy to environment'), }); @@ -240,7 +240,7 @@ describe('~/environments/components/new_environment_item.vue', () => { }); it('shows the option to pin the environment if there is an autostop date', () => { - const pin = wrapper.findByRole('menuitem', { name: __('Prevent auto-stopping') }); + const pin = wrapper.findByRole('button', { name: __('Prevent auto-stopping') }); expect(pin.exists()).toBe(true); }); @@ -260,7 +260,7 @@ describe('~/environments/components/new_environment_item.vue', () => { it('does not show the option to pin the environment if there is no autostop date', () => { wrapper = createWrapper({ apolloProvider: createApolloProvider() }); - const pin = wrapper.findByRole('menuitem', { name: __('Prevent auto-stopping') }); + const pin = wrapper.findByRole('button', { name: __('Prevent auto-stopping') }); expect(pin.exists()).toBe(false); }); @@ -295,7 +295,7 @@ describe('~/environments/components/new_environment_item.vue', () => { it('does not show the option to pin the environment if there is no autostop date', () => { wrapper = createWrapper({ apolloProvider: createApolloProvider() }); - const pin = wrapper.findByRole('menuitem', { name: __('Prevent auto-stopping') }); + const pin = wrapper.findByRole('button', { name: __('Prevent auto-stopping') }); expect(pin.exists()).toBe(false); }); @@ -319,17 +319,17 @@ describe('~/environments/components/new_environment_item.vue', () => { apolloProvider: createApolloProvider(), }); - const rollback = wrapper.findByRole('menuitem', { name: __('Terminal') }); + const terminal = wrapper.findByRole('link', { name: __('Terminal') }); - expect(rollback.exists()).toBe(true); + expect(terminal.exists()).toBe(true); }); it('does not show the link to the terminal if not set up', () => { wrapper = createWrapper({ apolloProvider: createApolloProvider() }); - const rollback = wrapper.findByRole('menuitem', { name: __('Terminal') }); + const terminal = wrapper.findByRole('link', { name: __('Terminal') }); - expect(rollback.exists()).toBe(false); + expect(terminal.exists()).toBe(false); }); }); @@ -342,21 +342,21 @@ describe('~/environments/components/new_environment_item.vue', () => { apolloProvider: createApolloProvider(), }); - const rollback = wrapper.findByRole('menuitem', { + const deleteTrigger = wrapper.findByRole('button', { name: s__('Environments|Delete environment'), }); - expect(rollback.exists()).toBe(true); + expect(deleteTrigger.exists()).toBe(true); }); it('does not show the button to delete the environment if not possible', () => { wrapper = createWrapper({ apolloProvider: createApolloProvider() }); - const rollback = wrapper.findByRole('menuitem', { + const deleteTrigger = wrapper.findByRole('button', { name: s__('Environments|Delete environment'), }); - expect(rollback.exists()).toBe(false); + expect(deleteTrigger.exists()).toBe(false); }); }); diff --git a/spec/frontend/integrations/edit/components/override_dropdown_spec.js b/spec/frontend/integrations/edit/components/override_dropdown_spec.js index 2d1a6b3ace1..a528816971a 100644 --- a/spec/frontend/integrations/edit/components/override_dropdown_spec.js +++ b/spec/frontend/integrations/edit/components/override_dropdown_spec.js @@ -1,4 +1,4 @@ -import { GlDropdown, GlLink } from '@gitlab/ui'; +import { GlCollapsibleListbox, GlLink } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import OverrideDropdown from '~/integrations/edit/components/override_dropdown.vue'; @@ -27,14 +27,14 @@ describe('OverrideDropdown', () => { }; const findGlLink = () => wrapper.findComponent(GlLink); - const findGlDropdown = () => wrapper.findComponent(GlDropdown); + const findGlCollapsibleListbox = () => wrapper.findComponent(GlCollapsibleListbox); describe('template', () => { describe('override prop is true', () => { it('renders GlToggle as disabled', () => { createComponent(); - expect(findGlDropdown().props('text')).toBe('Use custom settings'); + expect(findGlCollapsibleListbox().props('toggleText')).toBe('Use custom settings'); }); }); @@ -42,7 +42,7 @@ describe('OverrideDropdown', () => { it('renders GlToggle as disabled', () => { createComponent({ override: false }); - expect(findGlDropdown().props('text')).toBe('Use default settings'); + expect(findGlCollapsibleListbox().props('toggleText')).toBe('Use default settings'); }); }); diff --git a/spec/lib/gitlab/data_builder/pipeline_spec.rb b/spec/lib/gitlab/data_builder/pipeline_spec.rb index eb348f5b497..a379af7483b 100644 --- a/spec/lib/gitlab/data_builder/pipeline_spec.rb +++ b/spec/lib/gitlab/data_builder/pipeline_spec.rb @@ -33,6 +33,7 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do expect(attributes[:iid]).to eq(pipeline.iid) expect(attributes[:source]).to eq(pipeline.source) expect(attributes[:status]).to eq(pipeline.status) + expect(attributes[:url]).to eq(Gitlab::Routing.url_helpers.project_pipeline_url(pipeline.project, pipeline)) expect(attributes[:detailed_status]).to eq('passed') expect(build_data).to be_a(Hash) expect(build_data[:id]).to eq(build.id) diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 5e4032fbd4b..52de8d39724 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -765,6 +765,7 @@ project: - freeze_periods - pumble_integration - webex_teams_integration +- telegram_integration - build_report_results - vulnerability_statistic - vulnerability_historical_statistics diff --git a/spec/lib/sidebars/groups/super_sidebar_menus/secure_menu_spec.rb b/spec/lib/sidebars/groups/super_sidebar_menus/secure_menu_spec.rb index 9eb81dda462..cdb853876f1 100644 --- a/spec/lib/sidebars/groups/super_sidebar_menus/secure_menu_spec.rb +++ b/spec/lib/sidebars/groups/super_sidebar_menus/secure_menu_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Sidebars::Groups::SuperSidebarMenus::SecureMenu, feature_category expect(items.map(&:item_id)).to eq([ :security_dashboard, :vulnerability_report, + :dependency_list, :audit_events, :compliance, :scan_policies diff --git a/spec/models/integrations/telegram_spec.rb b/spec/models/integrations/telegram_spec.rb new file mode 100644 index 00000000000..c3a66c84f09 --- /dev/null +++ b/spec/models/integrations/telegram_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe Integrations::Telegram, feature_category: :integrations do + it_behaves_like "chat integration", "Telegram" do + let(:payload) do + { + text: be_present + } + end + end + + describe 'validations' do + context 'when integration is active' do + before do + subject.active = true + end + + it { is_expected.to validate_presence_of(:token) } + it { is_expected.to validate_presence_of(:room) } + end + + context 'when integration is inactive' do + before do + subject.active = false + end + + it { is_expected.not_to validate_presence_of(:token) } + it { is_expected.not_to validate_presence_of(:room) } + end + end + + describe 'before_validation :set_webhook' do + context 'when token is not present' do + let(:integration) { build(:telegram_integration, token: nil) } + + it 'does not set webhook value' do + expect(integration.webhook).to eq(nil) + expect(integration).not_to be_valid + end + end + + context 'when token is present' do + let(:integration) { create(:telegram_integration) } + + it 'sets webhook value' do + expect(integration).to be_valid + expect(integration.webhook).to eq("https://api.telegram.org/bot123456:ABC-DEF1234/sendMessage") + end + end + end +end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 4bbe0d52486..14d885892ed 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -2111,15 +2111,48 @@ RSpec.describe Issue, feature_category: :team_planning do end describe 'issue_type enum generated methods' do - using RSpec::Parameterized::TableSyntax + describe '#<issue_type>?' do + let_it_be(:issue) { create(:issue, project: reusable_project) } - let_it_be(:issue) { create(:issue, project: reusable_project) } + where(issue_type: WorkItems::Type.base_types.keys) + + with_them do + it 'raises an error if called' do + expect { issue.public_send("#{issue_type}?".to_sym) }.to raise_error( + Issue::ForbiddenColumnUsed, + a_string_matching(/`issue\.#{issue_type}\?` uses the `issue_type` column underneath/) + ) + end + end + end - where(issue_type: WorkItems::Type.base_types.keys) + describe '.<issue_type> scopes' do + where(issue_type: WorkItems::Type.base_types.keys) - with_them do - it 'raises an error if called' do - expect { issue.public_send("#{issue_type}?".to_sym) }.to raise_error(Issue::ForbiddenColumnUsed) + with_them do + it 'raises an error if called' do + expect { Issue.public_send(issue_type.to_sym) }.to raise_error( + Issue::ForbiddenColumnUsed, + a_string_matching(/`Issue\.#{issue_type}` uses the `issue_type` column underneath/) + ) + end + + context 'when called in a production environment' do + before do + stub_rails_env('production') + end + + it 'returns issues scoped by type instead of raising an error' do + issue = create( + :issue, + issue_type: issue_type, + work_item_type: WorkItems::Type.default_by_type(issue_type), + project: reusable_project + ) + + expect(Issue.public_send(issue_type.to_sym)).to contain_exactly(issue) + end + end end end end diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index aea7a3b52c9..e1629dd354e 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -15,7 +15,6 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do let(:repository_storage) { 'default' } describe 'associations' do - it { is_expected.to belong_to(:organization).class_name('Organizations::Organization') } it { is_expected.to have_many :projects } it { is_expected.to have_many :project_statistics } it { is_expected.to belong_to :parent } @@ -2746,11 +2745,4 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do end end end - - context 'with loose foreign key on organization_id' do - it_behaves_like 'cleanup by a loose foreign key' do - let!(:parent) { create(:organization) } - let!(:model) { create(:namespace, organization: parent) } - end - end end diff --git a/spec/models/organizations/organization_spec.rb b/spec/models/organizations/organization_spec.rb index ec5aea519f5..cc2262634e3 100644 --- a/spec/models/organizations/organization_spec.rb +++ b/spec/models/organizations/organization_spec.rb @@ -6,11 +6,6 @@ RSpec.describe Organizations::Organization, type: :model, feature_category: :cel let_it_be(:organization) { create(:organization) } let_it_be(:default_organization) { create(:organization, :default) } - describe 'associations' do - it { is_expected.to have_many :namespaces } - it { is_expected.to have_many :groups } - end - describe 'validations' do subject { create(:organization) } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 51c87217d9d..2164d5fc787 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -49,6 +49,7 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr it { is_expected.to have_one(:microsoft_teams_integration) } it { is_expected.to have_one(:mattermost_integration) } it { is_expected.to have_one(:hangouts_chat_integration) } + it { is_expected.to have_one(:telegram_integration) } it { is_expected.to have_one(:unify_circuit_integration) } it { is_expected.to have_one(:pumble_integration) } it { is_expected.to have_one(:webex_teams_integration) } |