From df04b598572fb530b517e7849da019b1f63e81c7 Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Wed, 1 Jun 2011 15:57:14 -0700 Subject: [PATCH] Change :on to :post in the comment and post methods --- app/controllers/comments_controller.rb | 2 +- app/controllers/likes_controller.rb | 2 +- app/models/user.rb | 3 +-- spec/controllers/aspects_controller_spec.rb | 6 ++--- spec/controllers/comments_controller_spec.rb | 14 +++++------ spec/controllers/likes_controller_spec.rb | 6 ++--- spec/controllers/people_controller_spec.rb | 4 ++-- .../status_messages_controller_spec.rb | 4 ++-- spec/controllers/tags_controller_spec.rb | 2 +- spec/integration/receiving_spec.rb | 4 ++-- spec/lib/postzord/dispatch_spec.rb | 6 ++--- spec/mailers/notifier_spec.rb | 2 +- spec/misc_spec.rb | 2 +- spec/models/comment_spec.rb | 24 +++++++++---------- spec/models/like_spec.rb | 18 +++++++------- spec/models/notification_spec.rb | 6 ++--- spec/models/photo_spec.rb | 2 +- spec/models/post_spec.rb | 2 +- spec/models/relayable_retraction_spec.rb | 10 ++++---- spec/models/user_spec.rb | 4 ++-- 20 files changed, 61 insertions(+), 62 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c428c0735..9ddd5751c 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -14,7 +14,7 @@ class CommentsController < ApplicationController text = params[:text] if target - @comment = current_user.build_comment(:text => text, :on => target) + @comment = current_user.build_comment(:text => text, :post => target) if @comment.save Rails.logger.info("event=create type=comment user=#{current_user.diaspora_handle} status=success comment=#{@comment.id} chars=#{params[:text].length}") diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 357c3b90e..b008dc41a 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -12,7 +12,7 @@ class LikesController < ApplicationController target = current_user.find_visible_post_by_id params[:post_id] positive = (params[:positive] == 'true') ? true : false if target - @like = current_user.build_like(:positive => positive, :on => target) + @like = current_user.build_like(:positive => positive, :post => target) if @like.save Rails.logger.info("event=create type=like user=#{current_user.diaspora_handle} status=success like=#{@like.id} positive=#{positive}") diff --git a/app/models/user.rb b/app/models/user.rb index 82534c1e4..bd7da1297 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,7 @@ class User < ActiveRecord::Base :timeoutable, :token_authenticatable 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_uniqueness_of :username @@ -154,7 +154,6 @@ class User < ActiveRecord::Base end def build_relayable(model, options = {}) - options[:post] = options.delete(:on) m = model.new(options.merge(:author_id => self.person.id)) m.set_guid diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index dd958f810..07c149420 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -65,7 +65,7 @@ describe AspectsController do it 'generates a jasmine fixture with posts', :fixture => 'jasmine' do 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 save_fixture(html_for("body"), "aspects_index_with_posts") @@ -104,7 +104,7 @@ describe AspectsController do post.save! @posts << post end - alice.build_comment(:text => 'lalala', :on => @posts.first ).save + alice.build_comment(:text => 'lalala', :post => @posts.first ).save end describe "post visibilities" do @@ -187,7 +187,7 @@ describe AspectsController do connect_users(alice, @alices_aspect_1, user, aspect) post = alice.post(:status_message, :text => "hello#{n}", :to => @alices_aspect_2.id) 8.times do |n| - user.comment "yo#{post.text}", :on => post + user.comment "yo#{post.text}", :post => post end end end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index bab6710ff..a857e886d 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -49,7 +49,7 @@ describe CommentsController do end 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 post :create, comment_hash old_comment.reload.text.should == 'hello' @@ -73,9 +73,9 @@ describe CommentsController do context 'your post' do before do @message = alice.post(:status_message, :text => "hey", :to => @aspect1.id) - @comment = alice.comment("hey", :on => @message) - @comment2 = bob.comment("hey", :on => @message) - @comment3 = eve.comment("hey", :on => @message) + @comment = alice.comment("hey", :post => @message) + @comment2 = bob.comment("hey", :post => @message) + @comment3 = eve.comment("hey", :post => @message) end it 'lets the user delete his comment' do @@ -94,9 +94,9 @@ describe CommentsController do context "another user's post" do before do @message = bob.post(:status_message, :text => "hey", :to => bob.aspects.first.id) - @comment = alice.comment("hey", :on => @message) - @comment2 = bob.comment("hey", :on => @message) - @comment3 = eve.comment("hey", :on => @message) + @comment = alice.comment("hey", :post => @message) + @comment2 = bob.comment("hey", :post => @message) + @comment3 = eve.comment("hey", :post => @message) end it 'let the user delete his comment' do diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index 1ded8837d..4d95f9172 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -53,7 +53,7 @@ describe LikesController do end it "doesn't post multiple times" do - @user1.like(1, :on => @post) + @user1.like(1, :post => @post) post :create, dislike_hash response.code.should == '422' end @@ -76,7 +76,7 @@ describe LikesController do context 'your like' do before do @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 end @@ -87,7 +87,7 @@ describe LikesController do end 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 expect { diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index c5883b3b0..8788f18a9 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -89,7 +89,7 @@ describe PeopleController do end @posts.each do |post| @users.each do |user| - user.comment "yo#{post.text}", :on => post + user.comment "yo#{post.text}", :post => post end end end @@ -150,7 +150,7 @@ describe PeopleController do it "renders the comments on the user's posts" do 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 response.should be_success end diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index 6ea925212..88f71831d 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -54,8 +54,8 @@ describe StatusMessagesController do end it 'marks a corresponding notification as read' do - alice.comment("comment after me", :on => @message) - bob.comment("here you go", :on => @message) + alice.comment("comment after me", :post => @message) + bob.comment("here you go", :post => @message) note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first lambda{ get :show, :id => @message.id diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index 1ccfe0cd3..492d66897 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -99,7 +99,7 @@ describe TagsController do end it 'succeeds with comments' do - alice.comment('what WHAT!', :on => @post) + alice.comment('what WHAT!', :post => @post) get :show, :name => 'what' response.should be_success end diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index 2d96f12e8..4e6d9315d 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -233,7 +233,7 @@ describe 'a user receives a post' do receive_with_zord(bob, 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) @xml = @comment.to_diaspora_xml @comment.delete @@ -290,7 +290,7 @@ describe 'a user receives a post' do end 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 lambda { diff --git a/spec/lib/postzord/dispatch_spec.rb b/spec/lib/postzord/dispatch_spec.rb index f46a0ca60..414dde600 100644 --- a/spec/lib/postzord/dispatch_spec.rb +++ b/spec/lib/postzord/dispatch_spec.rb @@ -84,7 +84,7 @@ describe Postzord::Dispatch do end context "local leia" do before do - @comment = @local_leia.build_comment :text => "yo", :on => @post + @comment = @local_leia.build_comment :text => "yo", :post => @post @comment.save end context "local leia's mailman" do @@ -156,7 +156,7 @@ describe Postzord::Dispatch do end context "local luke" do before do - @comment = @local_luke.build_comment :text => "yo", :on => @post + @comment = @local_luke.build_comment :text => "yo", :post => @post @comment.save @mailman = Postzord::Dispatch.new(@local_luke, @comment) end @@ -182,7 +182,7 @@ describe Postzord::Dispatch do context "remote raphael's post is commented on by local luke" do before do @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 @mailman = Postzord::Dispatch.new(@local_luke, @comment) end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 40c062067..69bf65f2c 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -163,7 +163,7 @@ describe Notifier do context "comments" do let!(:connect) { connect_users(user, aspect, user2, aspect2)} 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 let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment.id).deliver} diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 5c1b3365a..e01f93f17 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -58,7 +58,7 @@ describe 'making sure the spec runner works' do m.stub!(:post) Postzord::Dispatch.should_receive(:new).and_return(m) - alice.comment "yo", :on => person_status + alice.comment "yo", :post => person_status end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 8f0a10c12..74f6d7871 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -17,19 +17,19 @@ describe Comment do describe 'comment#notification_type' 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 end 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 end context "also commented" do before do - @bob.comment("a-commenta commenta", :on => @status) - @comment = @eve.comment("I also commented on the first user's post", :on => @status) + @bob.comment("a-commenta commenta", :post => @status) + @comment = @eve.comment("I also commented on the first user's post", :post => @status) end it 'does not return also commented if the user commented' do @@ -45,17 +45,17 @@ describe Comment do describe 'User#comment' 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" end 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" end it 'does not multi-post a comment' do lambda { - alice.comment 'hello', :on => @status + alice.comment 'hello', :post => @status }.should change { Comment.count }.by(1) end end @@ -66,7 +66,7 @@ describe Comment do @commenter_aspect = @commenter.aspects.create(:name => "bruisers") connect_users(alice, @alices_aspect, @commenter, @commenter_aspect) @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 end 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( [nil, 'Foobar '+expected_title+' hallo welt dsd']) - comment = alice.build_comment :text => url, :on => @message + comment = alice.build_comment :text => url, :post => @message comment.save! 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) @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_recipient = @local_leia.build_comment(:text => "yo", :on => @local_parent) + @object_by_parent_author = @local_luke.comment("yo", :post => @local_parent) + @object_by_recipient = @local_leia.build_comment(:text => "yo", :post => @local_parent) @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 it_should_behave_like 'it is relayable' end diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index f3b9859b8..19c0b4963 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, :on => @status) + alice.like(1, :post => @status) @status.reload.likes.first.positive.should == true end 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 end it "does not allow multiple likes" do lambda { - alice.like(1, :on => @status) - alice.like(0, :on => @status) + alice.like(1, :post => @status) + alice.like(0, :post => @status) }.should raise_error end end describe '#notification_type' do before do - @like = @alice.like(1, :on => @status) + @like = @alice.like(1, :post => @status) end 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") connect_users(alice, @alices_aspect, @liker, @liker_aspect) @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 end it 'serializes the sender handle' do @@ -90,11 +90,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, :on => @local_parent) - @object_by_recipient = @local_leia.build_like(:positive => 1, :on => @local_parent) + @object_by_parent_author = @local_luke.like(1, :post => @local_parent) + @object_by_recipient = @local_leia.build_like(:positive => 1, :post => @local_parent) @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 it_should_behave_like 'it is relayable' end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index f97b2b2b0..4a025d6ff 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -119,8 +119,8 @@ describe Notification do before do @user3 = bob @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 => @user.person, :object => @user.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", :post => @sm)).receive_object end it "updates the notification with a more people if one already exists" do @@ -128,7 +128,7 @@ describe Notification do end 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 end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index fef115151..aeb42e951 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -171,7 +171,7 @@ describe Photo do context "commenting" 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 diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index d63a2641f..a591c399c 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -13,7 +13,7 @@ describe Post do describe 'deletion' do it 'should delete a posts comments on delete' do post = Factory.create(:status_message, :author => @user.person) - @user.comment "hey", :on => post + @user.comment "hey", :post => post post.destroy Post.where(:id => post.id).empty?.should == true Comment.where(:text => "hey").empty?.should == true diff --git a/spec/models/relayable_retraction_spec.rb b/spec/models/relayable_retraction_spec.rb index 45f25c201..2c26ba93f 100644 --- a/spec/models/relayable_retraction_spec.rb +++ b/spec/models/relayable_retraction_spec.rb @@ -14,7 +14,7 @@ describe RelayableRetraction do describe '#subscribers' do before do - @comment= @local_luke.comment("yo", :on => @local_parent) + @comment= @local_luke.comment("yo", :post => @local_parent) @retraction= @local_luke.retract(@comment) end it 'delegates it to target' do @@ -26,7 +26,7 @@ describe RelayableRetraction do describe '#receive' 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.instance_variable_set(:@target, nil) @@ -36,7 +36,7 @@ describe RelayableRetraction do end context 'from the downstream author' do before do - @comment = @local_leia.comment("yo", :on => @local_parent) + @comment = @local_leia.comment("yo", :post => @local_parent) @retraction = @local_leia.retract(@comment) @recipient = @local_luke end @@ -59,7 +59,7 @@ describe RelayableRetraction do end context 'from the upstream owner' 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.sender = @remote_raphael @retraction.target = @comment @@ -79,7 +79,7 @@ describe RelayableRetraction do describe 'xml' 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.parent_author_signature = 'PARENTSIGNATURE' @retraction.target_author_signature = 'TARGETSIGNATURE' diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2cad8c7db..a91214359 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -562,8 +562,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, :on => @message) - @dislike = bob.like(false, :on => @message) + @like = alice.like(true, :post => @message) + @dislike = bob.like(false, :post => @message) end describe '#like_for' do