UX: Display only top categories in hamburger menu (#6146)

This commit is contained in:
Vinoth Kannan
2018-07-27 12:11:07 +05:30
committed by GitHub
parent e4208113a8
commit dac29b5ebc
7 changed files with 122 additions and 46 deletions

View File

@ -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