Skip to content

Commit

Permalink
Fix taggable uniqueness in tags admin table
Browse files Browse the repository at this point in the history
We need to check the class for uniqueness check on the
admin tags table, otherwise it will be duplicated.
  • Loading branch information
tvdeyen committed Feb 29, 2024
1 parent dd49458 commit ead8ec6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/tags/_tag.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<td class="icon"><%= render_icon(:tag, size: "xl") %></td>
<td class="name"><%= tag.name %></td>
<td>
<% tag.taggings.collect(&:taggable).compact.uniq.each do |taggable| %>
<% tag.taggings.collect(&:taggable).compact.uniq(&:class).each do |taggable| %>
<span class="label">
<%= taggable.class.model_name.human %>
</span>
Expand Down
19 changes: 19 additions & 0 deletions spec/features/admin/tags_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Tags", type: :system do
let!(:picture) { create(:alchemy_picture, tag_list: "Foo") }
let!(:picture2) { create(:alchemy_picture, tag_list: "Foo") }
let!(:a_page) { create(:alchemy_page, tag_list: "Bar") }

before { authorize_user(:as_admin) }

describe "index view" do
it "should list taggable class names" do
visit "/admin/tags"
expect(page).to have_selector(".label", text: "Picture", count: 1)
expect(page).to have_selector(".label", text: "Page", count: 1)
end
end
end

0 comments on commit ead8ec6

Please sign in to comment.