diff --git a/spec/factories/site_settings.rb b/spec/factories/site_settings.rb index 3de4dd31c..fa0e98f40 100644 --- a/spec/factories/site_settings.rb +++ b/spec/factories/site_settings.rb @@ -25,6 +25,11 @@ favicon { Rack::Test::UploadedFile.new("app/assets/images/icons/favicon-48x48.png", IMAGE_TYPE) } end + trait :invalid_favicon do + title { "ZeroWaste" } + favicon { Rack::Test::UploadedFile.new("spec/fixtures/icons/favicon-181x181.png", IMAGE_TYPE) } + end + trait :custom_setting do title { "Custom Waste" } favicon { Rack::Test::UploadedFile.new("app/assets/images/user.png", IMAGE_TYPE) } diff --git a/spec/fixtures/icons/favicon-181x181.png b/spec/fixtures/icons/favicon-181x181.png new file mode 100644 index 000000000..6da2582e1 Binary files /dev/null and b/spec/fixtures/icons/favicon-181x181.png differ diff --git a/spec/models/site_setting_spec.rb b/spec/models/site_setting_spec.rb index 329876acc..8e5625eb2 100644 --- a/spec/models/site_setting_spec.rb +++ b/spec/models/site_setting_spec.rb @@ -16,7 +16,7 @@ before { subject.update(site_setting_params) } - let(:site_setting_params) { FactoryBot.attributes_for(:site_setting, :with_valid_site_setting) } + let(:site_setting_params) { attributes_for(:site_setting, :with_valid_site_setting) } it "has a valid factory" do is_expected.to be_valid @@ -79,5 +79,16 @@ ) end end + + context "with a favicon larger than 180x180 pixels" do + let(:site_setting_params) { attributes_for(:site_setting, :invalid_favicon) } + + it "is not valid" do + is_expected.not_to be_valid + expect(subject.errors.messages[:favicon]).to include( + I18n.t("errors.messages.dimension_width_less_than_or_equal_to", length: 180) + ) + end + end end end