Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def update
category_params[:minimum_required_tags] = 0 if category_params[:minimum_required_tags]&.blank?

old_permissions = cat.permissions_params
old_permissions = { "everyone" => 1 } if old_permissions.empty?
old_permissions = { Group[:everyone].name => 1 } if old_permissions.empty?

if result = cat.update(category_params)
Category.preload_user_fields!(guardian, [cat])
Expand Down
48 changes: 30 additions & 18 deletions spec/requests/categories_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,8 @@
end

it "does not include the sort parameter in more_topics_url" do
# we need to create more topics for more_topics_url to be serialized
SiteSetting.categories_topics = 5
Fabricate.times(
5,
:topic,
category: category,
created_at: 1.day.ago,
bumped_at: 1.day.ago,
)
Fabricate.times(5, :topic, category:, created_at: 1.day.ago, bumped_at: 1.day.ago)

get "/categories_and_latest.json"
expect(response.status).to eq(200)
Expand All @@ -277,15 +270,8 @@
end

it "includes the sort parameter in more_topics_url" do
# we need to create more topics for more_topics_url to be serialized
SiteSetting.categories_topics = 5
Fabricate.times(
5,
:topic,
category: category,
created_at: 1.day.ago,
bumped_at: 1.day.ago,
)
Fabricate.times(5, :topic, category:, created_at: 1.day.ago, bumped_at: 1.day.ago)

get "/categories_and_latest.json"
expect(response.status).to eq(200)
Expand Down Expand Up @@ -349,7 +335,6 @@
CategoryFeaturedTopic.feature_topics
SiteSetting.desktop_category_page_style = "categories_with_featured_topics"

# warmup
get "/categories.json"
expect(response.status).to eq(200)

Expand Down Expand Up @@ -831,6 +816,33 @@
expect(UserHistory.count).to eq(6)
end

it "does not log false permission changes when everyone group name is localized" do
Group[:everyone].update!(name: "jeder")
category.category_groups.destroy_all

put "/categories/#{category.id}.json",
params: {
name: category.name,
color: category.color,
text_color: category.text_color,
slug: category.slug,
permissions: {
"jeder" => CategoryGroup.permission_types[:full],
},
}

expect(response.status).to eq(200)

Scheduler::Defer.do_all_work

expect(
UserHistory.exists?(
action: UserHistory.actions[:change_category_settings],
subject: "permissions",
),
).to eq(false)
end

it "updates per-category settings correctly" do
category.require_topic_approval = false
category.require_reply_approval = false
Expand Down Expand Up @@ -1129,7 +1141,7 @@
end

describe "#categories_and_topics" do
before { 10.times.each { Fabricate(:topic) } }
before { 10.times { Fabricate(:topic) } }

it "works when SiteSetting.categories_topics is non-null" do
SiteSetting.categories_topics = 5
Expand Down
Loading