From 48fa1f141fdb5469f6ba0f6e2c5c7a9d4aaf9920 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Tue, 11 Oct 2016 19:15:36 -0300 Subject: [PATCH] Add specs for localized notifications on backfilled badges --- spec/services/badge_granter_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/services/badge_granter_spec.rb b/spec/services/badge_granter_spec.rb index a7ce5e40df0..cb906c282d5 100644 --- a/spec/services/badge_granter_spec.rb +++ b/spec/services/badge_granter_spec.rb @@ -94,6 +94,23 @@ describe BadgeGranter do expect(Badge.find(Badge::NiceTopic).grant_count).to eq(1) expect(Badge.find(Badge::GoodTopic).grant_count).to eq(1) end + + it 'should grant badges in the user locale' do + + SiteSetting.allow_user_locale = true + + nice_topic = Badge.find(Badge::NiceTopic) + name_english = nice_topic.name + + user = Fabricate(:user, locale: 'fr') + post = Fabricate(:post, like_count: 10, user: user) + + BadgeGranter.backfill(nice_topic) + + notification_badge_name = JSON.parse(post.user.notifications.first.data)['badge_name'] + + expect(notification_badge_name).not_to eq(name_english) + end end describe 'grant' do