forked from dsjoerg/ggtracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifications_controller_spec.rb
More file actions
40 lines (31 loc) · 1011 Bytes
/
notifications_controller_spec.rb
File metadata and controls
40 lines (31 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'spec_helper'
describe NotificationsController do
login_user
describe :ack do
it 'should ack a notification for current_user' do
subject.current_user.notify('hi!')
n = subject.current_user.notifications.last
# We redirect_to :back on #ack for html requests.
request.env["HTTP_REFERER"] = '/'
get :ack, id: n.id
n.reload
n.ack?.should == true
end
it 'should not ack notifications for other users' do
user = FactoryGirl.create(:user)
user.notify('hi!')
n = user.notifications.last
# We redirect_to :back on #ack for html requests.
request.env["HTTP_REFERER"] = '/'
get :ack, id: n.id
n.reload
n.ack?.should == false
end
it 'should not redirect on JSON requests' do
subject.current_user.notify('hi!')
n = subject.current_user.notifications.last
get :ack, id: n.id, :format => :json
response.status.should == 200
end
end
end