fix notifications controller. yay.
This commit is contained in:
parent
ceb8497e49
commit
a0e8f161f5
1 changed files with 11 additions and 15 deletions
|
|
@ -5,12 +5,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe NotificationsController do
|
||||
render_views(false)
|
||||
before do
|
||||
@user = alice
|
||||
@aspect = @user.aspects.first
|
||||
@controller = NotificationsController.new
|
||||
@controller.stub!(:current_user).and_return(@user)
|
||||
sign_in :user, alice
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
|
|
@ -37,7 +33,7 @@ describe NotificationsController do
|
|||
it 'only lets you read your own notifications' do
|
||||
user2 = bob
|
||||
|
||||
Factory(:notification, :recipient => @user)
|
||||
Factory(:notification, :recipient => alice)
|
||||
note = Factory(:notification, :recipient => user2)
|
||||
|
||||
get :update, "id" => note.id, :set_unread => "false"
|
||||
|
|
@ -49,20 +45,20 @@ describe NotificationsController do
|
|||
describe "#read_all" do
|
||||
it 'marks all notifications as read' do
|
||||
request.env["HTTP_REFERER"] = "I wish I were spelled right"
|
||||
Factory(:notification, :recipient => @user)
|
||||
Factory(:notification, :recipient => @user)
|
||||
Factory(:notification, :recipient => alice)
|
||||
Factory(:notification, :recipient => alice)
|
||||
|
||||
Notification.where(:unread => true).count.should == 2
|
||||
get :read_all
|
||||
Notification.where(:unread => true).count.should == 0
|
||||
end
|
||||
it "should redirect to the stream in the html version" do
|
||||
Factory(:notification, :recipient => @user)
|
||||
Factory(:notification, :recipient => alice)
|
||||
get :read_all, :format => :html
|
||||
response.should redirect_to(stream_path)
|
||||
end
|
||||
it "should return a dummy value in the json version" do
|
||||
Factory(:notification, :recipient => @user)
|
||||
Factory(:notification, :recipient => alice)
|
||||
get :read_all, :format => :json
|
||||
response.should_not be_redirect
|
||||
end
|
||||
|
|
@ -71,11 +67,11 @@ describe NotificationsController do
|
|||
describe '#index' do
|
||||
before do
|
||||
@post = Factory(:status_message)
|
||||
Factory(:notification, :recipient => @user, :target => @post)
|
||||
Factory(:notification, :recipient => alice, :target => @post)
|
||||
end
|
||||
|
||||
it 'paginates the notifications' do
|
||||
25.times { Factory(:notification, :recipient => @user, :target => @post) }
|
||||
25.times { Factory(:notification, :recipient => alice, :target => @post) }
|
||||
get :index
|
||||
assigns[:notifications].count.should == 25
|
||||
get :index, "page" => 2
|
||||
|
|
@ -83,20 +79,20 @@ describe NotificationsController do
|
|||
end
|
||||
|
||||
it "supports a limit per_page parameter" do
|
||||
5.times { Factory(:notification, :recipient => @user, :target => @post) }
|
||||
5.times { Factory(:notification, :recipient => alice, :target => @post) }
|
||||
get :index, "per_page" => 5
|
||||
assigns[:notifications].count.should == 5
|
||||
end
|
||||
|
||||
describe "special case for start sharing notifications" do
|
||||
it "should not provide a contacts menu for standard notifications" do
|
||||
2.times { Factory(:notification, :recipient => @user, :target => @post) }
|
||||
2.times { Factory(:notification, :recipient => alice, :target => @post) }
|
||||
get :index, "per_page" => 5
|
||||
|
||||
Nokogiri(response.body).css('.aspect_membership').should be_empty
|
||||
end
|
||||
it "should provide a contacts menu for start sharing notifications" do
|
||||
2.times { Factory(:notification, :recipient => @user, :target => @post) }
|
||||
2.times { Factory(:notification, :recipient => alice, :target => @post) }
|
||||
eve.share_with(alice.person, eve.aspects.first)
|
||||
get :index, "per_page" => 5
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue