Mark badge notification as read when the notification is clicked.

This commit is contained in:
Vikhyat Korrapati
2014-06-14 13:25:06 +05:30
parent fcfc6177c2
commit 41ecba1b77
4 changed files with 28 additions and 4 deletions

View File

@ -2,6 +2,11 @@ require 'spec_helper'
describe BadgesController do
let!(:badge) { Fabricate(:badge) }
let(:user) { Fabricate(:user) }
before do
SiteSetting.enable_badges = true
end
context 'index' do
it 'should return a list of all badges' do
@ -20,5 +25,13 @@ describe BadgesController do
parsed = JSON.parse(response.body)
parsed["badge"].should be_present
end
it "should mark the notification as viewed" do
log_in_user(user)
user_badge = BadgeGranter.grant(badge, user)
user_badge.notification.read.should == false
get :show, id: badge.id, format: :json
user_badge.notification.reload.read.should == true
end
end
end