Commit 9572a314 authored by Imre Farkas's avatar Imre Farkas

Merge branch 'pl-spec-perf-metrics-dashboard-annotations' into 'master'

Speed up metrics dashboard annotation policy specs

See merge request gitlab-org/gitlab!40260
parents e802f7bc c3469aab
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Metrics::Dashboard::AnnotationPolicy, :models do 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 shared_examples 'metrics dashboard annotation policy' do
context 'when guest' do context 'when guest' do
before do before do
...@@ -51,23 +55,21 @@ RSpec.describe Metrics::Dashboard::AnnotationPolicy, :models do ...@@ -51,23 +55,21 @@ RSpec.describe Metrics::Dashboard::AnnotationPolicy, :models do
describe 'rules' do describe 'rules' do
context 'environments annotation' do context 'environments annotation' do
let(:annotation) { create(:metrics_dashboard_annotation, environment: environment) } let_it_be(:environment) { create(:environment) }
let(:environment) { create(:environment) } let_it_be(:annotation) { create(:metrics_dashboard_annotation, environment: environment) }
let!(:project) { environment.project }
let(:user) { create(:user) }
let(:policy) { described_class.new(user, annotation) }
it_behaves_like 'metrics dashboard annotation policy' it_behaves_like 'metrics dashboard annotation policy' do
let(:project) { environment.project }
end
end end
context 'cluster annotation' do context 'cluster annotation' do
let(:annotation) { create(:metrics_dashboard_annotation, environment: nil, cluster: cluster) } let_it_be(:cluster) { create(:cluster, :project) }
let(:cluster) { create(:cluster, :project) } let_it_be(:annotation) { create(:metrics_dashboard_annotation, environment: nil, cluster: cluster) }
let(:project) { cluster.project }
let(:user) { create(:user) }
let(:policy) { described_class.new(user, annotation) }
it_behaves_like 'metrics dashboard annotation policy' it_behaves_like 'metrics dashboard annotation policy' do
let(:project) { cluster.project }
end
end end
end end
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