Skip to content
Extraits de code Groupes Projets
Valider 6d6b07fb rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Use form_tag, not form_for, in _new_comment

parent f59c6e24
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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)
......
......@@ -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')
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter