From 6d6b07fb92ed1b20fbbea2c7a83fcb0d70e2f384 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 27 Nov 2010 23:12:42 -0500 Subject: [PATCH] Use form_tag, not form_for, in _new_comment --- app/controllers/comments_controller.rb | 4 ++-- app/views/comments/_new_comment.html.haml | 10 +++++----- spec/controllers/comments_controller_spec.rb | 11 +++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 8f7806a18..b334bcd0a 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -10,8 +10,8 @@ class CommentsController < ApplicationController respond_to :json, :only => :show def create - target = current_user.find_visible_post_by_id params[:comment][:post_id] - text = params[:comment][:text] + target = current_user.find_visible_post_by_id params[:post_id] + text = params[:text] @comment = current_user.build_comment(text, :on => target) diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml index a11d62202..0cafb34d6 100644 --- a/app/views/comments/_new_comment.html.haml +++ b/app/views/comments/_new_comment.html.haml @@ -2,10 +2,10 @@ -# licensed under the Affero General Public License version 3 or later. See -# 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 = label_tag "comment_text_on_#{post_id}", t('.comment') - = comment.text_area :text, :rows => 1, :id => "comment_text_on_#{post_id}", :class => "comment_box" - = comment.hidden_field :post_id, :id => "post_id_on_#{post_id}", :value => post_id - = comment.submit t('.comment'), :id => "comment_submit_#{post_id}", :class => "comment_submit button", :disable_with => t('.commenting') - + = text_area_tag :text, nil, :rows => 1, :class => "comment_box",:id => "comment_text_on_#{post_id}" + = hidden_field_tag :post_id, post_id, :id => "post_id_on_#{post_id}" + = submit_tag t('.comment'), :id => "comment_submit_#{post_id}", :class => "comment_submit button", :disable_with => t('.commenting') + diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 0c2e94c07..804dc4a7e 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -20,9 +20,8 @@ describe CommentsController do describe '#create' do let(:comment_hash) { - {:comment =>{ - :text =>"facebook, is that you?", - :post_id =>"#{@post.id}"}} + {:text =>"facebook, is that you?", + :post_id =>"#{@post.id}"} } context "on a post from a contact" do @@ -36,13 +35,13 @@ describe CommentsController do end it "doesn't overwrite person_id" do 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 - 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 it "doesn't overwrite id" do old_comment = user.comment("hello", :on => @post) - comment_hash[:comment][:id] = old_comment.id + comment_hash[:id] = old_comment.id post :create, comment_hash old_comment.reload.text.should == 'hello' end