Skip to content

Commit

Permalink
Fix weight units bug in views (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
coalest authored Oct 21, 2024
1 parent 4e046e5 commit 2884d06
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/organizations/adoptable_pets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<%= tag.li("Age: #{time_ago_in_words(pet.birth_date).titleize}", class: li_classes) %>
<%= tag.li("Breed: #{pet.breed}", class: li_classes) %>
<%= tag.li("Sex: #{pet.sex}", class: li_classes) %>
<%= tag.li("Weight range: #{[pet.weight_from, pet.weight_to].join("-")} kg", class: li_classes) %>
<%= tag.li("Weight range: #{[pet.weight_from, pet.weight_to].join("-")} #{pet.weight_unit}", class: li_classes) %>
</ul>
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<%= tag.li("#{t('general.age')}: #{time_ago_in_words(pet.birth_date).titleize}", class: li_classes) %>
<%= tag.li("#{t('general.breed')}: #{pet.breed}", class: li_classes) %>
<%= tag.li("#{t('general.sex')}: #{pet.sex}", class: li_classes) %>
<%= tag.li("#{t('general.weight_range')}: #{[pet.weight_from, pet.weight_to].join("-")} kg", class: li_classes) %>
<%= tag.li("#{t('general.weight_range')}: #{[pet.weight_from, pet.weight_to].join("-")} #{pet.weight_unit}", class: li_classes) %>
</ul>
<% end %>
<% end %>
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/organizations/adoptable_pets_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ class Organizations::AdoptablePetsControllerTest < ActionDispatch::IntegrationTe
assert_equal 1, assigns[:pets].count
assert assigns[:pets].pluck(:id).exclude?(adopted_pet.id)
end

should "render information on pets" do
get adoptable_pets_url

assert_select(".card li:nth-of-type(1)", text: /#{@pet.name}\s+#{@pet.species}/)
assert_select(".card li:nth-of-type(2)", text: /Age/)
assert_select(".card li:nth-of-type(3)", text: "Breed: #{@pet.breed}")
assert_select(".card li:nth-of-type(4)", text: "Sex: #{@pet.sex}")
assert_select(".card li:nth-of-type(5)", text: "Weight range: #{@pet.weight_from}-#{@pet.weight_to} #{@pet.weight_unit}")
end
end

context "#show" do
Expand Down

0 comments on commit 2884d06

Please sign in to comment.