Newer
Older
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe CommentsController do
render_views
@aspect1 = @user1.aspects.first
@aspect2 = @user2.aspects.first
end
describe '#create' do
let(:comment_hash) {
@post = @user1.post :status_message, :text => 'GIANTS', :to => @aspect1.id
end
it 'responds to format js' do
post :create, comment_hash.merge(:format => 'js')
response.code.should == '201'
context "on a post from a contact" do
@post = @user2.post :status_message, :text => 'GIANTS', :to => @aspect2.id
end
it 'comments' do
post :create, comment_hash
response.code.should == '201'
end
it "doesn't overwrite author_id" do
new_user = Factory.create(:user)
comment_hash[:author_id] = new_user.person.id.to_s
Comment.find_by_text(comment_hash[:text]).author_id.should == @user1.person.id
old_comment = @user1.comment("hello", :on => @post)
post :create, comment_hash
old_comment.reload.text.should == 'hello'
end
end
context 'on a post from a stranger' do
before do
@post = eve.post :status_message, :text => 'GIANTS', :to => eve.aspects.first.id