summaryrefslogtreecommitdiff
path: root/spec/policies/metrics
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/policies/metrics
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/policies/metrics')
-rw-r--r--spec/policies/metrics/dashboard/annotation_policy_spec.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/spec/policies/metrics/dashboard/annotation_policy_spec.rb b/spec/policies/metrics/dashboard/annotation_policy_spec.rb
index 0c59b39ae3e..9ea9f843f2c 100644
--- a/spec/policies/metrics/dashboard/annotation_policy_spec.rb
+++ b/spec/policies/metrics/dashboard/annotation_policy_spec.rb
@@ -3,6 +3,10 @@
require 'spec_helper'
RSpec.describe Metrics::Dashboard::AnnotationPolicy, :models do
+ let(:policy) { described_class.new(user, annotation) }
+
+ let_it_be(:user) { create(:user) }
+
shared_examples 'metrics dashboard annotation policy' do
context 'when guest' do
before do
@@ -51,23 +55,21 @@ RSpec.describe Metrics::Dashboard::AnnotationPolicy, :models do
describe 'rules' do
context 'environments annotation' do
- let(:annotation) { create(:metrics_dashboard_annotation, environment: environment) }
- let(:environment) { create(:environment) }
- let!(:project) { environment.project }
- let(:user) { create(:user) }
- let(:policy) { described_class.new(user, annotation) }
+ let_it_be(:environment) { create(:environment) }
+ let_it_be(:annotation) { create(:metrics_dashboard_annotation, environment: environment) }
- it_behaves_like 'metrics dashboard annotation policy'
+ it_behaves_like 'metrics dashboard annotation policy' do
+ let(:project) { environment.project }
+ end
end
context 'cluster annotation' do
- let(:annotation) { create(:metrics_dashboard_annotation, environment: nil, cluster: cluster) }
- let(:cluster) { create(:cluster, :project) }
- let(:project) { cluster.project }
- let(:user) { create(:user) }
- let(:policy) { described_class.new(user, annotation) }
+ let_it_be(:cluster) { create(:cluster, :project) }
+ let_it_be(:annotation) { create(:metrics_dashboard_annotation, environment: nil, cluster: cluster) }
- it_behaves_like 'metrics dashboard annotation policy'
+ it_behaves_like 'metrics dashboard annotation policy' do
+ let(:project) { cluster.project }
+ end
end
end
end