Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-15 18:08:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-15 18:08:59 +0300
commit51858218a3961c6d872703eabde0635bc0a1368f (patch)
tree4b62ba865821631fcc2e68025a5fade1b1e7b069 /spec
parent6986c1adc235859111e45593bb0bd61e70892d3c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/notes/components/note_actions/reply_button_spec.js19
-rw-r--r--spec/lib/gitlab/background_migration/populate_issue_email_participants_spec.rb20
-rw-r--r--spec/lib/gitlab/email/handler/service_desk_handler_spec.rb7
-rw-r--r--spec/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter_spec.rb8
-rw-r--r--spec/migrations/schedule_populate_issue_email_participants_spec.rb33
-rw-r--r--spec/support/shared_examples/services/issuable_shared_examples.rb21
6 files changed, 95 insertions, 13 deletions
diff --git a/spec/frontend/notes/components/note_actions/reply_button_spec.js b/spec/frontend/notes/components/note_actions/reply_button_spec.js
index a8e8d23a6c1..4993ded365d 100644
--- a/spec/frontend/notes/components/note_actions/reply_button_spec.js
+++ b/spec/frontend/notes/components/note_actions/reply_button_spec.js
@@ -1,29 +1,22 @@
-import { createLocalVue, mount } from '@vue/test-utils';
-import Vuex from 'vuex';
+import { GlButton } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
import ReplyButton from '~/notes/components/note_actions/reply_button.vue';
-const localVue = createLocalVue();
-localVue.use(Vuex);
-
describe('ReplyButton', () => {
let wrapper;
beforeEach(() => {
- wrapper = mount(localVue.extend(ReplyButton), {
- localVue,
- });
+ wrapper = shallowMount(ReplyButton);
});
afterEach(() => {
wrapper.destroy();
+ wrapper = null;
});
it('emits startReplying on click', () => {
- const button = wrapper.find({ ref: 'button' });
-
- button.trigger('click');
+ wrapper.find(GlButton).vm.$emit('click');
- expect(wrapper.emitted().startReplying).toBeTruthy();
- expect(wrapper.emitted().startReplying.length).toBe(1);
+ expect(wrapper.emitted('startReplying')).toEqual([[]]);
});
});
diff --git a/spec/lib/gitlab/background_migration/populate_issue_email_participants_spec.rb b/spec/lib/gitlab/background_migration/populate_issue_email_participants_spec.rb
new file mode 100644
index 00000000000..f724b007e01
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/populate_issue_email_participants_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::BackgroundMigration::PopulateIssueEmailParticipants, schema: 20201128210234 do
+ let!(:namespace) { table(:namespaces).create!(name: 'namespace', path: 'namespace') }
+ let!(:project) { table(:projects).create!(id: 1, namespace_id: namespace.id) }
+ let!(:issue1) { table(:issues).create!(id: 1, project_id: project.id, service_desk_reply_to: "a@gitlab.com") }
+ let!(:issue2) { table(:issues).create!(id: 2, project_id: project.id, service_desk_reply_to: "b@gitlab.com") }
+ let(:issue_email_participants) { table(:issue_email_participants) }
+
+ describe '#perform' do
+ it 'migrates email addresses from service desk issues', :aggregate_failures do
+ expect { subject.perform(1, 2) }.to change { issue_email_participants.count }.by(2)
+
+ expect(issue_email_participants.find_by(issue_id: 1).email).to eq("a@gitlab.com")
+ expect(issue_email_participants.find_by(issue_id: 2).email).to eq("b@gitlab.com")
+ end
+ end
+end
diff --git a/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb b/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
index b1ffbedc7bf..eb11c051adc 100644
--- a/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb
@@ -40,6 +40,13 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do
expect(new_issue.description).to eq(expected_description.strip)
end
+ it 'creates an issue_email_participant' do
+ receiver.execute
+ new_issue = Issue.last
+
+ expect(new_issue.issue_email_participants.first.email).to eq("jake@adventuretime.ooo")
+ end
+
it 'sends thank you email' do
expect { receiver.execute }.to have_enqueued_job.on_queue('mailers')
end
diff --git a/spec/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter_spec.rb
index 8c4beb46701..6377d7156fb 100644
--- a/spec/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter_spec.rb
+++ b/spec/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter_spec.rb
@@ -237,6 +237,14 @@ RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :cl
end
end
+ describe '.track_task_item_status_changed' do
+ subject { described_class.track_task_item_status_changed(user: user) }
+
+ it_behaves_like 'a tracked merge request unique event' do
+ let(:action) { described_class::MR_TASK_ITEM_STATUS_CHANGED_ACTION }
+ end
+ end
+
describe '.track_users_review_requested' do
subject { described_class.track_users_review_requested(users: [user]) }
diff --git a/spec/migrations/schedule_populate_issue_email_participants_spec.rb b/spec/migrations/schedule_populate_issue_email_participants_spec.rb
new file mode 100644
index 00000000000..a3f18617b70
--- /dev/null
+++ b/spec/migrations/schedule_populate_issue_email_participants_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20201128210234_schedule_populate_issue_email_participants.rb')
+
+RSpec.describe SchedulePopulateIssueEmailParticipants do
+ let!(:namespace) { table(:namespaces).create!(name: 'namespace', path: 'namespace') }
+ let!(:project) { table(:projects).create!(id: 1, namespace_id: namespace.id) }
+ let!(:issue1) { table(:issues).create!(id: 1, project_id: project.id, service_desk_reply_to: "a@gitlab.com") }
+ let!(:issue2) { table(:issues).create!(id: 2, project_id: project.id) }
+ let!(:issue3) { table(:issues).create!(id: 3, project_id: project.id, service_desk_reply_to: "b@gitlab.com") }
+ let!(:issue4) { table(:issues).create!(id: 4, project_id: project.id, service_desk_reply_to: "c@gitlab.com") }
+ let!(:issue5) { table(:issues).create!(id: 5, project_id: project.id, service_desk_reply_to: "d@gitlab.com") }
+ let(:issue_email_participants) { table(:issue_email_participants) }
+
+ it 'correctly schedules background migrations' do
+ stub_const("#{described_class.name}::BATCH_SIZE", 2)
+
+ Sidekiq::Testing.fake! do
+ freeze_time do
+ migrate!
+
+ expect(described_class::MIGRATION)
+ .to be_scheduled_delayed_migration(2.minutes, 1, 3)
+
+ expect(described_class::MIGRATION)
+ .to be_scheduled_delayed_migration(4.minutes, 4, 5)
+
+ expect(BackgroundMigrationWorker.jobs.size).to eq(2)
+ end
+ end
+ end
+end
diff --git a/spec/support/shared_examples/services/issuable_shared_examples.rb b/spec/support/shared_examples/services/issuable_shared_examples.rb
index 47c7a1e7356..5b3e0f9e0b9 100644
--- a/spec/support/shared_examples/services/issuable_shared_examples.rb
+++ b/spec/support/shared_examples/services/issuable_shared_examples.rb
@@ -18,6 +18,27 @@ RSpec.shared_examples 'updating a single task' do
update_issuable(description: "- [ ] Task 1\n- [ ] Task 2")
end
+ context 'usage counters' do
+ it 'update as expected' do
+ if try(:merge_request)
+ expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
+ .to receive(:track_task_item_status_changed).once.with(user: user)
+ else
+ expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
+ .not_to receive(:track_task_item_status_changed)
+ end
+
+ update_issuable(
+ update_task: {
+ index: 1,
+ checked: true,
+ line_source: '- [ ] Task 1',
+ line_number: 1
+ }
+ )
+ end
+ end
+
context 'when a task is marked as completed' do
before do
update_issuable(update_task: { index: 1, checked: true, line_source: '- [ ] Task 1', line_number: 1 })