Commit 169b8ece authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '217645-refactor-compliance-entity-spec' into 'master'

Refactor compliance entity spec using let_it_be

See merge request gitlab-org/gitlab!38729
parents c56ef3e6 e4ec603d
...@@ -7,10 +7,10 @@ RSpec.describe MergeRequestComplianceEntity do ...@@ -7,10 +7,10 @@ RSpec.describe MergeRequestComplianceEntity do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:merge_request) { create(:merge_request, state: :merged) } let_it_be(:merge_request) { create(:merge_request, :merged) }
let(:request) { double('request', current_user: user, project: project) } let(:request) { double('request', current_user: user, project: project) }
let(:entity) { described_class.new(merge_request, request: request) } let(:entity) { described_class.new(merge_request.reload, request: request) }
describe '.as_json' do describe '.as_json' do
subject { entity.as_json } subject { entity.as_json }
...@@ -35,9 +35,9 @@ RSpec.describe MergeRequestComplianceEntity do ...@@ -35,9 +35,9 @@ RSpec.describe MergeRequestComplianceEntity do
describe 'with an approver' do describe 'with an approver' do
let_it_be(:approver) { create(:user) } let_it_be(:approver) { create(:user) }
let!(:approval) { create :approval, merge_request: merge_request, user: approver } let_it_be(:approval) { create :approval, merge_request: merge_request, user: approver }
before do before_all do
project.add_developer(approver) project.add_developer(approver)
end end
...@@ -51,7 +51,7 @@ RSpec.describe MergeRequestComplianceEntity do ...@@ -51,7 +51,7 @@ RSpec.describe MergeRequestComplianceEntity do
end end
describe 'with a head pipeline' do describe 'with a head pipeline' do
let!(:pipeline) { create(:ci_empty_pipeline, status: :success, project: project, head_pipeline_of: merge_request) } let_it_be(:pipeline) { create(:ci_empty_pipeline, status: :success, project: project, head_pipeline_of: merge_request) }
describe 'and the user cannot read the pipeline' do describe 'and the user cannot read the pipeline' do
it 'does not include pipeline status attribute' do it 'does not include pipeline status attribute' do
......
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