Merge pull request #3477 from PierreMesure/upgrade-tag-to-category
Fix a bug where a category can't be created if it already exists as a tag
This commit is contained in:
@@ -9,7 +9,8 @@ class Admin::TagsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
Tag.category.create!(tag_params)
|
||||
Tag.find_or_create_by!(name: tag_params["name"]).update!(kind: "category")
|
||||
|
||||
redirect_to admin_tags_path
|
||||
end
|
||||
|
||||
|
||||
@@ -88,4 +88,17 @@ describe "Admin tags" do
|
||||
expect(Tag.category.where(name: "wow_category")).to exist
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Upgrade tag to category" do
|
||||
create(:tag, name: "Soon a category")
|
||||
|
||||
visit admin_tags_path
|
||||
|
||||
within("form.new_tag") do
|
||||
fill_in "tag_name", with: "Soon a category"
|
||||
click_button "Create topic"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Soon a category"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user