Commit 5aa6899e authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'pl-spec-factory-bot-parent-strategy' into 'master'

[RUN AS-IF-FOSS] Use parent strategy for associations in factories

See merge request gitlab-org/gitlab!40274
parents 47195fd4 ac5682c0
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Geo::SnippetRepositoryReplicator do
let(:model_record) { build(:snippet_repository) }
let(:model_record) { build(:snippet_repository, snippet: create(:snippet)) }
include_examples 'a repository replicator'
end
......@@ -48,7 +48,8 @@ RSpec.describe Git::WikiPushService do
end
context 'with a group wiki' do
let_it_be(:wiki) { build(:group_wiki) }
let_it_be(:group) { create(:group) }
let_it_be(:wiki) { build(:group_wiki, group: group) }
it 'does not trigger a wiki update' do
expect(wiki).not_to receive(:index_wiki_blobs)
......
......@@ -137,7 +137,8 @@ RSpec.describe PostReceive do
end
context 'with a group wiki' do
let(:wiki) { build(:group_wiki) }
let_it_be(:group) { create(:group) }
let(:wiki) { build(:group_wiki, group: group) }
it 'calls Git::WikiPushService#execute' do
expect_next_instance_of(::Git::WikiPushService) do |service|
......
......@@ -122,7 +122,7 @@ RSpec.describe Ci::PipelinesForMergeRequestFinder do
end
context 'with unsaved merge request' do
let(:merge_request) { build(:merge_request) }
let(:merge_request) { build(:merge_request, source_project: create(:project, :repository)) }
let!(:pipeline) do
create(:ci_empty_pipeline, project: project,
......
......@@ -6,7 +6,7 @@ RSpec.describe Ci::TriggerSerializer do
describe '#represent' do
let(:represent) { described_class.new.represent(trigger) }
let(:trigger) { build(:ci_trigger) }
let(:trigger) { build_stubbed(:ci_trigger) }
it 'matches schema' do
expect(represent.to_json).to match_schema('entities/trigger')
......
......@@ -3,7 +3,3 @@
FactoryBot::SyntaxRunner.class_eval do
include RSpec::Mocks::ExampleMethods
end
# Use FactoryBot 4.x behavior:
# https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
FactoryBot.use_parent_strategy = false
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