Commit 031bde1ccadf7f095f3fe988ea3fa4645dd168cf
1 parent
5086fd08
Exists in
test_author_name
Test author.name being present
Add test to make sure that author.name is present even if fields is passed
Showing
1 changed file
with
22 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,22 @@ | @@ -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 | + |