Skip to content

Commit

Permalink
Merge pull request #2757 from AlchemyCMS/backport/7.0-stable/pr-2735
Browse files Browse the repository at this point in the history
[7.0] Fix tags view for missing taggables
  • Loading branch information
tvdeyen authored Feb 27, 2024
2 parents c046e73 + c197b58 commit bbcd03b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 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);
}
8 changes: 6 additions & 2 deletions app/views/alchemy/admin/tags/_tag.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<tr class="<%= cycle('even', 'odd') %>">
<td class="icon"><%= render_icon :tag %></td>
<td class="name"><%= tag.name %></td>
<td class="count">
<%= tag.taggings.collect(&:taggable).collect { |t| t.class.model_name.human }.uniq.join(', ') %>
<td>
<% 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 bbcd03b

Please sign in to comment.