From 8e1dcdc16ada8c75bb2d796c7b78d70b4ebe09a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Thu, 10 Sep 2015 13:52:39 +0200 Subject: [PATCH] fix bug on tag deletion when no taggable --- config/initializers/acts_as_taggable_on.rb | 2 +- spec/features/admin/tags_spec.rb | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config/initializers/acts_as_taggable_on.rb b/config/initializers/acts_as_taggable_on.rb index dcccf9429..7ad1bbb22 100644 --- a/config/initializers/acts_as_taggable_on.rb +++ b/config/initializers/acts_as_taggable_on.rb @@ -2,7 +2,7 @@ ActsAsTaggableOn::Tagging.class_eval do after_destroy :touch_taggable def touch_taggable - taggable.touch + taggable.touch if taggable.present? end end \ No newline at end of file diff --git a/spec/features/admin/tags_spec.rb b/spec/features/admin/tags_spec.rb index 16280383a..a56f10ffa 100644 --- a/spec/features/admin/tags_spec.rb +++ b/spec/features/admin/tags_spec.rb @@ -62,4 +62,23 @@ feature 'Admin tags' do expect(page).to_not have_content tag2.name end + scenario 'Delete tag with hidden taggables' do + tag2 = create(:tag, name: 'bad tag') + debate = create(:debate, tag_list: tag2.name) + debate.hide + + visit admin_tags_path + + expect(page).to have_content @tag1.name + expect(page).to have_content tag2.name + + within("#edit_tag_#{tag2.id}") do + click_link 'Delete Topic' + end + + visit admin_tags_path + expect(page).to have_content @tag1.name + expect(page).to_not have_content tag2.name + end + end \ No newline at end of file