FIX: unable to remove required tag group from a category
This commit is contained in:
parent
228c4814be
commit
a4dbec5bf9
|
@ -281,6 +281,7 @@ class CategoriesController < ApplicationController
|
|||
if SiteSetting.tagging_enabled
|
||||
params[:allowed_tags] ||= []
|
||||
params[:allowed_tag_groups] ||= []
|
||||
params[:required_tag_group_name] ||= ''
|
||||
end
|
||||
|
||||
result = params.permit(
|
||||
|
|
|
@ -559,7 +559,7 @@ class Category < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def required_tag_group_name=(group_name)
|
||||
self.required_tag_group = group_name ? TagGroup.where(name: group_name).first : nil
|
||||
self.required_tag_group = group_name.blank? ? nil : TagGroup.where(name: group_name).first
|
||||
end
|
||||
|
||||
def downcase_email
|
||||
|
|
|
@ -334,6 +334,7 @@ describe CategoriesController do
|
|||
|
||||
describe "success" do
|
||||
it "updates attributes correctly" do
|
||||
SiteSetting.tagging_enabled = true
|
||||
readonly = CategoryGroup.permission_types[:readonly]
|
||||
create_post = CategoryGroup.permission_types[:create_post]
|
||||
tag_group = Fabricate(:tag_group)
|
||||
|
@ -415,6 +416,22 @@ describe CategoriesController do
|
|||
expect(category.num_auto_bump_daily).to eq(10)
|
||||
expect(category.navigate_to_first_post_after_read).to eq(true)
|
||||
end
|
||||
|
||||
it "can remove required tag group" do
|
||||
SiteSetting.tagging_enabled = true
|
||||
category.update!(required_tag_group: Fabricate(:tag_group))
|
||||
put "/categories/#{category.id}.json", params: {
|
||||
name: category.name,
|
||||
color: category.color,
|
||||
text_color: category.text_color,
|
||||
allow_global_tags: 'false',
|
||||
min_tags_from_required_group: 1
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
category.reload
|
||||
expect(category.required_tag_group).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue