debian-mirror-gitlab/spec/policies/resource_state_event_policy_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1 KiB
Ruby
Raw Normal View History

2023-03-17 16:20:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ResourceStateEventPolicy, feature_category: :team_planning do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :private) }
let_it_be(:issue) { create(:issue, project: project) }
describe '#read_resource_state_event' do
context 'with non-member user' do
it 'does not allow to read event' do
event = build_event(project)
expect(permissions(user, event)).to be_disallowed(:read_resource_state_event, :read_note)
end
end
context 'with member user' do
before do
project.add_guest(user)
end
it 'allows to read event for a state change' do
event = build_event(project)
expect(permissions(user, event)).to be_allowed(:read_resource_state_event, :read_note)
end
end
end
def build_event(label_project)
build(:resource_state_event, issue: issue, state: 2)
end
def permissions(user, issue)
described_class.new(user, issue)
end
end