diff options
author | danielgrippi <danielgrippi@gmail.com> | 2011-07-08 22:28:17 +0400 |
---|---|---|
committer | Raphael Sofaer <raphael@joindiaspora.com> | 2011-07-12 02:00:48 +0400 |
commit | 2e15b6a61e44f0bdd98f7b25473164eb3f38ebae (patch) | |
tree | 1e84239fc974411c597b3fa3ddc58bfe6ed762e7 /spec | |
parent | e59f49aace4a6e4ad695c5791768a4470be67c49 (diff) |
Likes in comments, cache counter disabled for now.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/likes_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/factories.rb | 2 | ||||
-rw-r--r-- | spec/helpers/notifications_helper_spec.rb | 6 | ||||
-rw-r--r-- | spec/mailers/notifier_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/like_spec.rb | 23 | ||||
-rw-r--r-- | spec/models/notification_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 4 |
7 files changed, 27 insertions, 26 deletions
diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index e30f2954d..b017e37dd 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -52,7 +52,7 @@ describe LikesController do end it "doesn't post multiple times" do - @user1.like(1, :post => @post) + @user1.like(1, :target => @post) post :create, dislike_hash response.code.should == '422' end @@ -81,7 +81,7 @@ describe LikesController do end it 'returns an array of likes for a post' do - like = bob.build_like(:positive => true, :post => @message) + like = bob.build_like(:positive => true, :target => @message) like.save! get :index, :post_id => @message.id @@ -97,23 +97,23 @@ describe LikesController do describe '#destroy' do before do @message = bob.post(:status_message, :text => "hey", :to => @aspect1.id) - @like = alice.build_like(:positive => true, :post => @message) + @like = alice.build_like(:positive => true, :target => @message) @like.save end it 'lets a user destroy their like' do expect { - delete :destroy, :format => "js", :post_id => @like.post_id, :id => @like.id + delete :destroy, :format => "js", :post_id => @like.target_id, :id => @like.id }.should change(Like, :count).by(-1) response.status.should == 200 end it 'does not let a user destroy other likes' do - like2 = eve.build_like(:positive => true, :post => @message) + like2 = eve.build_like(:positive => true, :target => @message) like2.save expect { - delete :destroy, :format => "js", :post_id => like2.post_id, :id => like2.id + delete :destroy, :format => "js", :post_id => like2.target_id, :id => like2.id }.should_not change(Like, :count) response.status.should == 403 diff --git a/spec/factories.rb b/spec/factories.rb index f25b92fbe..7d9ebe9ca 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -37,7 +37,7 @@ end Factory.define :like do |x| x.association :author, :factory => :person - x.association :post, :factory => :status_message + x.association :target, :factory => :status_message end Factory.define :user do |u| diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 3e4d599a2..59a9e827f 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -8,10 +8,10 @@ describe NotificationsHelper do @person = Factory(:person) @post = Factory(:status_message, :author => @user.person) @person2 = Factory(:person) - @notification = Notification.notify(@user, Factory(:like, :author => @person, :post => @post), @person) - @notification = Notification.notify(@user, Factory(:like, :author => @person2, :post => @post), @person2) - + @notification = Notification.notify(@user, Factory(:like, :author => @person, :target => @post), @person) + @notification = Notification.notify(@user, Factory(:like, :author => @person2, :target => @post), @person2) end + describe '#notification_people_link' do context 'formatting' do include ActionView::Helpers::SanitizeHelper diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 69bf65f2c..1eeb068ab 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -102,7 +102,7 @@ describe Notifier do describe ".liked" do before do @sm = Factory(:status_message, :author => alice.person) - @like = @sm.likes.create(:author => bob.person) + @like = @sm.likes.create!(:author => bob.person) @mail = Notifier.liked(alice.id, @like.author.id, @like.id) end diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index ade64c299..c3b02b0d7 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -21,26 +21,26 @@ describe Like do describe 'User#like' do it "should be able to like on one's own status" do - alice.like(1, :post => @status) + alice.like(1, :target => @status) @status.reload.likes.first.positive.should == true end it "should be able to like on a contact's status" do - bob.like(0, :post => @status) + bob.like(0, :target => @status) @status.reload.dislikes.first.positive.should == false end it "does not allow multiple likes" do lambda { - alice.like(1, :post => @status) - alice.like(0, :post => @status) + alice.like(1, :target => @status) + alice.like(0, :target => @status) }.should raise_error end end describe '#notification_type' do before do - @like = @alice.like(1, :post => @status) + @like = @alice.like(1, :target => @status) end it 'should be notifications liked if you are the post owner' do @@ -58,8 +58,9 @@ describe Like do describe 'counter cache' do it 'increments the counter cache on its post' do + pending lambda { - @alice.like(1, :post => @status) + @alice.like(1, :target => @status) }.should change{ @status.reload.likes_count }.by(1) end end @@ -70,7 +71,7 @@ describe Like do @liker_aspect = @liker.aspects.create(:name => "dummies") connect_users(alice, @alices_aspect, @liker, @liker_aspect) @post = alice.post :status_message, :text => "huhu", :to => @alices_aspect.id - @like = @liker.like 0, :post => @post + @like = @liker.like 0, :target => @post @xml = @like.to_xml.to_s end it 'serializes the sender handle' do @@ -87,7 +88,7 @@ describe Like do @marshalled_like.author.should == @liker.person end it 'marshals the post' do - @marshalled_like.post.should == @post + @marshalled_like.target.should == @post end end end @@ -98,11 +99,11 @@ describe Like do @remote_parent = Factory.create(:status_message, :author => @remote_raphael) @local_parent = @local_luke.post :status_message, :text => "foobar", :to => @local_luke.aspects.first - @object_by_parent_author = @local_luke.like(1, :post => @local_parent) - @object_by_recipient = @local_leia.build_like(:positive => 1, :post => @local_parent) + @object_by_parent_author = @local_luke.like(1, :target => @local_parent) + @object_by_recipient = @local_leia.build_like(:positive => 1, :target => @local_parent) @dup_object_by_parent_author = @object_by_parent_author.dup - @object_on_remote_parent = @local_luke.like(0, :post => @remote_parent) + @object_on_remote_parent = @local_luke.like(0, :target => @remote_parent) end it_should_behave_like 'it is relayable' end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 4a025d6ff..609392db1 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -96,8 +96,8 @@ describe Notification do it 'concatinates the like notifications' do p = Factory(:status_message, :author => @user.person) person2 = Factory(:person) - notification = Notification.notify(@user, Factory(:like, :author => @person, :post => p), @person) - notification2 = Notification.notify(@user, Factory(:like, :author => person2, :post => p), person2) + notification = Notification.notify(@user, Factory(:like, :author => @person, :target => p), @person) + notification2 = Notification.notify(@user, Factory(:like, :author => person2, :target => p), person2) notification.id.should == notification2.id end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c206fe1a7..f95c68d01 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -569,8 +569,8 @@ describe User do before do @message = alice.post(:status_message, :text => "cool", :to => alice.aspects.first) @message2 = bob.post(:status_message, :text => "uncool", :to => bob.aspects.first) - @like = alice.like(true, :post => @message) - @like2 = bob.like(true, :post => @message) + @like = alice.like(true, :target => @message) + @like2 = bob.like(true, :target => @message) end describe '#like_for' do |