moved tests from jasmine to controller specs
This commit is contained in:
parent
62dd2fc642
commit
77fc4b6cab
3 changed files with 30 additions and 32 deletions
|
|
@ -131,8 +131,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
this.changeNotificationCount = function(change) {
|
this.changeNotificationCount = function(change) {
|
||||||
self.count += change;
|
self.count = Math.max( self.count + change, 0 )
|
||||||
|
|
||||||
self.badge.text(self.count);
|
self.badge.text(self.count);
|
||||||
if ( self.notificationArea )
|
if ( self.notificationArea )
|
||||||
self.notificationArea.find( ".notification_count" ).text(self.count);
|
self.notificationArea.find( ".notification_count" ).text(self.count);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,16 @@ describe NotificationsController do
|
||||||
get :read_all
|
get :read_all
|
||||||
Notification.where(:unread => true).count.should == 0
|
Notification.where(:unread => true).count.should == 0
|
||||||
end
|
end
|
||||||
|
it "should redirect to the stream in the html version" do
|
||||||
|
Factory(:notification, :recipient => @user)
|
||||||
|
get :read_all, :format => :html
|
||||||
|
response.should redirect_to(multi_stream_path)
|
||||||
|
end
|
||||||
|
it "should return a dummy value in the json version" do
|
||||||
|
Factory(:notification, :recipient => @user)
|
||||||
|
get :read_all, :format => :json
|
||||||
|
response.should_not be_redirect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
|
|
@ -77,5 +87,24 @@ describe NotificationsController do
|
||||||
get :index, "per_page" => 5
|
get :index, "per_page" => 5
|
||||||
assigns[:notifications].count.should == 5
|
assigns[:notifications].count.should == 5
|
||||||
end
|
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) }
|
||||||
|
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) }
|
||||||
|
eve.share_with(alice.person, eve.aspects.first)
|
||||||
|
get :index, "per_page" => 5
|
||||||
|
|
||||||
|
Nokogiri(response.body).css('.aspect_membership').should_not be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
describe("app.views.Notification", function(){
|
|
||||||
var pageText = null;
|
|
||||||
|
|
||||||
|
|
||||||
describe("render regular notifications", function(){
|
|
||||||
beforeEach(function(){
|
|
||||||
pageText = spec.readFixture("notifications_index");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("has two notifications", function(){
|
|
||||||
expect( $( pageText ).find('.stream_element').length).toBe(2)
|
|
||||||
});
|
|
||||||
it("has no aspects menu", function(){
|
|
||||||
expect( $( pageText ).find('.dropdown_list').length).toBe(0)
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
describe("render a start sharing notification", function(){
|
|
||||||
beforeEach(function(){
|
|
||||||
pageText = spec.readFixture("notifications_index_with_sharing");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("has three notifications", function(){
|
|
||||||
expect( $( pageText ).find('.stream_element').length).toBe(3)
|
|
||||||
});
|
|
||||||
it("has shows an aspect menu for the start sharing item", function(){
|
|
||||||
expect( $( pageText ).find('.aspect_membership').length).toBe(1)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
Loading…
Reference in a new issue