Merge Request #3
← To merge requests
From
hugomelo:test_author_name
into
noosfero-plugins:master
Add test to make sure that author.name is present even if fields param is passed
Esse teste está ok pra voce?
Commits (1)
-
Add test to make sure that author.name is present even if fields is passed
Showing
1 changed file
Show diff stats
... | ... | @@ -0,0 +1,22 @@ |
1 | +require_relative '../test_helper' | |
2 | +require_relative '../../../../test/unit/api/test_helper' | |
3 | + | |
4 | +class APITest < ActiveSupport::TestCase | |
5 | + | |
6 | + def setup | |
7 | + login_api | |
8 | + end | |
9 | + | |
10 | + should 'list article children with author.name without filtering for that' do | |
11 | + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing", author_id: user.person.id) | |
12 | + child1 = fast_create(Article, :parent_id => article.id, :profile_id => user.person.id, :author_id => user.person.id,:name => "Some thing") | |
13 | + child2 = fast_create(Article, :parent_id => article.id, :profile_id => user.person.id, :author_id => user.person.id,:name => "Some thing") | |
14 | + | |
15 | + params['fields'] = 'title,id' | |
16 | + get "/api/v1/articles/#{article.id}/children?#{params.to_query}" | |
17 | + json = JSON.parse(last_response.body) | |
18 | + assert_equivalent [child1.author.name, child2.author.name], json["articles"].map { |a| a["author"]["name"] unless a['author'].nil? } | |
19 | + end | |
20 | + | |
21 | +end | |
22 | + | ... | ... |