diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 23:02:30 +0300 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/support/shared_examples/models/concerns | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/support/shared_examples/models/concerns')
4 files changed, 55 insertions, 22 deletions
diff --git a/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb b/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb index 2a976fb7421..d6415e98289 100644 --- a/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/integrations/slack_mattermost_notifier_shared_examples.rb @@ -692,16 +692,6 @@ RSpec.shared_examples Integrations::SlackMattermostNotifier do |integration_name context 'notification enabled for all branches' do it_behaves_like "triggered #{integration_name} integration", event_type: "pipeline", branches_to_be_notified: "all" end - - context 'when chat_notification_deployment_protected_branch_filter is disabled' do - before do - stub_feature_flags(chat_notification_deployment_protected_branch_filter: false) - end - - context 'notification enabled only for default branch' do - it_behaves_like "triggered #{integration_name} integration", event_type: "pipeline", branches_to_be_notified: "default" - end - end end end end diff --git a/spec/support/shared_examples/models/concerns/limitable_shared_examples.rb b/spec/support/shared_examples/models/concerns/limitable_shared_examples.rb index 07d687147bc..0ff0895b861 100644 --- a/spec/support/shared_examples/models/concerns/limitable_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/limitable_shared_examples.rb @@ -23,7 +23,7 @@ RSpec.shared_examples 'includes Limitable concern' do context 'with an existing model' do before do - subject.dup.save! + subject.clone.save! end it 'cannot create new models exceeding the plan limits' do diff --git a/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb b/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb index 39121b73bc5..a2b4cdc33d0 100644 --- a/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/timebox_shared_examples.rb @@ -66,17 +66,6 @@ RSpec.shared_examples 'a timebox' do |timebox_type| end end - describe 'title' do - it { is_expected.to validate_presence_of(:title) } - - it 'is invalid if title would be empty after sanitation' do - timebox = build(timebox_type, *timebox_args, project: project, title: '<img src=x onerror=prompt(1)>') - - expect(timebox).not_to be_valid - expect(timebox.errors[:title]).to include("can't be blank") - end - end - describe '#timebox_type_check' do it 'is invalid if it has both project_id and group_id' do timebox = build(timebox_type, *timebox_args, group: group) diff --git a/spec/support/shared_examples/models/concerns/update_namespace_statistics_shared_examples.rb b/spec/support/shared_examples/models/concerns/update_namespace_statistics_shared_examples.rb new file mode 100644 index 00000000000..255b6efa518 --- /dev/null +++ b/spec/support/shared_examples/models/concerns/update_namespace_statistics_shared_examples.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'updates namespace statistics' do + let(:namespace_statistics_name) { described_class.namespace_statistics_name } + let(:statistic_attribute) { described_class.statistic_attribute } + + context 'when creating' do + before do + statistic_source.send("#{statistic_attribute}=", 10) + end + + it 'schedules a statistic refresh' do + expect(Groups::UpdateStatisticsWorker) + .to receive(:perform_async) + + statistic_source.save! + end + end + + context 'when updating' do + before do + statistic_source.save! + + expect(statistic_source).to be_persisted + end + + context 'when the statistic attribute has not changed' do + it 'does not schedule a statistic refresh' do + expect(Groups::UpdateStatisticsWorker) + .not_to receive(:perform_async) + + statistic_source.update!(file_name: 'new-file-name.txt') + end + end + + context 'when the statistic attribute has changed' do + it 'schedules a statistic refresh' do + expect(Groups::UpdateStatisticsWorker) + .to receive(:perform_async) + + statistic_source.update!(statistic_attribute => 20) + end + end + end + + context 'when deleting' do + it 'schedules a statistic refresh' do + expect(Groups::UpdateStatisticsWorker) + .to receive(:perform_async) + + statistic_source.destroy! + end + end +end |