Skip to content

Commit

Permalink
Merge pull request #2735 from tvdeyen/fix-tags
Browse files Browse the repository at this point in the history
Fix tags view for missing taggables
  • Loading branch information
tvdeyen authored Feb 21, 2024
2 parents b679b86 + 5d9023b commit b49cf8d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 1 addition & 4 deletions app/assets/stylesheets/alchemy/labels.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.label {
@include label-base(
$margin: $default-margin/2 0,
$padding: $default-padding 2*$default-padding $default-padding
);
@include label-base($margin: 0, $padding: 0 2 * $default-padding);
}
6 changes: 5 additions & 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,11 @@
<td class="icon"><%= render_icon(:tag, size: "xl") %></td>
<td class="name"><%= tag.name %></td>
<td>
<%= tag.taggings.collect(&:taggable).collect { |t| t.class.model_name.human }.uniq.join(', ') %>
<% tag.taggings.collect(&:taggable).compact.uniq.each do |taggable| %>
<span class="label">
<%= taggable.class.model_name.human %>
</span>
<% end %>
</td>
<td class="count"><%= tag.taggings.count %></td>
<td class="tools">
Expand Down
16 changes: 16 additions & 0 deletions spec/controllers/alchemy/admin/tags_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,26 @@ module Admin
before { authorize_user(:as_admin) }

describe "#index" do
render_views

let!(:picture) { create(:alchemy_picture, tag_list: "Foo,Bar") }

it "renders index template" do
get :index
expect(response).to be_successful
end

context "with taggable missing" do
before do
picture.thumbs.destroy_all
picture.delete
end

it "does not raise error" do
get :index
expect(response).to be_successful
end
end
end

describe "#create" do
Expand Down

0 comments on commit b49cf8d

Please sign in to comment.