FIX: Should not include regular categories in top_category_ids array

This commit is contained in:
Vinoth Kannan
2018-07-30 16:06:36 +05:30
parent 8d1acbd4c2
commit 50df2d7241
2 changed files with 8 additions and 1 deletions

View File

@ -37,6 +37,7 @@ RSpec.describe CurrentUserSerializer do
let(:user) { Fabricate(:user) }
let(:category1) { Fabricate(:category) }
let(:category2) { Fabricate(:category) }
let(:category3) { Fabricate(:category) }
let :serializer do
CurrentUserSerializer.new(user, scope: Guardian.new, root: false)
end
@ -55,6 +56,11 @@ RSpec.describe CurrentUserSerializer do
CategoryUser.create!(user_id: user.id,
category_id: category2.id,
notification_level: CategoryUser.notification_levels[:watching])
CategoryUser.create!(user_id: user.id,
category_id: category3.id,
notification_level: CategoryUser.notification_levels[:regular])
payload = serializer.as_json
expect(payload[:top_category_ids]).to eq([category2.id, category1.id])
end