mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
UX: Display only top categories in hamburger menu (#6146)
This commit is contained in:
@ -32,4 +32,31 @@ RSpec.describe CurrentUserSerializer do
|
||||
expect(payload[:external_id]).to eq("12345")
|
||||
end
|
||||
end
|
||||
|
||||
context "#top_category_ids" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:category1) { Fabricate(:category) }
|
||||
let(:category2) { Fabricate(:category) }
|
||||
let :serializer do
|
||||
CurrentUserSerializer.new(user, scope: Guardian.new, root: false)
|
||||
end
|
||||
|
||||
it "should include empty top_category_ids array" do
|
||||
payload = serializer.as_json
|
||||
expect(payload[:top_category_ids]).to eq([])
|
||||
end
|
||||
|
||||
it "should include correct id in top_category_ids array" do
|
||||
category = Category.first
|
||||
CategoryUser.create!(user_id: user.id,
|
||||
category_id: category1.id,
|
||||
notification_level: CategoryUser.notification_levels[:tracking])
|
||||
|
||||
CategoryUser.create!(user_id: user.id,
|
||||
category_id: category2.id,
|
||||
notification_level: CategoryUser.notification_levels[:watching])
|
||||
payload = serializer.as_json
|
||||
expect(payload[:top_category_ids]).to eq([category2.id, category1.id])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user