diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/services/issues | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/build_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/issues/create_service_spec.rb | 60 | ||||
-rw-r--r-- | spec/services/issues/relative_position_rebalancing_service_spec.rb | 15 | ||||
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 37 |
4 files changed, 42 insertions, 72 deletions
diff --git a/spec/services/issues/build_service_spec.rb b/spec/services/issues/build_service_spec.rb index 304e4bb3ebb..838e0675372 100644 --- a/spec/services/issues/build_service_spec.rb +++ b/spec/services/issues/build_service_spec.rb @@ -63,12 +63,14 @@ RSpec.describe Issues::BuildService do it 'wraps the note in a blockquote' do note_text = "This is a string\n"\ + "\n"\ ">>>\n"\ "with a blockquote\n"\ "> That has a quote\n"\ ">>>\n" note_result = " > This is a string\n"\ " > \n"\ + " > \n"\ " > > with a blockquote\n"\ " > > > That has a quote\n"\ " > \n" diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index 80c455e72b0..4a84862b9d5 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -416,7 +416,7 @@ RSpec.describe Issues::CreateService do context "when issuable feature is private" do before do project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE, - merge_requests_access_level: ProjectFeature::PRIVATE) + merge_requests_access_level: ProjectFeature::PRIVATE) end levels = [Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::PUBLIC] @@ -555,24 +555,29 @@ RSpec.describe Issues::CreateService do expect(reloaded_discussion.last_note.system).to eq(true) end - it 'assigns the title and description for the issue' do - issue = described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute + it 'sets default title and description values if not provided' do + issue = described_class.new( + project: project, current_user: user, + params: opts, + spam_params: spam_params + ).execute - expect(issue.title).not_to be_nil - expect(issue.description).not_to be_nil + expect(issue).to be_persisted + expect(issue.title).to eq("Follow-up from \"#{merge_request.title}\"") + expect(issue.description).to include("The following discussion from #{merge_request.to_reference} should be addressed") end - it 'can set nil explicitly to the title and description' do + it 'takes params from the request over the default values' do issue = described_class.new(project: project, current_user: user, - params: { - merge_request_to_resolve_discussions_of: merge_request, - description: nil, - title: nil - }, + params: opts.merge( + description: 'Custom issue description', + title: 'My new issue' + ), spam_params: spam_params).execute - expect(issue.description).to be_nil - expect(issue.title).to be_nil + expect(issue).to be_persisted + expect(issue.description).to eq('Custom issue description') + expect(issue.title).to eq('My new issue') end end @@ -594,24 +599,29 @@ RSpec.describe Issues::CreateService do expect(reloaded_discussion.last_note.system).to eq(true) end - it 'assigns the title and description for the issue' do - issue = described_class.new(project: project, current_user: user, params: opts, spam_params: spam_params).execute + it 'sets default title and description values if not provided' do + issue = described_class.new( + project: project, current_user: user, + params: opts, + spam_params: spam_params + ).execute - expect(issue.title).not_to be_nil - expect(issue.description).not_to be_nil + expect(issue).to be_persisted + expect(issue.title).to eq("Follow-up from \"#{merge_request.title}\"") + expect(issue.description).to include("The following discussion from #{merge_request.to_reference} should be addressed") end - it 'can set nil explicitly to the title and description' do + it 'takes params from the request over the default values' do issue = described_class.new(project: project, current_user: user, - params: { - merge_request_to_resolve_discussions_of: merge_request, - description: nil, - title: nil - }, + params: opts.merge( + description: 'Custom issue description', + title: 'My new issue' + ), spam_params: spam_params).execute - expect(issue.description).to be_nil - expect(issue.title).to be_nil + expect(issue).to be_persisted + expect(issue.description).to eq('Custom issue description') + expect(issue.title).to eq('My new issue') end end end diff --git a/spec/services/issues/relative_position_rebalancing_service_spec.rb b/spec/services/issues/relative_position_rebalancing_service_spec.rb index 20064bd7e4b..37a94e1d6a2 100644 --- a/spec/services/issues/relative_position_rebalancing_service_spec.rb +++ b/spec/services/issues/relative_position_rebalancing_service_spec.rb @@ -72,22 +72,8 @@ RSpec.describe Issues::RelativePositionRebalancingService, :clean_gitlab_redis_s end.not_to change { issues_in_position_order.map(&:id) } end - it 'does nothing if the feature flag is disabled' do - stub_feature_flags(rebalance_issues: false) - issue = project.issues.first - issue.project - issue.project.group - old_pos = issue.relative_position - - # fetching root namespace in the initializer triggers 2 queries: - # for fetching a random project from collection and fetching the root namespace. - expect { service.execute }.not_to exceed_query_limit(2) - expect(old_pos).to eq(issue.reload.relative_position) - end - it 'acts if the flag is enabled for the root namespace' do issue = create(:issue, project: project, author: user, relative_position: max_pos) - stub_feature_flags(rebalance_issues: project.root_namespace) expect { service.execute }.to change { issue.reload.relative_position } end @@ -95,7 +81,6 @@ RSpec.describe Issues::RelativePositionRebalancingService, :clean_gitlab_redis_s it 'acts if the flag is enabled for the group' do issue = create(:issue, project: project, author: user, relative_position: max_pos) project.update!(group: create(:group)) - stub_feature_flags(rebalance_issues: issue.project.group) expect { service.execute }.to change { issue.reload.relative_position } end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index aef3608831c..8a2e9ed74f7 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -48,6 +48,11 @@ RSpec.describe Issues::UpdateService, :mailer do described_class.new(project: project, current_user: user, params: opts).execute(issue) end + it_behaves_like 'issuable update service updating last_edited_at values' do + let(:issuable) { issue } + subject(:update_issuable) { update_issue(update_params) } + end + context 'valid params' do let(:opts) do { @@ -299,38 +304,6 @@ RSpec.describe Issues::UpdateService, :mailer do end end - it 'does not rebalance even if needed if the flag is disabled' do - stub_feature_flags(rebalance_issues: false) - - range = described_class::NO_REBALANCING_NEEDED - issue1 = create(:issue, project: project, relative_position: range.first - 100) - issue2 = create(:issue, project: project, relative_position: range.first) - issue.update!(relative_position: RelativePositioning::START_POSITION) - - opts[:move_between_ids] = [issue1.id, issue2.id] - - expect(Issues::RebalancingWorker).not_to receive(:perform_async) - - update_issue(opts) - expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) - end - - it 'rebalances if needed if the flag is enabled for the project' do - stub_feature_flags(rebalance_issues: project) - - range = described_class::NO_REBALANCING_NEEDED - issue1 = create(:issue, project: project, relative_position: range.first - 100) - issue2 = create(:issue, project: project, relative_position: range.first) - issue.update!(relative_position: RelativePositioning::START_POSITION) - - opts[:move_between_ids] = [issue1.id, issue2.id] - - expect(Issues::RebalancingWorker).to receive(:perform_async).with(nil, nil, project.root_namespace.id) - - update_issue(opts) - expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) - end - it 'rebalances if needed on the left' do range = described_class::NO_REBALANCING_NEEDED issue1 = create(:issue, project: project, relative_position: range.first - 100) |