Commit 78ee3a12 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'tc-fix-skip-callback' into 'master'

Remove use of skip_callback in MergeRequest factory

See merge request gitlab-org/gitlab!42238
parents 44a05ff1 efd3ac56
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Geo::MergeRequestDiffRegistry, :geo, type: :model do RSpec.describe Geo::MergeRequestDiffRegistry, :geo, type: :model do
let_it_be(:registry) { create(:geo_merge_request_diff_registry) } let_it_be(:merge_request) { create(:merge_request) }
let_it_be(:merge_request_diff) { create(:merge_request_diff, merge_request: merge_request) }
let_it_be(:registry) { create(:geo_merge_request_diff_registry, merge_request_diff: merge_request_diff) }
specify 'factory is valid' do specify 'factory is valid' do
expect(registry).to be_valid expect(registry).to be_valid
......
...@@ -2,7 +2,13 @@ ...@@ -2,7 +2,13 @@
FactoryBot.define do FactoryBot.define do
factory :merge_request_diff do factory :merge_request_diff do
association :merge_request, :without_merge_request_diff merge_request do
build(:merge_request) do |merge_request|
# MergeRequest should not create a MergeRequestDiff in the callback
allow(merge_request).to receive(:ensure_merge_request_diff)
end
end
state { :collected } state { :collected }
commits_count { 1 } commits_count { 1 }
......
...@@ -92,16 +92,6 @@ FactoryBot.define do ...@@ -92,16 +92,6 @@ FactoryBot.define do
target_branch { "feature_two" } target_branch { "feature_two" }
end end
trait(:without_merge_request_diff) do
after(:build) do |_|
MergeRequest.skip_callback(:create, :after, :ensure_merge_request_diff)
end
after(:create) do |_|
MergeRequest.set_callback(:create, :after, :ensure_merge_request_diff)
end
end
trait :locked do trait :locked do
state_id { MergeRequest.available_states[:locked] } state_id { MergeRequest.available_states[:locked] }
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