2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
RSpec.shared_examples 'has user mentions' do
|
2020-01-01 13:55:28 +05:30
|
|
|
describe '#has_mentions?' do
|
|
|
|
context 'when no mentions' do
|
|
|
|
it 'returns false' do
|
|
|
|
expect(subject.mentioned_users_ids).to be nil
|
|
|
|
expect(subject.mentioned_projects_ids).to be nil
|
|
|
|
expect(subject.mentioned_groups_ids).to be nil
|
|
|
|
expect(subject.has_mentions?).to be false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when mentioned_users_ids not null' do
|
|
|
|
subject { described_class.new(mentioned_users_ids: [1, 2, 3]) }
|
|
|
|
|
|
|
|
it 'returns true' do
|
|
|
|
expect(subject.has_mentions?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when mentioned projects' do
|
|
|
|
subject { described_class.new(mentioned_projects_ids: [1, 2, 3]) }
|
|
|
|
|
|
|
|
it 'returns true' do
|
|
|
|
expect(subject.has_mentions?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when mentioned groups' do
|
|
|
|
subject { described_class.new(mentioned_groups_ids: [1, 2, 3]) }
|
|
|
|
|
|
|
|
it 'returns true' do
|
|
|
|
expect(subject.has_mentions?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|