Simplify the method and fix Rubocop warnings
This commit is contained in:
@@ -9,13 +9,8 @@ class Admin::TagsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
@existing_tag = Tag.where(name: tag_params.first).first
|
||||
if @existing_tag
|
||||
@existing_tag.kind = "category"
|
||||
@existing_tag.save
|
||||
else
|
||||
Tag.category.create(tag_params)
|
||||
end
|
||||
Tag.find_or_create_by!(name: tag_params["name"]).update!(kind: "category")
|
||||
|
||||
redirect_to admin_tags_path
|
||||
end
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ describe "Admin tags" do
|
||||
end
|
||||
|
||||
scenario "Upgrade tag to category" do
|
||||
not_category_tag = create(:tag, name: "Soon a category")
|
||||
create(:tag, name: "Soon a category")
|
||||
|
||||
visit admin_tags_path
|
||||
|
||||
@@ -101,5 +101,4 @@ describe "Admin tags" do
|
||||
|
||||
expect(page).to have_content "Soon a category"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user