Avoid model inheritance in skip validation test
One of these tests was failing sometimes on Github Actions. It looked like the line `custom_banner.save!` was using the validations from the Banner class sometimes, even if the callbacks had correctly been removed in the DummyBanner class. Se we're inheriting from ApplicationRecord instead of inheriting from Banner. Since I couldn't reproduce the issue locally after running the test hundreds of times and with the same seed and tests that were running on Github Actions, there's a change this won't work. I've tested a few times on Github Actions and it seems to be working, but we'll have to keep an eye on it.
This commit is contained in:
@@ -49,19 +49,21 @@ describe SkipValidation do
|
||||
|
||||
describe ".skip_translation_validation" do
|
||||
before do
|
||||
dummy_banner = Class.new(Banner) do
|
||||
def self.translation_class
|
||||
@translation_class ||= Class.new(Banner::Translation) { clear_validators! }
|
||||
dummy_banner = Class.new(ApplicationRecord) do
|
||||
def self.name
|
||||
"DummyBanner"
|
||||
end
|
||||
reflect_on_association(:translations).options[:class_name] = "DummyBanner::Translation"
|
||||
self.table_name = "banners"
|
||||
|
||||
translates :title, touch: true
|
||||
translates :description, touch: true
|
||||
include Globalizable
|
||||
|
||||
clear_validators!
|
||||
validates_translation :title, presence: true
|
||||
validates_translation :description, presence: true
|
||||
end
|
||||
|
||||
stub_const("DummyBanner", dummy_banner)
|
||||
stub_const("DummyBanner::Translation", dummy_banner.translation_class)
|
||||
end
|
||||
|
||||
it "removes the validation from the translatable attribute" do
|
||||
|
||||
Reference in New Issue
Block a user