Commit a0784889 authored by Toon Claes's avatar Toon Claes

Use subclass to override ensure_merge_request_diff

No longer use stubbing for `MergeRequest#ensure_merge_request_diff`, but
instead create a `MergeRequest` that overrides
`#ensure_merge_request_diff` with an empty implementation.
parent cf33ef9a
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
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(:merge_request) { create(:merge_request) } let_it_be(:registry) { create(:geo_merge_request_diff_registry) }
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,13 +2,7 @@ ...@@ -2,13 +2,7 @@
FactoryBot.define do FactoryBot.define do
factory :merge_request_diff do factory :merge_request_diff do
merge_request do association :merge_request, factory: :merge_request_without_merge_request_diff
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 }
......
...@@ -286,5 +286,13 @@ FactoryBot.define do ...@@ -286,5 +286,13 @@ FactoryBot.define do
merge_request.update!(labels: evaluator.labels) merge_request.update!(labels: evaluator.labels)
end end
end end
factory :merge_request_without_merge_request_diff, class: 'MergeRequestWithoutMergeRequestDiff'
end end
end end
class MergeRequestWithoutMergeRequestDiff < ::MergeRequest
self.inheritance_column = :_type_disabled
def ensure_merge_request_diff; 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