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 @@
require 'spec_helper'
RSpec.describe Geo::MergeRequestDiffRegistry, :geo, type: :model do
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) }
let_it_be(:registry) { create(:geo_merge_request_diff_registry) }
specify 'factory is valid' do
expect(registry).to be_valid
......
......@@ -2,13 +2,7 @@
FactoryBot.define do
factory :merge_request_diff do
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
association :merge_request, factory: :merge_request_without_merge_request_diff
state { :collected }
commits_count { 1 }
......
......@@ -286,5 +286,13 @@ FactoryBot.define do
merge_request.update!(labels: evaluator.labels)
end
end
factory :merge_request_without_merge_request_diff, class: 'MergeRequestWithoutMergeRequestDiff'
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