summaryrefslogtreecommitdiff
path: root/spec/policies/project_policy_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/policies/project_policy_spec.rb')
-rw-r--r--spec/policies/project_policy_spec.rb53
1 files changed, 47 insertions, 6 deletions
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index 77214814b7f..051a4420e73 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -1131,12 +1131,20 @@ RSpec.describe ProjectPolicy do
let_it_be(:project_with_analytics_enabled) { create(:project, :analytics_enabled) }
before do
+ project_with_analytics_disabled.add_guest(guest)
+ project_with_analytics_private.add_guest(guest)
+ project_with_analytics_enabled.add_guest(guest)
+
+ project_with_analytics_disabled.add_reporter(reporter)
+ project_with_analytics_private.add_reporter(reporter)
+ project_with_analytics_enabled.add_reporter(reporter)
+
project_with_analytics_disabled.add_developer(developer)
project_with_analytics_private.add_developer(developer)
project_with_analytics_enabled.add_developer(developer)
end
- context 'when analytics is enabled for the project' do
+ context 'when analytics is disabled for the project' do
let(:project) { project_with_analytics_disabled }
context 'for guest user' do
@@ -1145,6 +1153,16 @@ RSpec.describe ProjectPolicy do
it { is_expected.to be_disallowed(:read_cycle_analytics) }
it { is_expected.to be_disallowed(:read_insights) }
it { is_expected.to be_disallowed(:read_repository_graphs) }
+ it { is_expected.to be_disallowed(:read_ci_cd_analytics) }
+ end
+
+ context 'for reporter user' do
+ let(:current_user) { reporter }
+
+ it { is_expected.to be_disallowed(:read_cycle_analytics) }
+ it { is_expected.to be_disallowed(:read_insights) }
+ it { is_expected.to be_disallowed(:read_repository_graphs) }
+ it { is_expected.to be_disallowed(:read_ci_cd_analytics) }
end
context 'for developer' do
@@ -1153,6 +1171,7 @@ RSpec.describe ProjectPolicy do
it { is_expected.to be_disallowed(:read_cycle_analytics) }
it { is_expected.to be_disallowed(:read_insights) }
it { is_expected.to be_disallowed(:read_repository_graphs) }
+ it { is_expected.to be_disallowed(:read_ci_cd_analytics) }
end
end
@@ -1162,9 +1181,19 @@ RSpec.describe ProjectPolicy do
context 'for guest user' do
let(:current_user) { guest }
- it { is_expected.to be_disallowed(:read_cycle_analytics) }
- it { is_expected.to be_disallowed(:read_insights) }
+ it { is_expected.to be_allowed(:read_cycle_analytics) }
+ it { is_expected.to be_allowed(:read_insights) }
it { is_expected.to be_disallowed(:read_repository_graphs) }
+ it { is_expected.to be_disallowed(:read_ci_cd_analytics) }
+ end
+
+ context 'for reporter user' do
+ let(:current_user) { reporter }
+
+ it { is_expected.to be_allowed(:read_cycle_analytics) }
+ it { is_expected.to be_allowed(:read_insights) }
+ it { is_expected.to be_allowed(:read_repository_graphs) }
+ it { is_expected.to be_allowed(:read_ci_cd_analytics) }
end
context 'for developer' do
@@ -1173,18 +1202,29 @@ RSpec.describe ProjectPolicy do
it { is_expected.to be_allowed(:read_cycle_analytics) }
it { is_expected.to be_allowed(:read_insights) }
it { is_expected.to be_allowed(:read_repository_graphs) }
+ it { is_expected.to be_allowed(:read_ci_cd_analytics) }
end
end
context 'when analytics is enabled for the project' do
- let(:project) { project_with_analytics_private }
+ let(:project) { project_with_analytics_enabled }
context 'for guest user' do
let(:current_user) { guest }
- it { is_expected.to be_disallowed(:read_cycle_analytics) }
- it { is_expected.to be_disallowed(:read_insights) }
+ it { is_expected.to be_allowed(:read_cycle_analytics) }
+ it { is_expected.to be_allowed(:read_insights) }
it { is_expected.to be_disallowed(:read_repository_graphs) }
+ it { is_expected.to be_disallowed(:read_ci_cd_analytics) }
+ end
+
+ context 'for reporter user' do
+ let(:current_user) { reporter }
+
+ it { is_expected.to be_allowed(:read_cycle_analytics) }
+ it { is_expected.to be_allowed(:read_insights) }
+ it { is_expected.to be_allowed(:read_repository_graphs) }
+ it { is_expected.to be_allowed(:read_ci_cd_analytics) }
end
context 'for developer' do
@@ -1193,6 +1233,7 @@ RSpec.describe ProjectPolicy do
it { is_expected.to be_allowed(:read_cycle_analytics) }
it { is_expected.to be_allowed(:read_insights) }
it { is_expected.to be_allowed(:read_repository_graphs) }
+ it { is_expected.to be_allowed(:read_ci_cd_analytics) }
end
end
end