diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-03 06:08:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-03 06:08:22 +0000 |
commit | d72fedf168dafcb38bd51b67f86804738000fb48 (patch) | |
tree | 24c96e700e2560835aff28ab5e4ca599875019b5 /spec | |
parent | 497b73152109b6da922e1a8ffd8ab193f7f3fcd3 (diff) | |
download | gitlab-ce-d72fedf168dafcb38bd51b67f86804738000fb48.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 4 | ||||
-rw-r--r-- | spec/controllers/projects/milestones_controller_spec.rb | 8 | ||||
-rw-r--r-- | spec/finders/issues_finder_spec.rb | 16 | ||||
-rw-r--r-- | spec/helpers/ci/pipelines_helper_spec.rb | 24 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/lint_spec.rb | 25 | ||||
-rw-r--r-- | spec/services/issuable/common_system_notes_service_spec.rb | 35 | ||||
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 12 | ||||
-rw-r--r-- | spec/services/merge_requests/update_service_spec.rb | 12 | ||||
-rw-r--r-- | spec/services/resource_events/synthetic_milestone_notes_builder_service_spec.rb | 23 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 12 | ||||
-rw-r--r-- | spec/services/system_notes/issuables_service_spec.rb | 58 | ||||
-rw-r--r-- | spec/support/shared_examples/services/issuable_shared_examples.rb | 31 | ||||
-rw-r--r-- | spec/views/projects/ci/lints/show.html.haml_spec.rb | 4 | ||||
-rw-r--r-- | spec/views/projects/pipelines/new.html.haml_spec.rb | 2 |
14 files changed, 64 insertions, 202 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 78de89de796..35d8c0b7c6d 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -422,10 +422,6 @@ RSpec.describe GroupsController do end context 'searching' do - before do - stub_feature_flags(attempt_group_search_optimizations: true) - end - it 'works with popularity sort' do get :issues, params: { id: group.to_param, search: 'foo', sort: 'popularity' } diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb index 0c7391c1b9c..fa32d32f552 100644 --- a/spec/controllers/projects/milestones_controller_spec.rb +++ b/spec/controllers/projects/milestones_controller_spec.rb @@ -135,10 +135,6 @@ RSpec.describe Projects::MilestonesController do end describe "#destroy" do - before do - stub_feature_flags(track_resource_milestone_change_events: false) - end - it "removes milestone" do expect(issue.milestone_id).to eq(milestone.id) @@ -153,10 +149,6 @@ RSpec.describe Projects::MilestonesController do merge_request.reload expect(merge_request.milestone_id).to eq(nil) - - # Check system note left for milestone removal - last_note = project.issues.find(issue.id).notes[-1].note - expect(last_note).to eq('removed milestone') end end diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index fb7d4e808fe..9cb4f8c9fc1 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -949,10 +949,6 @@ RSpec.describe IssuesFinder do describe '#use_cte_for_search?' do let(:finder) { described_class.new(nil, params) } - before do - stub_feature_flags(attempt_group_search_optimizations: true) - end - context 'when there is no search param' do let(:params) { { attempt_group_search_optimizations: true } } @@ -969,18 +965,6 @@ RSpec.describe IssuesFinder do end end - context 'when the attempt_group_search_optimizations flag is disabled' do - let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } - - before do - stub_feature_flags(attempt_group_search_optimizations: false) - end - - it 'returns false' do - expect(finder.use_cte_for_search?).to be_falsey - end - end - context 'when attempt_group_search_optimizations is unset and attempt_project_search_optimizations is set' do let(:params) { { search: 'foo', attempt_project_search_optimizations: true } } diff --git a/spec/helpers/ci/pipelines_helper_spec.rb b/spec/helpers/ci/pipelines_helper_spec.rb index 89b9907d0c2..a96d6e7711f 100644 --- a/spec/helpers/ci/pipelines_helper_spec.rb +++ b/spec/helpers/ci/pipelines_helper_spec.rb @@ -22,8 +22,8 @@ RSpec.describe Ci::PipelinesHelper do let(:warning_messages) { [double(content: 'Warning 1'), double(content: 'Warning 2')] } it 'returns a warning callout box' do - expect(subject).to have_css 'div.alert-warning' - expect(subject).to include 'Warning:' + expect(subject).to have_css 'div.bs-callout-warning' + expect(subject).to include '2 warning(s) found:' end it 'lists the the warnings' do @@ -32,4 +32,24 @@ RSpec.describe Ci::PipelinesHelper do end end end + + describe 'warning_header' do + subject { helper.warning_header(count) } + + context 'when warnings are more than max cap' do + let(:count) { 30 } + + it 'returns 30 warning(s) found: showing first 25' do + expect(subject).to eq('30 warning(s) found: showing first 25') + end + end + + context 'when warnings are less than max cap' do + let(:count) { 15 } + + it 'returns 15 warning(s) found' do + expect(subject).to eq('15 warning(s) found:') + end + end + end end diff --git a/spec/lib/gitlab/ci/lint_spec.rb b/spec/lib/gitlab/ci/lint_spec.rb index 02533779457..71bd68d287f 100644 --- a/spec/lib/gitlab/ci/lint_spec.rb +++ b/spec/lib/gitlab/ci/lint_spec.rb @@ -92,6 +92,31 @@ RSpec.describe Gitlab::Ci::Lint do end end + context 'when content has more warnings than max limit' do + # content will result in 2 warnings + let(:content) do + <<~YAML + rspec: + script: rspec + rules: + - when: always + rspec2: + script: rspec + rules: + - when: always + YAML + end + + before do + stub_const('Gitlab::Ci::Warnings::MAX_LIMIT', 1) + end + + it 'returns a result with warnings' do + expect(subject).to be_valid + expect(subject.warnings.size).to eq(1) + end + end + context 'when content has errors and warnings' do let(:content) do <<~YAML diff --git a/spec/services/issuable/common_system_notes_service_spec.rb b/spec/services/issuable/common_system_notes_service_spec.rb index daf4f68208e..217550542bb 100644 --- a/spec/services/issuable/common_system_notes_service_spec.rb +++ b/spec/services/issuable/common_system_notes_service_spec.rb @@ -32,17 +32,6 @@ RSpec.describe Issuable::CommonSystemNotesService do end end - context 'when new milestone is assigned' do - before do - milestone = create(:milestone, project: project) - issuable.milestone_id = milestone.id - - stub_feature_flags(track_resource_milestone_change_events: false) - end - - it_behaves_like 'system note creation', {}, 'changed milestone' - end - context 'with merge requests Draft note' do context 'adding Draft note' do let(:issuable) { create(:merge_request, title: "merge request") } @@ -100,32 +89,10 @@ RSpec.describe Issuable::CommonSystemNotesService do expect(event.user_id).to eq user.id end - context 'when milestone change event tracking is disabled' do - before do - stub_feature_flags(track_resource_milestone_change_events: false) - - issuable.milestone = create(:milestone, project: project) - issuable.save - end - - it 'creates a system note for milestone set' do - expect { subject }.to change { issuable.notes.count }.from(0).to(1) - expect(issuable.notes.last.note).to match('changed milestone') - end - - it 'does not create a milestone change event' do - expect { subject }.not_to change { ResourceMilestoneEvent.count } - end - end - - context 'when milestone change event tracking is enabled' do + context 'when changing milestones' do let_it_be(:milestone) { create(:milestone, project: project) } let_it_be(:issuable) { create(:issue, project: project, milestone: milestone) } - before do - stub_feature_flags(track_resource_milestone_change_events: true) - end - it 'does not create a system note for milestone set' do expect { subject }.not_to change { issuable.notes.count } end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 1fed6094314..81fac33a3c7 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -445,10 +445,6 @@ RSpec.describe Issues::UpdateService, :mailer do end context 'when the milestone is removed' do - before do - stub_feature_flags(track_resource_milestone_change_events: false) - end - let!(:non_subscriber) { create(:user) } let!(:subscriber) do @@ -458,8 +454,6 @@ RSpec.describe Issues::UpdateService, :mailer do end end - it_behaves_like 'system notes for milestones' - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do issue.milestone = create(:milestone, project: project) @@ -490,10 +484,6 @@ RSpec.describe Issues::UpdateService, :mailer do end context 'when the milestone is assigned' do - before do - stub_feature_flags(track_resource_milestone_change_events: false) - end - let!(:non_subscriber) { create(:user) } let!(:subscriber) do @@ -509,8 +499,6 @@ RSpec.describe Issues::UpdateService, :mailer do expect(todo.reload.done?).to eq true end - it_behaves_like 'system notes for milestones' - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do perform_enqueued_jobs do update_issue(milestone: create(:milestone, project: project)) diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index c3433c8c9d2..5f5a94da400 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -380,10 +380,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do end context 'when the milestone is removed' do - before do - stub_feature_flags(track_resource_milestone_change_events: false) - end - let!(:non_subscriber) { create(:user) } let!(:subscriber) do @@ -393,8 +389,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do end end - it_behaves_like 'system notes for milestones' - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do merge_request.milestone = create(:milestone, project: project) @@ -410,10 +404,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do end context 'when the milestone is changed' do - before do - stub_feature_flags(track_resource_milestone_change_events: false) - end - let!(:non_subscriber) { create(:user) } let!(:subscriber) do @@ -429,8 +419,6 @@ RSpec.describe MergeRequests::UpdateService, :mailer do expect(pending_todo.reload).to be_done end - it_behaves_like 'system notes for milestones' - it 'sends notifications for subscribers of changed milestone', :sidekiq_might_not_need_inline do perform_enqueued_jobs do update_merge_request(milestone: create(:milestone, project: project)) diff --git a/spec/services/resource_events/synthetic_milestone_notes_builder_service_spec.rb b/spec/services/resource_events/synthetic_milestone_notes_builder_service_spec.rb index 5e3afeabee7..1b35e224e98 100644 --- a/spec/services/resource_events/synthetic_milestone_notes_builder_service_spec.rb +++ b/spec/services/resource_events/synthetic_milestone_notes_builder_service_spec.rb @@ -6,20 +6,23 @@ RSpec.describe ResourceEvents::SyntheticMilestoneNotesBuilderService do describe '#execute' do let_it_be(:user) { create(:user) } let_it_be(:issue) { create(:issue, author: user) } + let_it_be(:milestone) { create(:milestone, project: issue.project) } - before do - create_list(:resource_milestone_event, 3, issue: issue) - - stub_feature_flags(track_resource_milestone_change_events: false) + let_it_be(:events) do + [ + create(:resource_milestone_event, issue: issue, milestone: milestone, action: :add, created_at: '2020-01-01 04:00'), + create(:resource_milestone_event, issue: issue, milestone: milestone, action: :remove, created_at: '2020-01-02 08:00') + ] end - context 'when resource milestone events are disabled' do - # https://gitlab.com/gitlab-org/gitlab/-/issues/212985 - it 'still builds notes for existing resource milestone events' do - notes = described_class.new(issue, user).execute + it 'builds milestone notes for resource milestone events' do + notes = described_class.new(issue, user).execute - expect(notes.size).to eq(3) - end + expect(notes.map(&:created_at)).to eq(events.map(&:created_at)) + expect(notes.map(&:note)).to eq([ + "changed milestone to %#{milestone.iid}", + 'removed milestone' + ]) end end end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index d166a9b5ab2..47b8621b5c9 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -74,18 +74,6 @@ RSpec.describe SystemNoteService do end end - describe '.change_milestone' do - let(:milestone) { double } - - it 'calls IssuableService' do - expect_next_instance_of(::SystemNotes::IssuablesService) do |service| - expect(service).to receive(:change_milestone).with(milestone) - end - - described_class.change_milestone(noteable, project, author, milestone) - end - end - describe '.relate_issue' do let(:noteable_ref) { double } let(:noteable) { double } diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb index 536e9792534..fec2a711dc2 100644 --- a/spec/services/system_notes/issuables_service_spec.rb +++ b/spec/services/system_notes/issuables_service_spec.rb @@ -128,64 +128,6 @@ RSpec.describe ::SystemNotes::IssuablesService do end end - describe '#change_milestone' do - subject { service.change_milestone(milestone) } - - context 'for a project milestone' do - let(:milestone) { create(:milestone, project: project) } - - it_behaves_like 'a system note' do - let(:action) { 'milestone' } - end - - context 'when milestone added' do - it 'sets the note text' do - reference = milestone.to_reference(format: :iid) - - expect(subject.note).to eq "changed milestone to #{reference}" - end - - it_behaves_like 'a note with overridable created_at' - end - - context 'when milestone removed' do - let(:milestone) { nil } - - it 'sets the note text' do - expect(subject.note).to eq 'removed milestone' - end - - it_behaves_like 'a note with overridable created_at' - end - end - - context 'for a group milestone' do - let(:milestone) { create(:milestone, group: group) } - - it_behaves_like 'a system note' do - let(:action) { 'milestone' } - end - - context 'when milestone added' do - it 'sets the note text to use the milestone name' do - expect(subject.note).to eq "changed milestone to #{milestone.to_reference(format: :name)}" - end - - it_behaves_like 'a note with overridable created_at' - end - - context 'when milestone removed' do - let(:milestone) { nil } - - it 'sets the note text' do - expect(subject.note).to eq 'removed milestone' - end - - it_behaves_like 'a note with overridable created_at' - end - end - end - describe '#change_status' do subject { service.change_status(status, source) } diff --git a/spec/support/shared_examples/services/issuable_shared_examples.rb b/spec/support/shared_examples/services/issuable_shared_examples.rb index dd866c0a8dc..47c7a1e7356 100644 --- a/spec/support/shared_examples/services/issuable_shared_examples.rb +++ b/spec/support/shared_examples/services/issuable_shared_examples.rb @@ -8,37 +8,6 @@ RSpec.shared_examples 'cache counters invalidator' do end end -RSpec.shared_examples 'system notes for milestones' do - def update_issuable(opts) - issuable = try(:issue) || try(:merge_request) - described_class.new(project, user, opts).execute(issuable) - end - - context 'group milestones' do - let(:group) { create(:group) } - let(:group_milestone) { create(:milestone, group: group) } - - before do - project.update!(namespace: group) - create(:group_member, group: group, user: user) - end - - it 'creates a system note' do - expect do - update_issuable(milestone: group_milestone) - end.to change { Note.system.count }.by(1) - end - end - - context 'project milestones' do - it 'creates a system note' do - expect do - update_issuable(milestone: create(:milestone, project: project)) - end.to change { Note.system.count }.by(1) - end - end -end - RSpec.shared_examples 'updating a single task' do def update_issuable(opts) issuable = try(:issue) || try(:merge_request) diff --git a/spec/views/projects/ci/lints/show.html.haml_spec.rb b/spec/views/projects/ci/lints/show.html.haml_spec.rb index e9eb281a798..712f1437a8c 100644 --- a/spec/views/projects/ci/lints/show.html.haml_spec.rb +++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb @@ -87,7 +87,7 @@ RSpec.describe 'projects/ci/lints/show' do it 'shows warning messages' do render - expect(rendered).to have_content('Warning:') + expect(rendered).to have_content('2 warning(s) found:') expect(rendered).to have_content('Warning 1') expect(rendered).to have_content('Warning 2') end @@ -116,7 +116,7 @@ RSpec.describe 'projects/ci/lints/show' do it 'shows warning messages' do render - expect(rendered).to have_content('Warning:') + expect(rendered).to have_content('2 warning(s) found:') expect(rendered).to have_content('Warning 1') expect(rendered).to have_content('Warning 2') end diff --git a/spec/views/projects/pipelines/new.html.haml_spec.rb b/spec/views/projects/pipelines/new.html.haml_spec.rb index 2deacfa8478..9c5e46b6a17 100644 --- a/spec/views/projects/pipelines/new.html.haml_spec.rb +++ b/spec/views/projects/pipelines/new.html.haml_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'projects/pipelines/new' do it 'displays the warnings' do render - expect(rendered).to have_css('div.alert-warning') + expect(rendered).to have_css('div.bs-callout-warning') expect(rendered).to have_content('warning 1') expect(rendered).to have_content('warning 2') end |