Commit c89fb511 authored by Sean Arnold's avatar Sean Arnold

Tweak policy specs

- Add options to service description
parent e09513fb
......@@ -12,9 +12,9 @@ module IncidentManagement
# @param params - length_unit [String] The unit of the rotation length. (One of 'hours', days', 'weeks')
# @param params - starts_at [DateTime] The datetime the rotation starts on.
# @param params - participants [Array<hash>] An array of hashes defining participants of the on-call rotations.
# - participant [User] The user who is part of the rotation
# - color_palette [String] The color palette to assign to the on-call user, for example: "blue".
# - color_weight [String] The color weight to assign to for the on-call user, for example "500". Max 4 chars.
# @option opts - participant [User] The user who is part of the rotation
# @option opts - color_palette [String] The color palette to assign to the on-call user, for example: "blue".
# @option opts - color_weight [String] The color weight to assign to for the on-call user, for example "500". Max 4 chars.
def initialize(schedule, project, user, params)
@schedule = schedule
@project = project
......
......@@ -6,19 +6,31 @@ RSpec.describe IncidentManagement::OncallRotationPolicy do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:oncall_schedule) { create(:incident_management_oncall_schedule, project: project) }
let_it_be(:oncall_schedule) { create(:incident_management_oncall_rotation, oncall_schedule: oncall_schedule) }
let_it_be_with_refind(:oncall_rotation) { create(:incident_management_oncall_rotation, oncall_schedule: oncall_schedule) }
subject(:policy) { described_class.new(user, oncall_schedule) }
subject(:policy) { described_class.new(user, oncall_rotation) }
before do
stub_feature_flags(oncall_schedules_mvc: project)
end
describe 'rules' do
it { is_expected.to be_disallowed :read_incident_management_oncall_schedule }
context 'when maintainer' do
context 'when reporter' do
before do
project.add_maintainer(user)
project.add_reporter(user)
end
it { is_expected.to be_allowed :read_incident_management_oncall_schedule }
it { is_expected.to be_disallowed :read_incident_management_oncall_schedule }
context 'licensed feature enabled' do
before do
stub_licensed_features(oncall_schedules: true)
end
it { is_expected.to be_allowed :read_incident_management_oncall_schedule }
end
end
end
end
......@@ -5,24 +5,31 @@ require 'spec_helper'
RSpec.describe IncidentManagement::OncallSchedulePolicy do
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:oncall_schedule) { create(:incident_management_oncall_schedule, project: project) }
let_it_be_with_refind(:oncall_schedule) { create(:incident_management_oncall_schedule, project: project) }
subject(:policy) { described_class.new(user, oncall_schedule) }
before do
stub_licensed_features(oncall_schedules: true)
stub_feature_flags(oncall_schedules_mvc: project)
end
describe 'rules' do
it { is_expected.to be_disallowed :read_incident_management_oncall_schedule }
context 'when maintainer' do
context 'when reporter' do
before do
project.add_maintainer(user)
project.add_reporter(user)
end
it { is_expected.to be_allowed :read_incident_management_oncall_schedule }
it { is_expected.to be_disallowed :read_incident_management_oncall_schedule }
context 'licensed feature enabled' do
before do
stub_licensed_features(oncall_schedules: true)
end
it { is_expected.to be_allowed :read_incident_management_oncall_schedule }
end
end
end
end
......@@ -82,7 +82,7 @@ RSpec.describe IncidentManagement::OncallRotations::CreateService do
oncall_schedule = execute.payload[:oncall_rotation]
expect(oncall_schedule).to be_a(::IncidentManagement::OncallRotation)
expect(oncall_schedule.name).to eq('On-call rotation')
expect(oncall_schedule.length).to eq('1')
expect(oncall_schedule.length).to eq(1)
expect(oncall_schedule.length_unit).to eq('days')
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