Add lambda to the validations that use model constants

In this way when we need modify the constants model value in the
model/custom folder, adding lambda it will be possible load the new
values.
This commit is contained in:
taitus
2022-03-21 17:15:43 +01:00
committed by Javi Martín
parent 8c7091612e
commit ecde8c6439
32 changed files with 174 additions and 18 deletions

View File

@@ -33,5 +33,15 @@ describe SiteCustomization::Image do
expect(image).not_to be_valid
end
it "dynamically validates the valid images" do
stub_const("#{SiteCustomization::Image}::VALID_IMAGES", { "custom" => [223, 80] })
custom = build(:site_customization_image, name: "custom", image: fixture_file_upload("logo_header.png"))
expect(custom).to be_valid
map = build(:site_customization_image, name: "map", image: fixture_file_upload("custom_map.jpg"))
expect(map).not_to be_valid
end
end
end