Commit fb32cdd0bfe123fa6e95ef2b0d499449779ac7a9

Authored by Larissa Reis
1 parent e68b4d65

api: fixes comment test

  Instead of using nested attributes to create new comment, API users
  will just put the attributes straight up. It makes more sense that
  way, avoiding redundancy in the request url.
Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
lib/noosfero/api/v1/comments.rb
@@ -27,10 +27,10 @@ module Noosfero @@ -27,10 +27,10 @@ module Noosfero
27 end 27 end
28 28
29 # Example Request: 29 # Example Request:
30 - # POST api/v1/articles/12/comments?private_toke=234298743290432&body=new comment 30 + # POST api/v1/articles/12/comments?private_token=2298743290432&body=new comment&title=New
31 post ":id/comments" do 31 post ":id/comments" do
32 article = find_article(environment.articles, params[:id]) 32 article = find_article(environment.articles, params[:id])
33 - options = params[:comment].merge(:author => current_person) 33 + options = params.select { |key,v| !['id','private_token'].include?(key) }.merge(:author => current_person)
34 present article.comments.create(options), :with => Entities::Comment 34 present article.comments.create(options), :with => Entities::Comment
35 end 35 end
36 end 36 end