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

@@ -13,4 +13,14 @@ RSpec.describe SiteCustomization::Page, type: :model do
custom_page = build(:site_customization_page, slug: "as/as*la")
expect(custom_page).to be_invalid
end
it "dynamically validates the valid statuses" do
stub_const("#{SiteCustomization::Page}::VALID_STATUSES", %w[custom])
custom_page.status = "custom"
expect(custom_page).to be_valid
custom_page.status = "published"
expect(custom_page).not_to be_valid
end
end