Use form_tag, not form_for, in _new_comment
This commit is contained in:
parent
f59c6e2427
commit
6d6b07fb92
3 changed files with 12 additions and 13 deletions
|
|
@ -10,8 +10,8 @@ class CommentsController < ApplicationController
|
||||||
respond_to :json, :only => :show
|
respond_to :json, :only => :show
|
||||||
|
|
||||||
def create
|
def create
|
||||||
target = current_user.find_visible_post_by_id params[:comment][:post_id]
|
target = current_user.find_visible_post_by_id params[:post_id]
|
||||||
text = params[:comment][:text]
|
text = params[:text]
|
||||||
|
|
||||||
@comment = current_user.build_comment(text, :on => target)
|
@comment = current_user.build_comment(text, :on => target)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
= form_for Comment.new, :html => {:id => "new_comment_on_#{post_id}" }, :remote => true do |comment|
|
= form_tag( comments_path, :id => "new_comment_on_#{post_id}" , :remote => true) do
|
||||||
%p
|
%p
|
||||||
= label_tag "comment_text_on_#{post_id}", t('.comment')
|
= label_tag "comment_text_on_#{post_id}", t('.comment')
|
||||||
= comment.text_area :text, :rows => 1, :id => "comment_text_on_#{post_id}", :class => "comment_box"
|
= text_area_tag :text, nil, :rows => 1, :class => "comment_box",:id => "comment_text_on_#{post_id}"
|
||||||
= comment.hidden_field :post_id, :id => "post_id_on_#{post_id}", :value => post_id
|
= hidden_field_tag :post_id, post_id, :id => "post_id_on_#{post_id}"
|
||||||
= comment.submit t('.comment'), :id => "comment_submit_#{post_id}", :class => "comment_submit button", :disable_with => t('.commenting')
|
= submit_tag t('.comment'), :id => "comment_submit_#{post_id}", :class => "comment_submit button", :disable_with => t('.commenting')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,8 @@ describe CommentsController do
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
let(:comment_hash) {
|
let(:comment_hash) {
|
||||||
{:comment =>{
|
{:text =>"facebook, is that you?",
|
||||||
:text =>"facebook, is that you?",
|
:post_id =>"#{@post.id}"}
|
||||||
:post_id =>"#{@post.id}"}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context "on a post from a contact" do
|
context "on a post from a contact" do
|
||||||
|
|
@ -36,13 +35,13 @@ describe CommentsController do
|
||||||
end
|
end
|
||||||
it "doesn't overwrite person_id" do
|
it "doesn't overwrite person_id" do
|
||||||
new_user = make_user
|
new_user = make_user
|
||||||
comment_hash[:comment][:person_id] = new_user.person.id.to_s
|
comment_hash[:person_id] = new_user.person.id.to_s
|
||||||
post :create, comment_hash
|
post :create, comment_hash
|
||||||
Comment.find_by_text(comment_hash[:comment][:text]).person_id.should == user.person.id
|
Comment.find_by_text(comment_hash[:text]).person_id.should == user.person.id
|
||||||
end
|
end
|
||||||
it "doesn't overwrite id" do
|
it "doesn't overwrite id" do
|
||||||
old_comment = user.comment("hello", :on => @post)
|
old_comment = user.comment("hello", :on => @post)
|
||||||
comment_hash[:comment][: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'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue