Commit ba59eba6bc6ae105deeb411960226f93e3745764
1 parent
a3937f82
Exists in
theme-brasil-digital-from-staging
and in
4 other branches
api: fix search tests
Showing
1 changed file
with
8 additions
and
8 deletions
Show diff stats
test/unit/api/search_test.rb
... | ... | @@ -10,9 +10,9 @@ class SearchTest < ActiveSupport::TestCase |
10 | 10 | should 'not list unpublished articles' do |
11 | 11 | Article.delete_all |
12 | 12 | article = fast_create(Article, :profile_id => person.id, :published => false) |
13 | - assert !article.published? | |
13 | + assert !article.published? | |
14 | 14 | get "/api/v1/search/article" |
15 | - json = JSON.parse(last_response.body) | |
15 | + json = JSON.parse(last_response.body) | |
16 | 16 | assert_empty json['articles'] |
17 | 17 | end |
18 | 18 | |
... | ... | @@ -26,21 +26,21 @@ class SearchTest < ActiveSupport::TestCase |
26 | 26 | should 'invalid search string articles' do |
27 | 27 | fast_create(Article, :profile_id => person.id, :name => 'some article') |
28 | 28 | get "/api/v1/search/article?query=test" |
29 | - json = JSON.parse(last_response.body) | |
29 | + json = JSON.parse(last_response.body) | |
30 | 30 | assert_empty json['articles'] |
31 | 31 | end |
32 | 32 | |
33 | 33 | should 'do not list articles of wrong type' do |
34 | - fast_create(Article, :profile_id => person.id) | |
34 | + article = fast_create(Article, :profile_id => person.id) | |
35 | 35 | get "/api/v1/search/article?type=TinyMceArticle" |
36 | 36 | json = JSON.parse(last_response.body) |
37 | - assert_empty json['articles'] | |
37 | + assert_not_includes json['articles'].map {|a| a['id']}, article.id | |
38 | 38 | end |
39 | 39 | |
40 | 40 | should 'list articles of one type' do |
41 | 41 | fast_create(Article, :profile_id => person.id) |
42 | 42 | article = fast_create(TinyMceArticle, :profile_id => person.id) |
43 | - | |
43 | + | |
44 | 44 | get "/api/v1/search/article?type=TinyMceArticle" |
45 | 45 | json = JSON.parse(last_response.body) |
46 | 46 | assert_equal article.id, json['articles'].first['id'] |
... | ... | @@ -105,7 +105,7 @@ class SearchTest < ActiveSupport::TestCase |
105 | 105 | json = JSON.parse(last_response.body) |
106 | 106 | assert_equal 1, json['articles'].count |
107 | 107 | assert_equal article.id, json['articles'].first["id"] |
108 | - end | |
108 | + end | |
109 | 109 | |
110 | 110 | should 'search filter by category' do |
111 | 111 | Article.delete_all |
... | ... | @@ -117,7 +117,7 @@ class SearchTest < ActiveSupport::TestCase |
117 | 117 | json = JSON.parse(last_response.body) |
118 | 118 | assert_equal 1, json['articles'].count |
119 | 119 | assert_equal article.id, json['articles'].first["id"] |
120 | - end | |
120 | + end | |
121 | 121 | |
122 | 122 | should 'search filter by more than one category' do |
123 | 123 | Article.delete_all | ... | ... |