Commit 8a4cf342 authored by Eugenia Grieff's avatar Eugenia Grieff

Add specs todos created by issuables mentions

parent 42e6e1a7
---
title: Do not generate To-Dos additional when editing group mentions
merge_request: 19037
author:
type: fixed
......@@ -136,6 +136,40 @@ describe Epics::UpdateService do
expect(todo2.reload.state).to eq('pending')
end
end
context 'mentioning a group in epic description' do
let(:mentioned1) { create(:user) }
let(:mentioned2) { create(:user) }
before do
group.add_developer(mentioned1)
epic.update(description: "FYI: #{group.to_reference}")
end
context 'when the group is public' do
before do
group.update(visibility: Gitlab::VisibilityLevel::PUBLIC)
end
it 'creates todos for only newly mentioned users' do
expect do
update_epic(description: "FYI: #{mentioned1.to_reference} #{mentioned2.to_reference}")
end.to change { Todo.count }.by(1)
end
end
context 'when the group is private' do
before do
group.update(visibility: Gitlab::VisibilityLevel::PRIVATE)
end
it 'creates todos for only newly mentioned users that are group members' do
expect do
update_epic(description: "FYI: #{mentioned1.to_reference} #{mentioned2.to_reference}")
end.to not_change { Todo.count }
end
end
end
end
context 'when Epic has tasks' do
......
......@@ -58,9 +58,25 @@ RSpec.shared_examples 'updating mentions' do |service_class|
end
end
shared_examples 'updating attribute with existing group mention' do |attribute|
before do
mentionable.update!({ attribute => "FYI: #{group.to_reference}" })
end
it 'creates todos for only newly mentioned users' do
expect do
update_mentionable(
{ attribute => "For #{group.to_reference}, cc: #{mentioned_user.to_reference}" }
)
end.to change { Todo.count }.by(1)
end
end
context 'when group is public' do
it_behaves_like 'updating attribute with allowed mentions', :title
it_behaves_like 'updating attribute with allowed mentions', :description
it_behaves_like 'updating attribute with existing group mention', :title
it_behaves_like 'updating attribute with existing group mention', :description
end
context 'when the group is private' do
......@@ -70,6 +86,8 @@ RSpec.shared_examples 'updating mentions' do |service_class|
it_behaves_like 'updating attribute with allowed mentions', :title
it_behaves_like 'updating attribute with allowed mentions', :description
it_behaves_like 'updating attribute with existing group mention', :title
it_behaves_like 'updating attribute with existing group mention', :description
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment