diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-17 00:09:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-17 00:09:11 +0300 |
commit | fe530c6e7f3253de54a37ba68767c36c9d28ecec (patch) | |
tree | ec5d694d5c1f963e4ba189464ec886212e84759b /spec/models | |
parent | c44eade0d7b09c9d80c42aba6d1974ce9cd3146b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/merge_request_spec.rb | 197 | ||||
-rw-r--r-- | spec/models/namespace_spec.rb | 72 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 3 | ||||
-rw-r--r-- | spec/models/onboarding/progress_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/operations/feature_flags/strategy_spec.rb | 201 | ||||
-rw-r--r-- | spec/models/pages_domain_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 105 | ||||
-rw-r--r-- | spec/models/project_team_spec.rb | 27 | ||||
-rw-r--r-- | spec/models/release_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/remote_mirror_spec.rb | 44 |
10 files changed, 389 insertions, 292 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 2a35efed8e0..e16f7a94eb7 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1041,10 +1041,12 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev let(:tag_name) { subject.source_branch } it 'returns the sha of the source branch last commit' do - subject.source_project.repository.add_tag(subject.author, - tag_name, - subject.target_branch_sha, - 'Add a tag') + subject.source_project.repository.add_tag( + subject.author, + tag_name, + subject.target_branch_sha, + 'Add a tag' + ) expect(subject.source_branch_sha).to eq(last_branch_commit.sha) @@ -1392,8 +1394,7 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev before do allow(merge_request).to receive(:commits) { [merge_request.source_project.repository.commit] } - create(:note_on_commit, commit_id: merge_request.commits.first.id, - project: merge_request.project) + create(:note_on_commit, commit_id: merge_request.commits.first.id, project: merge_request.project) create(:note, noteable: merge_request, project: merge_request.project) end @@ -1403,16 +1404,19 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev end it "includes notes for commits from target project as well" do - create(:note_on_commit, commit_id: merge_request.commits.first.id, - project: merge_request.target_project) + create(:note_on_commit, commit_id: merge_request.commits.first.id, project: merge_request.target_project) expect(merge_request.commits).not_to be_empty expect(merge_request.related_notes.count).to eq(3) end it "excludes system notes for commits" do - system_note = create(:note_on_commit, :system, commit_id: merge_request.commits.first.id, - project: merge_request.project) + system_note = create( + :note_on_commit, + :system, + commit_id: merge_request.commits.first.id, + project: merge_request.project + ) expect(merge_request.related_notes.count).to eq(2) expect(merge_request.related_notes).not_to include(system_note) @@ -2168,10 +2172,12 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev context 'when there is a pipeline with the diff head sha' do let!(:pipeline) do - create(:ci_empty_pipeline, - project: merge_request.project, - sha: merge_request.diff_head_sha, - ref: merge_request.source_branch) + create( + :ci_empty_pipeline, + project: merge_request.project, + sha: merge_request.diff_head_sha, + ref: merge_request.source_branch + ) end it 'updates the head pipeline' do @@ -2200,12 +2206,14 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev context 'when detached merge request pipeline is run on head ref of the merge request' do let!(:pipeline) do - create(:ci_pipeline, - source: :merge_request_event, - project: merge_request.source_project, - ref: merge_request.ref_path, - sha: sha, - merge_request: merge_request) + create( + :ci_pipeline, + source: :merge_request_event, + project: merge_request.source_project, + ref: merge_request.ref_path, + sha: sha, + merge_request: merge_request + ) end let(:sha) { merge_request.diff_head_sha } @@ -2565,11 +2573,13 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev let(:merge_request) { create(:merge_request, source_project: project) } let!(:base_pipeline) do - create(:ci_pipeline, - :with_test_reports, - project: project, - ref: merge_request.target_branch, - sha: merge_request.diff_base_sha) + create( + :ci_pipeline, + :with_test_reports, + project: project, + ref: merge_request.target_branch, + sha: merge_request.diff_base_sha + ) end before do @@ -2578,11 +2588,13 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev context 'when head pipeline has test reports' do let!(:head_pipeline) do - create(:ci_pipeline, - :with_test_reports, - project: project, - ref: merge_request.source_branch, - sha: merge_request.diff_head_sha) + create( + :ci_pipeline, + :with_test_reports, + project: project, + ref: merge_request.source_branch, + sha: merge_request.diff_head_sha + ) end context 'when reactive cache worker is parsing asynchronously' do @@ -2618,10 +2630,12 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev context 'when head pipeline does not have test reports' do let!(:head_pipeline) do - create(:ci_pipeline, - project: project, - ref: merge_request.source_branch, - sha: merge_request.diff_head_sha) + create( + :ci_pipeline, + project: project, + ref: merge_request.source_branch, + sha: merge_request.diff_head_sha + ) end it 'returns status and error message' do @@ -2923,10 +2937,12 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev before do project.add_maintainer(current_user) - ProcessCommitWorker.new.perform(project.id, - current_user.id, - project.commit(revert_commit_id).to_hash, - project.default_branch == branch) + ProcessCommitWorker.new.perform( + project.id, + current_user.id, + project.commit(revert_commit_id).to_hash, + project.default_branch == branch + ) end context 'but merged at timestamp cannot be found' do @@ -3023,10 +3039,13 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev context 'when resource event for the merge exists' do before do - SystemNoteService.change_status(merge_request, - merge_request.target_project, - user, - merge_request.state, nil) + SystemNoteService.change_status( + merge_request, + merge_request.target_project, + user, + merge_request.state, + nil + ) end it 'returns the resource event creation date' do @@ -3194,9 +3213,7 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev context 'with skip_ci_check option' do before do - allow(subject).to receive_messages(check_mergeability: nil, - can_be_merged?: true, - broken?: false) + allow(subject).to receive_messages(check_mergeability: nil, can_be_merged?: true, broken?: false) end where(:mergeable_ci_state, :skip_ci_check, :expected_mergeable) do @@ -3217,10 +3234,12 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev context 'with skip_discussions_check option' do before do - allow(subject).to receive_messages(mergeable_ci_state?: true, - check_mergeability: nil, - can_be_merged?: true, - broken?: false) + allow(subject).to receive_messages( + mergeable_ci_state?: true, + check_mergeability: nil, + can_be_merged?: true, + broken?: false + ) end where(:mergeable_discussions_state, :skip_discussions_check, :expected_mergeable) do @@ -3713,17 +3732,21 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev expect_any_instance_of(Discussions::UpdateDiffPositionService).to receive(:execute).with(discussion).and_call_original - subject.update_diff_discussion_positions(old_diff_refs: old_diff_refs, - new_diff_refs: new_diff_refs, - current_user: subject.author) + subject.update_diff_discussion_positions( + old_diff_refs: old_diff_refs, + new_diff_refs: new_diff_refs, + current_user: subject.author + ) end it 'does not call the resolve method' do expect(MergeRequests::ResolvedDiscussionNotificationService).not_to receive(:new) - subject.update_diff_discussion_positions(old_diff_refs: old_diff_refs, - new_diff_refs: new_diff_refs, - current_user: subject.author) + subject.update_diff_discussion_positions( + old_diff_refs: old_diff_refs, + new_diff_refs: new_diff_refs, + current_user: subject.author + ) end context 'when resolve_outdated_diff_discussions is set' do @@ -3738,9 +3761,11 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev expect_any_instance_of(MergeRequests::ResolvedDiscussionNotificationService) .to receive(:execute).with(subject) - subject.update_diff_discussion_positions(old_diff_refs: old_diff_refs, - new_diff_refs: new_diff_refs, - current_user: subject.author) + subject.update_diff_discussion_positions( + old_diff_refs: old_diff_refs, + new_diff_refs: new_diff_refs, + current_user: subject.author + ) end end @@ -3750,9 +3775,11 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev it 'does not call the resolve method' do expect(MergeRequests::ResolvedDiscussionNotificationService).not_to receive(:new) - subject.update_diff_discussion_positions(old_diff_refs: old_diff_refs, - new_diff_refs: new_diff_refs, - current_user: subject.author) + subject.update_diff_discussion_positions( + old_diff_refs: old_diff_refs, + new_diff_refs: new_diff_refs, + current_user: subject.author + ) end end @@ -3764,9 +3791,11 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev it 'does not call the resolve method' do expect(MergeRequests::ResolvedDiscussionNotificationService).not_to receive(:new) - subject.update_diff_discussion_positions(old_diff_refs: old_diff_refs, - new_diff_refs: new_diff_refs, - current_user: subject.author) + subject.update_diff_discussion_positions( + old_diff_refs: old_diff_refs, + new_diff_refs: new_diff_refs, + current_user: subject.author + ) end end end @@ -4903,10 +4932,7 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev let(:target_project) { create(:project, :public) } let(:source_project) { fork_project(target_project) } let(:merge_request) do - create(:merge_request, - source_project: source_project, - source_branch: 'fixes', - target_project: target_project) + create(:merge_request, source_project: source_project, source_branch: 'fixes', target_project: target_project) end let(:user) { create(:user) } @@ -4936,10 +4962,7 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev let(:user) { create(:user) } subject do - create(:merge_request, - merge_when_pipeline_succeeds: true, - merge_user: user, - author: user) + create(:merge_request, merge_when_pipeline_succeeds: true, merge_user: user, author: user) end context 'author is not a project member' do @@ -4963,9 +4986,7 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev let(:merge_user) { create(:user) } subject do - create(:merge_request, - merge_when_pipeline_succeeds: true, - merge_user: merge_user) + create(:merge_request, merge_when_pipeline_succeeds: true, merge_user: merge_user) end before do @@ -5118,20 +5139,24 @@ RSpec.describe MergeRequest, factory_default: :keep, feature_category: :code_rev let!(:project) { create(:project) } let!(:fork) { fork_project(project) } let!(:merge_request1) do - create(:merge_request, - :merge_when_pipeline_succeeds, - target_project: project, - target_branch: 'master', - source_project: project, - source_branch: 'feature-1') + create( + :merge_request, + :merge_when_pipeline_succeeds, + target_project: project, + target_branch: 'master', + source_project: project, + source_branch: 'feature-1' + ) end let!(:merge_request4) do - create(:merge_request, - target_project: project, - target_branch: 'master', - source_project: fork, - source_branch: 'fork-feature-2') + create( + :merge_request, + target_project: project, + target_branch: 'master', + source_project: fork, + source_branch: 'fork-feature-2' + ) end let(:query) { described_class.with_auto_merge_enabled } diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index e1629dd354e..3d7d5062ca7 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -1103,32 +1103,39 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do let(:project1) do create(:project, - namespace: namespace, - statistics: build(:project_statistics, - namespace: namespace, - repository_size: 101, - wiki_size: 505, - lfs_objects_size: 202, - build_artifacts_size: 303, - pipeline_artifacts_size: 707, - packages_size: 404, - snippets_size: 605, - uploads_size: 808)) + namespace: namespace, + statistics: build( + :project_statistics, + namespace: namespace, + repository_size: 101, + wiki_size: 505, + lfs_objects_size: 202, + build_artifacts_size: 303, + pipeline_artifacts_size: 707, + packages_size: 404, + snippets_size: 605, + uploads_size: 808 + ) + ) end let(:project2) do - create(:project, - namespace: namespace, - statistics: build(:project_statistics, - namespace: namespace, - repository_size: 10, - wiki_size: 50, - lfs_objects_size: 20, - build_artifacts_size: 30, - pipeline_artifacts_size: 70, - packages_size: 40, - snippets_size: 60, - uploads_size: 80)) + create( + :project, + namespace: namespace, + statistics: build( + :project_statistics, + namespace: namespace, + repository_size: 10, + wiki_size: 50, + lfs_objects_size: 20, + build_artifacts_size: 30, + pipeline_artifacts_size: 70, + packages_size: 40, + snippets_size: 60, + uploads_size: 80 + ) + ) end it "sums all project storage counters in the namespace" do @@ -1191,8 +1198,9 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do end it 'raises an error about not movable project' do - expect { namespace.move_dir }.to raise_error(Gitlab::UpdatePathError, - /Namespace .* cannot be moved/) + expect { namespace.move_dir }.to raise_error( + Gitlab::UpdatePathError, /Namespace .* cannot be moved/ + ) end end end @@ -1857,16 +1865,12 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to( receive(:bulk_perform_in) - .with(1.hour, - [[group_one_user.id]], - batch_delay: 30.seconds, batch_size: 100) + .with(1.hour, [[group_one_user.id]], batch_delay: 30.seconds, batch_size: 100) ) expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to( receive(:bulk_perform_in) - .with(1.hour, - [[group_two_user.id]], - batch_delay: 30.seconds, batch_size: 100) + .with(1.hour, [[group_two_user.id]], batch_delay: 30.seconds, batch_size: 100) ) execute_update @@ -1885,12 +1889,10 @@ RSpec.describe Namespace, feature_category: :groups_and_projects do it 'updates the authorizations in a non-blocking manner' do expect(AuthorizedProjectsWorker).to( - receive(:bulk_perform_async) - .with([[group_one_user.id]])).once + receive(:bulk_perform_async).with([[group_one_user.id]])).once expect(AuthorizedProjectsWorker).to( - receive(:bulk_perform_async) - .with([[group_two_user.id]])).once + receive(:bulk_perform_async).with([[group_two_user.id]])).once execute_update end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index f82235916f2..e99d77dc0a0 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -53,8 +53,7 @@ RSpec.describe Note, feature_category: :team_planning do context 'when noteable and note project differ' do subject do - build(:note, noteable: build_stubbed(:issue), - project: build_stubbed(:project)) + build(:note, noteable: build_stubbed(:issue), project: build_stubbed(:project)) end it { is_expected.to be_invalid } diff --git a/spec/models/onboarding/progress_spec.rb b/spec/models/onboarding/progress_spec.rb index 7d169464462..c45d8c97385 100644 --- a/spec/models/onboarding/progress_spec.rb +++ b/spec/models/onboarding/progress_spec.rb @@ -77,8 +77,10 @@ RSpec.describe Onboarding::Progress do describe '.completed_actions_with_latest_in_range' do subject do - described_class.completed_actions_with_latest_in_range(actions, - 1.day.ago.beginning_of_day..1.day.ago.end_of_day) + described_class.completed_actions_with_latest_in_range( + actions, + 1.day.ago.beginning_of_day..1.day.ago.end_of_day + ) end let!(:one_action_completed_in_range_one_action_incompleted) do diff --git a/spec/models/operations/feature_flags/strategy_spec.rb b/spec/models/operations/feature_flags/strategy_spec.rb index 949f92b3b2a..91a465025a2 100644 --- a/spec/models/operations/feature_flags/strategy_spec.rb +++ b/spec/models/operations/feature_flags/strategy_spec.rb @@ -20,10 +20,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'skips parameters validation' do - strategy = build(:operations_strategy, - feature_flag: feature_flag, - name: invalid_name, - parameters: { bad: 'params' }) + strategy = build( + :operations_strategy, + feature_flag: feature_flag, + name: invalid_name, + parameters: { bad: 'params' } + ) expect(strategy).to be_invalid @@ -40,10 +42,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'must have valid parameters for the strategy' do - strategy = build(:operations_strategy, - :gradual_rollout, - feature_flag: feature_flag, - parameters: invalid_parameters) + strategy = build( + :operations_strategy, + :gradual_rollout, + feature_flag: feature_flag, + parameters: invalid_parameters + ) expect(strategy).to be_invalid @@ -52,10 +56,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end it 'allows the parameters in any order' do - strategy = build(:operations_strategy, - :gradual_rollout, - feature_flag: feature_flag, - parameters: { percentage: '10', groupId: 'mygroup' }) + strategy = build( + :operations_strategy, + :gradual_rollout, + feature_flag: feature_flag, + parameters: { percentage: '10', groupId: 'mygroup' } + ) expect(strategy).to be_valid end @@ -68,10 +74,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'must be a string value between 0 and 100 inclusive and without a percentage sign' do - strategy = build(:operations_strategy, - :gradual_rollout, - feature_flag: feature_flag, - parameters: { groupId: 'mygroup', percentage: invalid_value }) + strategy = build( + :operations_strategy, + :gradual_rollout, + feature_flag: feature_flag, + parameters: { groupId: 'mygroup', percentage: invalid_value } + ) expect(strategy).to be_invalid @@ -84,10 +92,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'must be a string value between 0 and 100 inclusive and without a percentage sign' do - strategy = build(:operations_strategy, - :gradual_rollout, - feature_flag: feature_flag, - parameters: { groupId: 'mygroup', percentage: valid_value }) + strategy = build( + :operations_strategy, + :gradual_rollout, + feature_flag: feature_flag, + parameters: { groupId: 'mygroup', percentage: valid_value } + ) expect(strategy).to be_valid end @@ -101,10 +111,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'must be a string value of up to 32 lowercase characters' do - strategy = build(:operations_strategy, - :gradual_rollout, - feature_flag: feature_flag, - parameters: { groupId: invalid_value, percentage: '40' }) + strategy = build( + :operations_strategy, + :gradual_rollout, + feature_flag: feature_flag, + parameters: { groupId: invalid_value, percentage: '40' } + ) expect(strategy).to be_invalid @@ -117,10 +129,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'must be a string value of up to 32 lowercase characters' do - strategy = build(:operations_strategy, - :gradual_rollout, - feature_flag: feature_flag, - parameters: { groupId: valid_value, percentage: '40' }) + strategy = build( + :operations_strategy, + :gradual_rollout, + feature_flag: feature_flag, + parameters: { groupId: valid_value, percentage: '40' } + ) expect(strategy).to be_valid end @@ -141,10 +155,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do ]) with_them do it 'must have valid parameters for the strategy' do - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: invalid_parameters) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: invalid_parameters + ) expect(strategy).to be_invalid @@ -158,10 +174,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do [:groupId, 'mygroup'] ].permutation(3).each do |parameters| it "allows the parameters in the order #{parameters.map { |p| p.first }.join(', ')}" do - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: Hash[parameters]) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: Hash[parameters] + ) expect(strategy).to be_valid end @@ -174,10 +192,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do with_them do it 'must be a string value between 0 and 100 inclusive and without a percentage sign' do parameters = { stickiness: 'default', groupId: 'mygroup', rollout: invalid_value } - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: parameters) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: parameters + ) expect(strategy).to be_invalid @@ -189,10 +209,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do with_them do it 'must be a string value between 0 and 100 inclusive and without a percentage sign' do parameters = { stickiness: 'default', groupId: 'mygroup', rollout: valid_value } - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: parameters) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: parameters + ) expect(strategy).to be_valid end @@ -205,10 +227,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do with_them do it 'must be a string value of up to 32 lowercase characters' do parameters = { stickiness: 'default', groupId: invalid_value, rollout: '40' } - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: parameters) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: parameters + ) expect(strategy).to be_invalid @@ -220,10 +244,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do with_them do it 'must be a string value of up to 32 lowercase characters' do parameters = { stickiness: 'default', groupId: valid_value, rollout: '40' } - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: parameters) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: parameters + ) expect(strategy).to be_valid end @@ -235,10 +261,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do with_them do it 'must be a string representing a supported stickiness setting' do parameters = { stickiness: invalid_value, groupId: 'mygroup', rollout: '40' } - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: parameters) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: parameters + ) expect(strategy).to be_invalid @@ -251,10 +279,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do with_them do it 'must be a string representing a supported stickiness setting' do parameters = { stickiness: valid_value, groupId: 'mygroup', rollout: '40' } - strategy = build(:operations_strategy, - :flexible_rollout, - feature_flag: feature_flag, - parameters: parameters) + strategy = build( + :operations_strategy, + :flexible_rollout, + feature_flag: feature_flag, + parameters: parameters + ) expect(strategy).to be_valid end @@ -268,9 +298,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'must have valid parameters for the strategy' do - strategy = build(:operations_strategy, - feature_flag: feature_flag, - name: 'userWithId', parameters: invalid_parameters) + strategy = build( + :operations_strategy, + feature_flag: feature_flag, + name: 'userWithId', + parameters: invalid_parameters + ) expect(strategy).to be_invalid @@ -287,10 +320,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'is valid with a string of comma separated values' do - strategy = build(:operations_strategy, - feature_flag: feature_flag, - name: 'userWithId', - parameters: { userIds: valid_value }) + strategy = build( + :operations_strategy, + feature_flag: feature_flag, + name: 'userWithId', + parameters: { userIds: valid_value } + ) expect(strategy).to be_valid end @@ -303,10 +338,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'is invalid' do - strategy = build(:operations_strategy, - feature_flag: feature_flag, - name: 'userWithId', - parameters: { userIds: invalid_value }) + strategy = build( + :operations_strategy, + feature_flag: feature_flag, + name: 'userWithId', + parameters: { userIds: invalid_value } + ) expect(strategy).to be_invalid @@ -347,11 +384,13 @@ RSpec.describe Operations::FeatureFlags::Strategy do end with_them do it 'is invalid' do - strategy = build(:operations_strategy, - :gitlab_userlist, - user_list: user_list, - feature_flag: feature_flag, - parameters: invalid_value) + strategy = build( + :operations_strategy, + :gitlab_userlist, + user_list: user_list, + feature_flag: feature_flag, + parameters: invalid_value + ) expect(strategy).to be_invalid @@ -360,10 +399,12 @@ RSpec.describe Operations::FeatureFlags::Strategy do end it 'is valid' do - strategy = build(:operations_strategy, - :gitlab_userlist, - user_list: user_list, - feature_flag: feature_flag) + strategy = build( + :operations_strategy, + :gitlab_userlist, + user_list: user_list, + feature_flag: feature_flag + ) expect(strategy).to be_valid end diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb index b218d4dce09..2c63306bd0a 100644 --- a/spec/models/pages_domain_spec.rb +++ b/spec/models/pages_domain_spec.rb @@ -427,23 +427,27 @@ RSpec.describe PagesDomain do end describe '#user_provided_key=' do - include_examples('certificate setter', 'key', 'user_provided_key=', - 'gitlab_provided', 'user_provided') + include_examples( + 'certificate setter', 'key', 'user_provided_key=', 'gitlab_provided', 'user_provided' + ) end describe '#gitlab_provided_key=' do - include_examples('certificate setter', 'key', 'gitlab_provided_key=', - 'user_provided', 'gitlab_provided') + include_examples( + 'certificate setter', 'key', 'gitlab_provided_key=', 'user_provided', 'gitlab_provided' + ) end describe '#user_provided_certificate=' do - include_examples('certificate setter', 'certificate', 'user_provided_certificate=', - 'gitlab_provided', 'user_provided') + include_examples( + 'certificate setter', 'certificate', 'user_provided_certificate=', 'gitlab_provided', 'user_provided' + ) end describe '#gitlab_provided_certificate=' do - include_examples('certificate setter', 'certificate', 'gitlab_provided_certificate=', - 'user_provided', 'gitlab_provided') + include_examples( + 'certificate setter', 'certificate', 'gitlab_provided_certificate=', 'user_provided', 'gitlab_provided' + ) end describe '#save' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 2164d5fc787..f44331521e9 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -209,9 +209,12 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr project = create(:project) lfs_object = create(:lfs_object) [:project, :design].each do |repository_type| - create(:lfs_objects_project, project: project, - lfs_object: lfs_object, - repository_type: repository_type) + create( + :lfs_objects_project, + project: project, + lfs_object: lfs_object, + repository_type: repository_type + ) end expect(project.lfs_objects_projects.size).to eq(2) @@ -781,14 +784,11 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr describe 'project pending deletion' do let!(:project_pending_deletion) do - create(:project, - pending_delete: true) + create(:project, pending_delete: true) end let(:new_project) do - build(:project, - path: project_pending_deletion.path, - namespace: project_pending_deletion.namespace) + build(:project, path: project_pending_deletion.path, namespace: project_pending_deletion.namespace) end before do @@ -3397,8 +3397,7 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr before do create(:container_repository, project: project, name: 'image') - stub_container_registry_tags(repository: /image/, - tags: %w[latest rc1]) + stub_container_registry_tags(repository: /image/, tags: %w[latest rc1]) end it 'has image tags' do @@ -3408,8 +3407,7 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr context 'when tags are present for root repository' do before do - stub_container_registry_tags(repository: project.full_path, - tags: %w[latest rc1 pre1]) + stub_container_registry_tags(repository: project.full_path, tags: %w[latest rc1 pre1]) end it 'has image tags' do @@ -3527,18 +3525,15 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr let(:second_branch) { project.repository.branches[2] } let!(:pipeline_for_default_branch) do - create(:ci_pipeline, project: project, sha: project.commit.id, - ref: project.default_branch) + create(:ci_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) end let!(:pipeline_for_second_branch) do - create(:ci_pipeline, project: project, sha: second_branch.target, - ref: second_branch.name) + create(:ci_pipeline, project: project, sha: second_branch.target, ref: second_branch.name) end let!(:other_pipeline_for_default_branch) do - create(:ci_pipeline, project: project, sha: project.commit.parent.id, - ref: project.default_branch) + create(:ci_pipeline, project: project, sha: project.commit.parent.id, ref: project.default_branch) end context 'default repository branch' do @@ -3568,8 +3563,12 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr context 'with provided sha' do let!(:latest_pipeline_for_ref) do - create(:ci_pipeline, project: project, sha: pipeline_for_second_branch.sha, - ref: pipeline_for_second_branch.ref) + create( + :ci_pipeline, + project: project, + sha: pipeline_for_second_branch.sha, + ref: pipeline_for_second_branch.ref + ) end subject { project.latest_pipeline(second_branch.name, second_branch.target) } @@ -4442,21 +4441,25 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr let(:project) { create(:project) } let!(:default_cluster) do - create(:cluster, - :not_managed, - platform_type: :kubernetes, - projects: [project], - environment_scope: '*', - platform_kubernetes: default_cluster_kubernetes) + create( + :cluster, + :not_managed, + platform_type: :kubernetes, + projects: [project], + environment_scope: '*', + platform_kubernetes: default_cluster_kubernetes + ) end let!(:review_env_cluster) do - create(:cluster, - :not_managed, - platform_type: :kubernetes, - projects: [project], - environment_scope: 'review/*', - platform_kubernetes: review_env_cluster_kubernetes) + create( + :cluster, + :not_managed, + platform_type: :kubernetes, + projects: [project], + environment_scope: 'review/*', + platform_kubernetes: review_env_cluster_kubernetes + ) end let(:default_cluster_kubernetes) { create(:cluster_platform_kubernetes, token: 'default-AAA') } @@ -6572,12 +6575,14 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr end it 'does not allow access to branches for which the merge request was closed' do - create(:merge_request, :closed, - target_project: target_project, - target_branch: 'target-branch', - source_project: project, - source_branch: 'rejected-feature-1', - allow_collaboration: true) + create( + :merge_request, :closed, + target_project: target_project, + target_branch: 'target-branch', + source_project: project, + source_branch: 'rejected-feature-1', + allow_collaboration: true + ) expect(project.branch_allows_collaboration?(user, 'rejected-feature-1')) .to be_falsy @@ -6612,8 +6617,7 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr it 'returns the classification label if it was configured on the project' do enable_external_authorization_service_check - project = build(:project, - external_authorization_classification_label: 'hello') + project = build(:project, external_authorization_classification_label: 'hello') expect(project.external_authorization_classification_label) .to eq('hello') @@ -9066,16 +9070,21 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr end def create_pipeline(project, status = 'success') - create(:ci_pipeline, project: project, - sha: project.commit.sha, - ref: project.default_branch, - status: status) + create( + :ci_pipeline, + project: project, + sha: project.commit.sha, + ref: project.default_branch, + status: status + ) end def create_build(new_pipeline = pipeline, name = 'test') - create(:ci_build, :success, :artifacts, - pipeline: new_pipeline, - status: new_pipeline.status, - name: name) + create( + :ci_build, :success, :artifacts, + pipeline: new_pipeline, + status: new_pipeline.status, + name: name + ) end end diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb index 4ff77faf5bf..f3139e72113 100644 --- a/spec/models/project_team_spec.rb +++ b/spec/models/project_team_spec.rb @@ -126,9 +126,12 @@ RSpec.describe ProjectTeam, feature_category: :groups_and_projects do it 'returns invited members of a group' do group_member = create(:group_member) - create(:project_group_link, group: group_member.group, - project: project, - group_access: Gitlab::Access::GUEST) + create( + :project_group_link, + group: group_member.group, + project: project, + group_access: Gitlab::Access::GUEST + ) expect(project.team.members) .to contain_exactly(group_member.user, project.first_owner) @@ -136,9 +139,12 @@ RSpec.describe ProjectTeam, feature_category: :groups_and_projects do it 'returns invited members of a group of a specified level' do group_member = create(:group_member) - create(:project_group_link, group: group_member.group, - project: project, - group_access: Gitlab::Access::REPORTER) + create( + :project_group_link, + group: group_member.group, + project: project, + group_access: Gitlab::Access::REPORTER + ) expect(project.team.guests).to be_empty expect(project.team.reporters).to contain_exactly(group_member.user) @@ -579,8 +585,7 @@ RSpec.describe ProjectTeam, feature_category: :groups_and_projects do all_users = users + [new_contributor.id, second_new_user.id] create(:merge_request, :merged, author: new_contributor, target_project: project, source_project: new_fork_project, target_branch: project.default_branch.to_s) - expected_all = expected.merge(new_contributor.id => true, - second_new_user.id => false) + expected_all = expected.merge(new_contributor.id => true, second_new_user.id => false) contributors(users) @@ -677,8 +682,10 @@ RSpec.describe ProjectTeam, feature_category: :groups_and_projects do second_new_user = create(:user) all_users = users + [new_user.id, second_new_user.id] - expected_all = expected.merge(new_user.id => Gitlab::Access::NO_ACCESS, - second_new_user.id => Gitlab::Access::NO_ACCESS) + expected_all = expected.merge( + new_user.id => Gitlab::Access::NO_ACCESS, + second_new_user.id => Gitlab::Access::NO_ACCESS + ) access_levels(users) diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb index 863cc11f0b2..bddd0516400 100644 --- a/spec/models/release_spec.rb +++ b/spec/models/release_spec.rb @@ -54,9 +54,9 @@ RSpec.describe Release, feature_category: :release_orchestration do it 'creates a validation error' do milestone = build(:milestone, project: create(:project)) - expect { release.milestones << milestone } - .to raise_error(ActiveRecord::RecordInvalid, - 'Validation failed: Release does not have the same project as the milestone') + expect { release.milestones << milestone }.to raise_error( + ActiveRecord::RecordInvalid, 'Validation failed: Release does not have the same project as the milestone' + ) end end diff --git a/spec/models/remote_mirror_spec.rb b/spec/models/remote_mirror_spec.rb index adb4777ae90..382718620f5 100644 --- a/spec/models/remote_mirror_spec.rb +++ b/spec/models/remote_mirror_spec.rb @@ -252,19 +252,23 @@ RSpec.describe RemoteMirror, :mailer do context 'stuck mirrors' do it 'includes mirrors that were started over an hour ago' do - mirror = create_mirror(url: 'http://cantbeblank', - update_status: 'started', - last_update_started_at: 3.hours.ago, - last_update_at: 2.hours.ago) + mirror = create_mirror( + url: 'http://cantbeblank', + update_status: 'started', + last_update_started_at: 3.hours.ago, + last_update_at: 2.hours.ago + ) expect(described_class.stuck.last).to eq(mirror) end it 'includes mirrors started over 3 hours ago for their first sync' do - mirror = create_mirror(url: 'http://cantbeblank', - update_status: 'started', - last_update_at: nil, - last_update_started_at: 4.hours.ago) + mirror = create_mirror( + url: 'http://cantbeblank', + update_status: 'started', + last_update_at: nil, + last_update_started_at: 4.hours.ago + ) expect(described_class.stuck.last).to eq(mirror) end @@ -358,11 +362,13 @@ RSpec.describe RemoteMirror, :mailer do let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first } it 'resets all the columns when URL changes' do - remote_mirror.update!(last_error: Time.current, - last_update_at: Time.current, - last_successful_update_at: Time.current, - update_status: 'started', - error_notification_sent: true) + remote_mirror.update!( + last_error: Time.current, + last_update_at: Time.current, + last_successful_update_at: Time.current, + update_status: 'started', + error_notification_sent: true + ) expect { remote_mirror.update_attribute(:url, 'http://new.example.com') } .to change { remote_mirror.last_error }.to(nil) @@ -406,11 +412,13 @@ RSpec.describe RemoteMirror, :mailer do context 'no project' do it 'includes mirror with a project in pending_delete' do - mirror = create_mirror(url: 'http://cantbeblank', - update_status: 'finished', - enabled: true, - last_update_at: nil, - updated_at: 25.hours.ago) + mirror = create_mirror( + url: 'http://cantbeblank', + update_status: 'finished', + enabled: true, + last_update_at: nil, + updated_at: 25.hours.ago + ) project = mirror.project project.pending_delete = true project.save! |