Commit 6474fe0d authored by Alex Kalderimis's avatar Alex Kalderimis

Verify design events are correctly visible

This tests that design events have the correct visibility behavior.

A new trait is adde dot the event factories to simplify creating design
events.
parent c9461083
......@@ -9,5 +9,15 @@ FactoryBot.modify do
action { Event::CREATED }
project { nil }
end
trait :for_design do
transient do
design { create(:design, issue: create(:issue, project: project)) }
note { create(:note, project: project, noteable: design) }
end
action { Event::COMMENTED }
target { note }
end
end
end
......@@ -9,14 +9,22 @@ describe Event do
let_it_be(:guest) { create(:user) }
let_it_be(:author) { create(:author) }
let_it_be(:admin) { create(:admin) }
let_it_be(:project) { create(:project) }
let(:epic) { create(:epic, group: group, author: author) }
let(:note_on_epic) { create(:note, :on_epic, noteable: epic) }
let(:event) { described_class.new(group: group, target: target, author: author) }
before do
stub_licensed_features(epics: true)
group.add_developer(member)
group.add_guest(guest)
project.add_developer(member)
project.add_guest(guest)
if defined?(group)
group.add_developer(member)
group.add_guest(guest)
end
end
shared_examples 'visible to group members only' do
......@@ -37,6 +45,23 @@ describe Event do
end
end
context 'design event' do
include DesignManagementTestHelpers
before do
enable_design_management
end
it 'is visible to authorised users' do
event = create(:event, :for_design, project: project)
expect(event.visible_to_user?(non_member)).to eq false
expect(event.visible_to_user?(member)).to eq true
expect(event.visible_to_user?(guest)).to eq true
expect(event.visible_to_user?(admin)).to eq true
end
end
context 'epic event' do
let(:target) { epic }
......
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