Change :on to :post in the comment and post methods
This commit is contained in:
parent
c8dd8c98ca
commit
df04b59857
20 changed files with 61 additions and 62 deletions
|
|
@ -14,7 +14,7 @@ class CommentsController < ApplicationController
|
||||||
text = params[:text]
|
text = params[:text]
|
||||||
|
|
||||||
if target
|
if target
|
||||||
@comment = current_user.build_comment(:text => text, :on => target)
|
@comment = current_user.build_comment(:text => text, :post => target)
|
||||||
|
|
||||||
if @comment.save
|
if @comment.save
|
||||||
Rails.logger.info("event=create type=comment user=#{current_user.diaspora_handle} status=success comment=#{@comment.id} chars=#{params[:text].length}")
|
Rails.logger.info("event=create type=comment user=#{current_user.diaspora_handle} status=success comment=#{@comment.id} chars=#{params[:text].length}")
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class LikesController < ApplicationController
|
||||||
target = current_user.find_visible_post_by_id params[:post_id]
|
target = current_user.find_visible_post_by_id params[:post_id]
|
||||||
positive = (params[:positive] == 'true') ? true : false
|
positive = (params[:positive] == 'true') ? true : false
|
||||||
if target
|
if target
|
||||||
@like = current_user.build_like(:positive => positive, :on => target)
|
@like = current_user.build_like(:positive => positive, :post => target)
|
||||||
|
|
||||||
if @like.save
|
if @like.save
|
||||||
Rails.logger.info("event=create type=like user=#{current_user.diaspora_handle} status=success like=#{@like.id} positive=#{positive}")
|
Rails.logger.info("event=create type=like user=#{current_user.diaspora_handle} status=success like=#{@like.id} positive=#{positive}")
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class User < ActiveRecord::Base
|
||||||
:timeoutable, :token_authenticatable
|
:timeoutable, :token_authenticatable
|
||||||
|
|
||||||
before_validation :strip_and_downcase_username
|
before_validation :strip_and_downcase_username
|
||||||
before_validation :set_current_language, :on => :create
|
before_validation :set_current_language, :post => :create
|
||||||
|
|
||||||
validates_presence_of :username
|
validates_presence_of :username
|
||||||
validates_uniqueness_of :username
|
validates_uniqueness_of :username
|
||||||
|
|
@ -154,7 +154,6 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_relayable(model, options = {})
|
def build_relayable(model, options = {})
|
||||||
options[:post] = options.delete(:on)
|
|
||||||
m = model.new(options.merge(:author_id => self.person.id))
|
m = model.new(options.merge(:author_id => self.person.id))
|
||||||
m.set_guid
|
m.set_guid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ describe AspectsController do
|
||||||
|
|
||||||
it 'generates a jasmine fixture with posts', :fixture => 'jasmine' do
|
it 'generates a jasmine fixture with posts', :fixture => 'jasmine' do
|
||||||
message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id)
|
message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id)
|
||||||
4.times { bob.comment("what", :on => message) }
|
4.times { bob.comment("what", :post => message) }
|
||||||
get :index
|
get :index
|
||||||
save_fixture(html_for("body"), "aspects_index_with_posts")
|
save_fixture(html_for("body"), "aspects_index_with_posts")
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ describe AspectsController do
|
||||||
post.save!
|
post.save!
|
||||||
@posts << post
|
@posts << post
|
||||||
end
|
end
|
||||||
alice.build_comment(:text => 'lalala', :on => @posts.first ).save
|
alice.build_comment(:text => 'lalala', :post => @posts.first ).save
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "post visibilities" do
|
describe "post visibilities" do
|
||||||
|
|
@ -187,7 +187,7 @@ describe AspectsController do
|
||||||
connect_users(alice, @alices_aspect_1, user, aspect)
|
connect_users(alice, @alices_aspect_1, user, aspect)
|
||||||
post = alice.post(:status_message, :text => "hello#{n}", :to => @alices_aspect_2.id)
|
post = alice.post(:status_message, :text => "hello#{n}", :to => @alices_aspect_2.id)
|
||||||
8.times do |n|
|
8.times do |n|
|
||||||
user.comment "yo#{post.text}", :on => post
|
user.comment "yo#{post.text}", :post => post
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ describe CommentsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't overwrite id" do
|
it "doesn't overwrite id" do
|
||||||
old_comment = alice.comment("hello", :on => @post)
|
old_comment = alice.comment("hello", :post => @post)
|
||||||
comment_hash[:id] = old_comment.id
|
comment_hash[:id] = old_comment.id
|
||||||
post :create, comment_hash
|
post :create, comment_hash
|
||||||
old_comment.reload.text.should == 'hello'
|
old_comment.reload.text.should == 'hello'
|
||||||
|
|
@ -73,9 +73,9 @@ describe CommentsController do
|
||||||
context 'your post' do
|
context 'your post' do
|
||||||
before do
|
before do
|
||||||
@message = alice.post(:status_message, :text => "hey", :to => @aspect1.id)
|
@message = alice.post(:status_message, :text => "hey", :to => @aspect1.id)
|
||||||
@comment = alice.comment("hey", :on => @message)
|
@comment = alice.comment("hey", :post => @message)
|
||||||
@comment2 = bob.comment("hey", :on => @message)
|
@comment2 = bob.comment("hey", :post => @message)
|
||||||
@comment3 = eve.comment("hey", :on => @message)
|
@comment3 = eve.comment("hey", :post => @message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'lets the user delete his comment' do
|
it 'lets the user delete his comment' do
|
||||||
|
|
@ -94,9 +94,9 @@ describe CommentsController do
|
||||||
context "another user's post" do
|
context "another user's post" do
|
||||||
before do
|
before do
|
||||||
@message = bob.post(:status_message, :text => "hey", :to => bob.aspects.first.id)
|
@message = bob.post(:status_message, :text => "hey", :to => bob.aspects.first.id)
|
||||||
@comment = alice.comment("hey", :on => @message)
|
@comment = alice.comment("hey", :post => @message)
|
||||||
@comment2 = bob.comment("hey", :on => @message)
|
@comment2 = bob.comment("hey", :post => @message)
|
||||||
@comment3 = eve.comment("hey", :on => @message)
|
@comment3 = eve.comment("hey", :post => @message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'let the user delete his comment' do
|
it 'let the user delete his comment' do
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ describe LikesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't post multiple times" do
|
it "doesn't post multiple times" do
|
||||||
@user1.like(1, :on => @post)
|
@user1.like(1, :post => @post)
|
||||||
post :create, dislike_hash
|
post :create, dislike_hash
|
||||||
response.code.should == '422'
|
response.code.should == '422'
|
||||||
end
|
end
|
||||||
|
|
@ -76,7 +76,7 @@ describe LikesController do
|
||||||
context 'your like' do
|
context 'your like' do
|
||||||
before do
|
before do
|
||||||
@message = bob.post(:status_message, :text => "hey", :to => @aspect1.id)
|
@message = bob.post(:status_message, :text => "hey", :to => @aspect1.id)
|
||||||
@like = alice.build_like(:positive => true, :on => @message)
|
@like = alice.build_like(:positive => true, :post => @message)
|
||||||
@like.save
|
@like.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ describe LikesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not let a user destroy other likes' do
|
it 'does not let a user destroy other likes' do
|
||||||
like2 = eve.build_like(:positive => true, :on => @message)
|
like2 = eve.build_like(:positive => true, :post => @message)
|
||||||
like2.save
|
like2.save
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ describe PeopleController do
|
||||||
end
|
end
|
||||||
@posts.each do |post|
|
@posts.each do |post|
|
||||||
@users.each do |user|
|
@users.each do |user|
|
||||||
user.comment "yo#{post.text}", :on => post
|
user.comment "yo#{post.text}", :post => post
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -150,7 +150,7 @@ describe PeopleController do
|
||||||
|
|
||||||
it "renders the comments on the user's posts" do
|
it "renders the comments on the user's posts" do
|
||||||
message = @user.post :status_message, :text => 'test more', :to => @aspect.id
|
message = @user.post :status_message, :text => 'test more', :to => @aspect.id
|
||||||
@user.comment 'I mean it', :on => message
|
@user.comment 'I mean it', :post => message
|
||||||
get :show, :id => @user.person.id
|
get :show, :id => @user.person.id
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ describe StatusMessagesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'marks a corresponding notification as read' do
|
it 'marks a corresponding notification as read' do
|
||||||
alice.comment("comment after me", :on => @message)
|
alice.comment("comment after me", :post => @message)
|
||||||
bob.comment("here you go", :on => @message)
|
bob.comment("here you go", :post => @message)
|
||||||
note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first
|
note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first
|
||||||
lambda{
|
lambda{
|
||||||
get :show, :id => @message.id
|
get :show, :id => @message.id
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ describe TagsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with comments' do
|
it 'succeeds with comments' do
|
||||||
alice.comment('what WHAT!', :on => @post)
|
alice.comment('what WHAT!', :post => @post)
|
||||||
get :show, :name => 'what'
|
get :show, :name => 'what'
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ describe 'a user receives a post' do
|
||||||
receive_with_zord(bob, alice.person, xml)
|
receive_with_zord(bob, alice.person, xml)
|
||||||
receive_with_zord(eve, alice.person, xml)
|
receive_with_zord(eve, alice.person, xml)
|
||||||
|
|
||||||
@comment = eve.comment('tada',:on => @post)
|
@comment = eve.comment('tada',:post => @post)
|
||||||
@comment.parent_author_signature = @comment.sign_with_key(alice.encryption_key)
|
@comment.parent_author_signature = @comment.sign_with_key(alice.encryption_key)
|
||||||
@xml = @comment.to_diaspora_xml
|
@xml = @comment.to_diaspora_xml
|
||||||
@comment.delete
|
@comment.delete
|
||||||
|
|
@ -290,7 +290,7 @@ describe 'a user receives a post' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not raise a `Mysql2::Error: Duplicate entry...` exception on save' do
|
it 'does not raise a `Mysql2::Error: Duplicate entry...` exception on save' do
|
||||||
@comment = bob.comment('tada',:on => @post)
|
@comment = bob.comment('tada',:post => @post)
|
||||||
@xml = @comment.to_diaspora_xml
|
@xml = @comment.to_diaspora_xml
|
||||||
|
|
||||||
lambda {
|
lambda {
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ describe Postzord::Dispatch do
|
||||||
end
|
end
|
||||||
context "local leia" do
|
context "local leia" do
|
||||||
before do
|
before do
|
||||||
@comment = @local_leia.build_comment :text => "yo", :on => @post
|
@comment = @local_leia.build_comment :text => "yo", :post => @post
|
||||||
@comment.save
|
@comment.save
|
||||||
end
|
end
|
||||||
context "local leia's mailman" do
|
context "local leia's mailman" do
|
||||||
|
|
@ -156,7 +156,7 @@ describe Postzord::Dispatch do
|
||||||
end
|
end
|
||||||
context "local luke" do
|
context "local luke" do
|
||||||
before do
|
before do
|
||||||
@comment = @local_luke.build_comment :text => "yo", :on => @post
|
@comment = @local_luke.build_comment :text => "yo", :post => @post
|
||||||
@comment.save
|
@comment.save
|
||||||
@mailman = Postzord::Dispatch.new(@local_luke, @comment)
|
@mailman = Postzord::Dispatch.new(@local_luke, @comment)
|
||||||
end
|
end
|
||||||
|
|
@ -182,7 +182,7 @@ describe Postzord::Dispatch do
|
||||||
context "remote raphael's post is commented on by local luke" do
|
context "remote raphael's post is commented on by local luke" do
|
||||||
before do
|
before do
|
||||||
@post = Factory(:status_message, :author => @remote_raphael)
|
@post = Factory(:status_message, :author => @remote_raphael)
|
||||||
@comment = @local_luke.build_comment :text => "yo", :on => @post
|
@comment = @local_luke.build_comment :text => "yo", :post => @post
|
||||||
@comment.save
|
@comment.save
|
||||||
@mailman = Postzord::Dispatch.new(@local_luke, @comment)
|
@mailman = Postzord::Dispatch.new(@local_luke, @comment)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ describe Notifier do
|
||||||
context "comments" do
|
context "comments" do
|
||||||
let!(:connect) { connect_users(user, aspect, user2, aspect2)}
|
let!(:connect) { connect_users(user, aspect, user2, aspect2)}
|
||||||
let!(:sm) {user.post(:status_message, :text => "Sunny outside", :to => :all)}
|
let!(:sm) {user.post(:status_message, :text => "Sunny outside", :to => :all)}
|
||||||
let!(:comment) { user2.comment("Totally is", :on => sm )}
|
let!(:comment) { user2.comment("Totally is", :post => sm )}
|
||||||
describe ".comment_on_post" do
|
describe ".comment_on_post" do
|
||||||
|
|
||||||
let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment.id).deliver}
|
let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment.id).deliver}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ describe 'making sure the spec runner works' do
|
||||||
m.stub!(:post)
|
m.stub!(:post)
|
||||||
Postzord::Dispatch.should_receive(:new).and_return(m)
|
Postzord::Dispatch.should_receive(:new).and_return(m)
|
||||||
|
|
||||||
alice.comment "yo", :on => person_status
|
alice.comment "yo", :post => person_status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,19 @@ describe Comment do
|
||||||
|
|
||||||
describe 'comment#notification_type' do
|
describe 'comment#notification_type' do
|
||||||
it "returns 'comment_on_post' if the comment is on a post you own" do
|
it "returns 'comment_on_post' if the comment is on a post you own" do
|
||||||
comment = bob.comment("why so formal?", :on => @status)
|
comment = bob.comment("why so formal?", :post => @status)
|
||||||
comment.notification_type(alice, bob.person).should == Notifications::CommentOnPost
|
comment.notification_type(alice, bob.person).should == Notifications::CommentOnPost
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns false if the comment is not on a post you own and no one "also_commented"' do
|
it 'returns false if the comment is not on a post you own and no one "also_commented"' do
|
||||||
comment = alice.comment("I simply felt like issuing a greeting. Do step off.", :on => @status)
|
comment = alice.comment("I simply felt like issuing a greeting. Do step off.", :post => @status)
|
||||||
comment.notification_type(@bob, alice.person).should == false
|
comment.notification_type(@bob, alice.person).should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
context "also commented" do
|
context "also commented" do
|
||||||
before do
|
before do
|
||||||
@bob.comment("a-commenta commenta", :on => @status)
|
@bob.comment("a-commenta commenta", :post => @status)
|
||||||
@comment = @eve.comment("I also commented on the first user's post", :on => @status)
|
@comment = @eve.comment("I also commented on the first user's post", :post => @status)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not return also commented if the user commented' do
|
it 'does not return also commented if the user commented' do
|
||||||
|
|
@ -45,17 +45,17 @@ describe Comment do
|
||||||
|
|
||||||
describe 'User#comment' do
|
describe 'User#comment' do
|
||||||
it "should be able to comment on one's own status" do
|
it "should be able to comment on one's own status" do
|
||||||
alice.comment("Yeah, it was great", :on => @status)
|
alice.comment("Yeah, it was great", :post => @status)
|
||||||
@status.reload.comments.first.text.should == "Yeah, it was great"
|
@status.reload.comments.first.text.should == "Yeah, it was great"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to comment on a contact's status" do
|
it "should be able to comment on a contact's status" do
|
||||||
bob.comment("sup dog", :on => @status)
|
bob.comment("sup dog", :post => @status)
|
||||||
@status.reload.comments.first.text.should == "sup dog"
|
@status.reload.comments.first.text.should == "sup dog"
|
||||||
end
|
end
|
||||||
it 'does not multi-post a comment' do
|
it 'does not multi-post a comment' do
|
||||||
lambda {
|
lambda {
|
||||||
alice.comment 'hello', :on => @status
|
alice.comment 'hello', :post => @status
|
||||||
}.should change { Comment.count }.by(1)
|
}.should change { Comment.count }.by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -66,7 +66,7 @@ describe Comment do
|
||||||
@commenter_aspect = @commenter.aspects.create(:name => "bruisers")
|
@commenter_aspect = @commenter.aspects.create(:name => "bruisers")
|
||||||
connect_users(alice, @alices_aspect, @commenter, @commenter_aspect)
|
connect_users(alice, @alices_aspect, @commenter, @commenter_aspect)
|
||||||
@post = alice.post :status_message, :text => "hello", :to => @alices_aspect.id
|
@post = alice.post :status_message, :text => "hello", :to => @alices_aspect.id
|
||||||
@comment = @commenter.comment "Fool!", :on => @post
|
@comment = @commenter.comment "Fool!", :post => @post
|
||||||
@xml = @comment.to_xml.to_s
|
@xml = @comment.to_xml.to_s
|
||||||
end
|
end
|
||||||
it 'serializes the sender handle' do
|
it 'serializes the sender handle' do
|
||||||
|
|
@ -104,7 +104,7 @@ describe Comment do
|
||||||
mock_http.should_receive(:get).with(/\/feeds\/api\/videos/, nil).twice.and_return(
|
mock_http.should_receive(:get).with(/\/feeds\/api\/videos/, nil).twice.and_return(
|
||||||
[nil, 'Foobar <title>'+expected_title+'</title> hallo welt <asd><dasdd><a>dsd</a>'])
|
[nil, 'Foobar <title>'+expected_title+'</title> hallo welt <asd><dasdd><a>dsd</a>'])
|
||||||
|
|
||||||
comment = alice.build_comment :text => url, :on => @message
|
comment = alice.build_comment :text => url, :post => @message
|
||||||
comment.save!
|
comment.save!
|
||||||
|
|
||||||
Comment.find(comment.id).youtube_titles.should == { first_video_id => CGI::escape(expected_title), second_video_id => CGI::escape(expected_title) }
|
Comment.find(comment.id).youtube_titles.should == { first_video_id => CGI::escape(expected_title), second_video_id => CGI::escape(expected_title) }
|
||||||
|
|
@ -117,11 +117,11 @@ describe Comment do
|
||||||
@remote_parent = Factory.create(:status_message, :author => @remote_raphael)
|
@remote_parent = Factory.create(:status_message, :author => @remote_raphael)
|
||||||
@local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first
|
@local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first
|
||||||
|
|
||||||
@object_by_parent_author = @local_luke.comment("yo", :on => @local_parent)
|
@object_by_parent_author = @local_luke.comment("yo", :post => @local_parent)
|
||||||
@object_by_recipient = @local_leia.build_comment(:text => "yo", :on => @local_parent)
|
@object_by_recipient = @local_leia.build_comment(:text => "yo", :post => @local_parent)
|
||||||
@dup_object_by_parent_author = @object_by_parent_author.dup
|
@dup_object_by_parent_author = @object_by_parent_author.dup
|
||||||
|
|
||||||
@object_on_remote_parent = @local_luke.comment("Yeah, it was great", :on => @remote_parent)
|
@object_on_remote_parent = @local_luke.comment("Yeah, it was great", :post => @remote_parent)
|
||||||
end
|
end
|
||||||
it_should_behave_like 'it is relayable'
|
it_should_behave_like 'it is relayable'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,26 @@ describe Like do
|
||||||
|
|
||||||
describe 'User#like' do
|
describe 'User#like' do
|
||||||
it "should be able to like on one's own status" do
|
it "should be able to like on one's own status" do
|
||||||
alice.like(1, :on => @status)
|
alice.like(1, :post => @status)
|
||||||
@status.reload.likes.first.positive.should == true
|
@status.reload.likes.first.positive.should == true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should be able to like on a contact's status" do
|
it "should be able to like on a contact's status" do
|
||||||
bob.like(0, :on => @status)
|
bob.like(0, :post => @status)
|
||||||
@status.reload.dislikes.first.positive.should == false
|
@status.reload.dislikes.first.positive.should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not allow multiple likes" do
|
it "does not allow multiple likes" do
|
||||||
lambda {
|
lambda {
|
||||||
alice.like(1, :on => @status)
|
alice.like(1, :post => @status)
|
||||||
alice.like(0, :on => @status)
|
alice.like(0, :post => @status)
|
||||||
}.should raise_error
|
}.should raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#notification_type' do
|
describe '#notification_type' do
|
||||||
before do
|
before do
|
||||||
@like = @alice.like(1, :on => @status)
|
@like = @alice.like(1, :post => @status)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be notifications liked if you are the post owner' do
|
it 'should be notifications liked if you are the post owner' do
|
||||||
|
|
@ -62,7 +62,7 @@ describe Like do
|
||||||
@liker_aspect = @liker.aspects.create(:name => "dummies")
|
@liker_aspect = @liker.aspects.create(:name => "dummies")
|
||||||
connect_users(alice, @alices_aspect, @liker, @liker_aspect)
|
connect_users(alice, @alices_aspect, @liker, @liker_aspect)
|
||||||
@post = alice.post :status_message, :text => "huhu", :to => @alices_aspect.id
|
@post = alice.post :status_message, :text => "huhu", :to => @alices_aspect.id
|
||||||
@like = @liker.like 0, :on => @post
|
@like = @liker.like 0, :post => @post
|
||||||
@xml = @like.to_xml.to_s
|
@xml = @like.to_xml.to_s
|
||||||
end
|
end
|
||||||
it 'serializes the sender handle' do
|
it 'serializes the sender handle' do
|
||||||
|
|
@ -90,11 +90,11 @@ describe Like do
|
||||||
@remote_parent = Factory.create(:status_message, :author => @remote_raphael)
|
@remote_parent = Factory.create(:status_message, :author => @remote_raphael)
|
||||||
@local_parent = @local_luke.post :status_message, :text => "foobar", :to => @local_luke.aspects.first
|
@local_parent = @local_luke.post :status_message, :text => "foobar", :to => @local_luke.aspects.first
|
||||||
|
|
||||||
@object_by_parent_author = @local_luke.like(1, :on => @local_parent)
|
@object_by_parent_author = @local_luke.like(1, :post => @local_parent)
|
||||||
@object_by_recipient = @local_leia.build_like(:positive => 1, :on => @local_parent)
|
@object_by_recipient = @local_leia.build_like(:positive => 1, :post => @local_parent)
|
||||||
@dup_object_by_parent_author = @object_by_parent_author.dup
|
@dup_object_by_parent_author = @object_by_parent_author.dup
|
||||||
|
|
||||||
@object_on_remote_parent = @local_luke.like(0, :on => @remote_parent)
|
@object_on_remote_parent = @local_luke.like(0, :post => @remote_parent)
|
||||||
end
|
end
|
||||||
it_should_behave_like 'it is relayable'
|
it_should_behave_like 'it is relayable'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,8 @@ describe Notification do
|
||||||
before do
|
before do
|
||||||
@user3 = bob
|
@user3 = bob
|
||||||
@sm = @user3.post(:status_message, :text => "comment!", :to => :all)
|
@sm = @user3.post(:status_message, :text => "comment!", :to => :all)
|
||||||
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :on => @sm)).receive_object
|
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :post => @sm)).receive_object
|
||||||
Postzord::Receiver.new(@user3, :person => @user.person, :object => @user.comment("hey", :on => @sm)).receive_object
|
Postzord::Receiver.new(@user3, :person => @user.person, :object => @user.comment("hey", :post => @sm)).receive_object
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates the notification with a more people if one already exists" do
|
it "updates the notification with a more people if one already exists" do
|
||||||
|
|
@ -128,7 +128,7 @@ describe Notification do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'handles double comments from the same person without raising' do
|
it 'handles double comments from the same person without raising' do
|
||||||
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :on => @sm)).receive_object
|
Postzord::Receiver.new(@user3, :person => @user2.person, :object => @user2.comment("hey", :post => @sm)).receive_object
|
||||||
Notification.where(:recipient_id => @user3.id, :target_type => @sm.class.base_class, :target_id => @sm.id).first.actors.count.should == 2
|
Notification.where(:recipient_id => @user3.id, :target_type => @sm.class.base_class, :target_id => @sm.id).first.actors.count.should == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ describe Photo do
|
||||||
|
|
||||||
context "commenting" do
|
context "commenting" do
|
||||||
it "accepts comments if there is no parent status message" do
|
it "accepts comments if there is no parent status message" do
|
||||||
proc{ @user.comment("big willy style", :on => @photo) }.should change(@photo.comments, :count).by(1)
|
proc{ @user.comment("big willy style", :post => @photo) }.should change(@photo.comments, :count).by(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ describe Post do
|
||||||
describe 'deletion' do
|
describe 'deletion' do
|
||||||
it 'should delete a posts comments on delete' do
|
it 'should delete a posts comments on delete' do
|
||||||
post = Factory.create(:status_message, :author => @user.person)
|
post = Factory.create(:status_message, :author => @user.person)
|
||||||
@user.comment "hey", :on => post
|
@user.comment "hey", :post => post
|
||||||
post.destroy
|
post.destroy
|
||||||
Post.where(:id => post.id).empty?.should == true
|
Post.where(:id => post.id).empty?.should == true
|
||||||
Comment.where(:text => "hey").empty?.should == true
|
Comment.where(:text => "hey").empty?.should == true
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ describe RelayableRetraction do
|
||||||
|
|
||||||
describe '#subscribers' do
|
describe '#subscribers' do
|
||||||
before do
|
before do
|
||||||
@comment= @local_luke.comment("yo", :on => @local_parent)
|
@comment= @local_luke.comment("yo", :post => @local_parent)
|
||||||
@retraction= @local_luke.retract(@comment)
|
@retraction= @local_luke.retract(@comment)
|
||||||
end
|
end
|
||||||
it 'delegates it to target' do
|
it 'delegates it to target' do
|
||||||
|
|
@ -26,7 +26,7 @@ describe RelayableRetraction do
|
||||||
|
|
||||||
describe '#receive' do
|
describe '#receive' do
|
||||||
it 'discards a retraction with a nil target' do
|
it 'discards a retraction with a nil target' do
|
||||||
@comment= @local_luke.comment("yo", :on => @local_parent)
|
@comment= @local_luke.comment("yo", :post => @local_parent)
|
||||||
@retraction= @local_luke.retract(@comment)
|
@retraction= @local_luke.retract(@comment)
|
||||||
|
|
||||||
@retraction.instance_variable_set(:@target, nil)
|
@retraction.instance_variable_set(:@target, nil)
|
||||||
|
|
@ -36,7 +36,7 @@ describe RelayableRetraction do
|
||||||
end
|
end
|
||||||
context 'from the downstream author' do
|
context 'from the downstream author' do
|
||||||
before do
|
before do
|
||||||
@comment = @local_leia.comment("yo", :on => @local_parent)
|
@comment = @local_leia.comment("yo", :post => @local_parent)
|
||||||
@retraction = @local_leia.retract(@comment)
|
@retraction = @local_leia.retract(@comment)
|
||||||
@recipient = @local_luke
|
@recipient = @local_luke
|
||||||
end
|
end
|
||||||
|
|
@ -59,7 +59,7 @@ describe RelayableRetraction do
|
||||||
end
|
end
|
||||||
context 'from the upstream owner' do
|
context 'from the upstream owner' do
|
||||||
before do
|
before do
|
||||||
@comment = @local_luke.comment("Yeah, it was great", :on => @remote_parent)
|
@comment = @local_luke.comment("Yeah, it was great", :post => @remote_parent)
|
||||||
@retraction = RelayableRetraction.allocate
|
@retraction = RelayableRetraction.allocate
|
||||||
@retraction.sender = @remote_raphael
|
@retraction.sender = @remote_raphael
|
||||||
@retraction.target = @comment
|
@retraction.target = @comment
|
||||||
|
|
@ -79,7 +79,7 @@ describe RelayableRetraction do
|
||||||
|
|
||||||
describe 'xml' do
|
describe 'xml' do
|
||||||
before do
|
before do
|
||||||
@comment = @local_leia.comment("yo", :on => @local_parent)
|
@comment = @local_leia.comment("yo", :post => @local_parent)
|
||||||
@retraction = RelayableRetraction.build(@local_leia, @comment)
|
@retraction = RelayableRetraction.build(@local_leia, @comment)
|
||||||
@retraction.parent_author_signature = 'PARENTSIGNATURE'
|
@retraction.parent_author_signature = 'PARENTSIGNATURE'
|
||||||
@retraction.target_author_signature = 'TARGETSIGNATURE'
|
@retraction.target_author_signature = 'TARGETSIGNATURE'
|
||||||
|
|
|
||||||
|
|
@ -562,8 +562,8 @@ describe User do
|
||||||
before do
|
before do
|
||||||
@message = alice.post(:status_message, :text => "cool", :to => alice.aspects.first)
|
@message = alice.post(:status_message, :text => "cool", :to => alice.aspects.first)
|
||||||
@message2 = bob.post(:status_message, :text => "uncool", :to => bob.aspects.first)
|
@message2 = bob.post(:status_message, :text => "uncool", :to => bob.aspects.first)
|
||||||
@like = alice.like(true, :on => @message)
|
@like = alice.like(true, :post => @message)
|
||||||
@dislike = bob.like(false, :on => @message)
|
@dislike = bob.like(false, :post => @message)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#like_for' do
|
describe '#like_for' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue