Commit fe743558330c5c99f979889d755b3b29599d58a0
1 parent
57bd217d
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
api: register vote without user
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
lib/noosfero/api/v1/articles.rb
| ... | ... | @@ -34,7 +34,7 @@ module Noosfero |
| 34 | 34 | # FIXME verify allowed values |
| 35 | 35 | render_api_error!('Vote value not allowed', 400) unless [-1, 1].include?(value) |
| 36 | 36 | article = find_article(environment.articles, params[:id]) |
| 37 | - Vote.create!(:voteable => article, :voter => current_person, :vote => value) | |
| 37 | + Vote.create!(:voteable => article, :voter => nil, :vote => value) | |
| 38 | 38 | {:vote => true} |
| 39 | 39 | end |
| 40 | 40 | ... | ... |
test/unit/api/articles_test.rb
| ... | ... | @@ -476,4 +476,11 @@ class ArticlesTest < ActiveSupport::TestCase |
| 476 | 476 | assert_equal 400, last_response.status |
| 477 | 477 | end |
| 478 | 478 | |
| 479 | + should 'allow multiple votes for an article' do | |
| 480 | + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | |
| 481 | + post "/api/v1/articles/#{article.id}/vote?#{params.to_query}" | |
| 482 | + post "/api/v1/articles/#{article.id}/vote?#{params.to_query}" | |
| 483 | + assert_equal 2, Vote.where(:voteable_id => article.id).sum(:vote) | |
| 484 | + end | |
| 485 | + | |
| 479 | 486 | end | ... | ... |