No need for instance variables in CommentsController#create

openid
Marcin Kulik 12 years ago
parent 4138deffd6
commit 0bb3e75fb6

@ -9,14 +9,14 @@ class Api::CommentsController < ApplicationController
end
def create
@comment = Comment.new(params[:comment])
@comment.asciicast = @asciicast
@comment.user = current_user
comment = Comment.new(params[:comment])
comment.asciicast = @asciicast
comment.user = current_user
@comment.save
comment.save
comment = CommentDecorator.new(@comment)
respond_with comment, :location => api_comment_url(@comment)
decorated_comment = CommentDecorator.new(comment)
respond_with decorated_comment, :location => api_comment_url(comment)
end
def destroy

@ -26,17 +26,7 @@ describe Api::CommentsController do
Comment.any_instance.should_receive(:save).and_return(true)
end
it "assigns current_user" do
dispatch
assigns(:comment).user.should_not be_blank
end
it "assigns asciicast" do
dispatch
assigns(:comment).asciicast.should_not be_blank
end
it "assigns asciicast" do
it "response status should be 201" do
dispatch
response.status.should == 201
end

Loading…
Cancel
Save