FIX: Always ensure notifications are treated as read once clicked

UX: improve messaging so notifications list is far more stable
PERF: improve performance of notifcation lookup queries

- Add feature "SetTransientHeader" that allows shipping info to server
   in the next Ajax request
- remove local storage hack used for notifications
- amend lookupStale to return hydrated objects, move logic into store
- stop magically clearing various notifications (likes, invitee accepted, group_summary, granted badge)
This commit is contained in:
Sam
2016-02-15 19:29:35 +11:00
parent 1f062ae2fd
commit dd6ebde824
15 changed files with 203 additions and 86 deletions

View File

@ -85,6 +85,35 @@ describe TopicsController do
end
describe 'clear_notifications' do
it 'correctly clears notifications if specified via cookie' do
notification = Fabricate(:notification)
log_in_user(notification.user)
request.cookies['cn'] = "2828,100,#{notification.id}"
get :show, {topic_id: 100}
expect(response.cookies['cn']).to eq nil
notification.reload
expect(notification.read).to eq true
end
it 'correctly clears notifications if specified via header' do
notification = Fabricate(:notification)
log_in_user(notification.user)
request.headers['Discourse-Clear-Notifications'] = "2828,100,#{notification.id}"
get :show, {topic_id: 100}
notification.reload
expect(notification.read).to eq true
end
end
describe 'set_locale' do
it 'sets the one the user prefers' do
SiteSetting.stubs(:allow_user_locale).returns(true)