Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 15:08:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 15:08:41 +0300
commit5c5d24f032b67d98452f391192386e330a0f880c (patch)
tree9e58d94388f63cb825e426fea2c4929740604768 /spec/policies/incident_management
parent5ccb67600c63549774a28811d177dd673e6dd4d0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies/incident_management')
-rw-r--r--spec/policies/incident_management/timeline_event_policy_spec.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/policies/incident_management/timeline_event_policy_spec.rb b/spec/policies/incident_management/timeline_event_policy_spec.rb
new file mode 100644
index 00000000000..5a659054d7a
--- /dev/null
+++ b/spec/policies/incident_management/timeline_event_policy_spec.rb
@@ -0,0 +1,60 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe IncidentManagement::TimelineEventPolicy, models: true do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:reporter) { create(:user) }
+ let_it_be(:developer) { create(:user) }
+ let_it_be(:user) { developer }
+ let_it_be(:incident) { create(:incident, project: project, author: user) }
+
+ let_it_be(:editable_timeline_event) do
+ create(:incident_management_timeline_event, :editable, project: project, author: user, incident: incident)
+ end
+
+ let_it_be(:non_editable_timeline_event) do
+ create(:incident_management_timeline_event, :non_editable, project: project, author: user, incident: incident)
+ end
+
+ before do
+ project.add_developer(developer)
+ project.add_reporter(reporter)
+ end
+
+ describe '#rules' do
+ subject(:policies) { described_class.new(user, timeline_event) }
+
+ context 'when a user is not able to manage timeline events' do
+ let_it_be(:user) { reporter }
+
+ context 'when timeline event is editable' do
+ let(:timeline_event) { editable_timeline_event }
+
+ it 'does not allow to edit the timeline event' do
+ is_expected.not_to be_allowed(:edit_incident_management_timeline_event)
+ end
+ end
+ end
+
+ context 'when a user is able to manage timeline events' do
+ let_it_be(:user) { developer }
+
+ context 'when timeline event is editable' do
+ let(:timeline_event) { editable_timeline_event }
+
+ it 'allows to edit the timeline event' do
+ is_expected.to be_allowed(:edit_incident_management_timeline_event)
+ end
+ end
+
+ context 'when timeline event is not editable' do
+ let(:timeline_event) { non_editable_timeline_event }
+
+ it 'does not allow to edit the timeline event' do
+ is_expected.not_to be_allowed(:edit_incident_management_timeline_event)
+ end
+ end
+ end
+ end
+end