diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 12:40:42 +0300 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/services/work_items/update_service_spec.rb | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/services/work_items/update_service_spec.rb')
-rw-r--r-- | spec/services/work_items/update_service_spec.rb | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/spec/services/work_items/update_service_spec.rb b/spec/services/work_items/update_service_spec.rb index e8b82b0b4f2..1761d1104dd 100644 --- a/spec/services/work_items/update_service_spec.rb +++ b/spec/services/work_items/update_service_spec.rb @@ -88,6 +88,26 @@ RSpec.describe WorkItems::UpdateService do end end + context 'when decription is changed' do + let(:opts) { { description: 'description changed' } } + + it 'triggers GraphQL description updated subscription' do + expect(GraphqlTriggers).to receive(:issuable_description_updated).with(work_item).and_call_original + + update_work_item + end + end + + context 'when decription is not changed' do + let(:opts) { { title: 'title changed' } } + + it 'does not trigger GraphQL description updated subscription' do + expect(GraphqlTriggers).not_to receive(:issuable_description_updated) + + update_work_item + end + end + context 'when updating state_event' do context 'when state_event is close' do let(:opts) { { state_event: 'close' } } @@ -292,5 +312,65 @@ RSpec.describe WorkItems::UpdateService do end end end + + describe 'label updates' do + let_it_be(:label1) { create(:label, project: project) } + let_it_be(:label2) { create(:label, project: project) } + + context 'when labels are changed' do + let(:label) { create(:label, project: project) } + let(:opts) { { label_ids: [label1.id] } } + + it 'tracks users updating work item labels' do + expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter).to receive(:track_work_item_labels_changed_action).with(author: current_user) + + update_work_item + end + + it_behaves_like 'broadcasting issuable labels updates' do + let(:issuable) { work_item } + let(:label_a) { label1 } + let(:label_b) { label2 } + + def update_issuable(update_params) + described_class.new( + project: project, + current_user: current_user, + params: update_params, + spam_params: spam_params, + widget_params: widget_params + ).execute(work_item) + end + end + end + + context 'when labels are not changed' do + shared_examples 'work item update that does not track label updates' do + it 'does not track users updating work item labels' do + expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter).not_to receive(:track_work_item_labels_changed_action) + + update_work_item + end + end + + context 'when labels param is not provided' do + let(:opts) { { title: 'not updating labels' } } + + it_behaves_like 'work item update that does not track label updates' + end + + context 'when labels param is provided but labels remain unchanged' do + let(:opts) { { label_ids: [] } } + + it_behaves_like 'work item update that does not track label updates' + end + + context 'when labels param is provided invalid values' do + let(:opts) { { label_ids: [non_existing_record_id] } } + + it_behaves_like 'work item update that does not track label updates' + end + end + end end end |