Skip to content

Commit

Permalink
add testing for incorrect resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeys committed Nov 17, 2023
1 parent ec3e5d0 commit 4fde61a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions spec/factories/site_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
Binary file added spec/fixtures/icons/favicon-181x181.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion spec/models/site_setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 4fde61a

Please sign in to comment.