Commit 7649012edcce40aba298c2dbc6a7a78867954332

Authored by Leandro Santos
1 parent 9eb2ca42

HOTFIX API: expose display_color for category

lib/noosfero/api/entities.rb
@@ -43,6 +43,7 @@ module Noosfero @@ -43,6 +43,7 @@ module Noosfero
43 expose :parent, :using => CategoryBase, if: { parent: true } 43 expose :parent, :using => CategoryBase, if: { parent: true }
44 expose :children, :using => CategoryBase, if: { children: true } 44 expose :children, :using => CategoryBase, if: { children: true }
45 expose :image, :using => Image 45 expose :image, :using => Image
  46 + expose :display_color
46 end 47 end
47 48
48 class Region < Category 49 class Region < Category
test/unit/api/articles_test.rb
@@ -94,7 +94,7 @@ class ArticlesTest &lt; ActiveSupport::TestCase @@ -94,7 +94,7 @@ class ArticlesTest &lt; ActiveSupport::TestCase
94 expose_attributes = %w(id body abstract created_at title author profile categories image votes_for votes_against setting position hits start_date end_date tag_list parent children children_count) 94 expose_attributes = %w(id body abstract created_at title author profile categories image votes_for votes_against setting position hits start_date end_date tag_list parent children children_count)
95 95
96 expose_attributes.each do |attr| 96 expose_attributes.each do |attr|
97 - should "expose article #{attr} attribute" do 97 + should "expose article #{attr} attribute by default" do
98 article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") 98 article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
99 get "/api/v1/articles/?#{params.to_query}" 99 get "/api/v1/articles/?#{params.to_query}"
100 json = JSON.parse(last_response.body) 100 json = JSON.parse(last_response.body)
test/unit/api/categories_test.rb
@@ -83,4 +83,15 @@ class CategoriesTest &lt; ActiveSupport::TestCase @@ -83,4 +83,15 @@ class CategoriesTest &lt; ActiveSupport::TestCase
83 json["categories"].map{ |c| c['children'].map{ |child| child['id'] }.sort } 83 json["categories"].map{ |c| c['children'].map{ |child| child['id'] }.sort }
84 end 84 end
85 85
  86 + expose_attributes = %w(id name full_name image display_color)
  87 +
  88 + expose_attributes.each do |attr|
  89 + should "expose category #{attr} attribute by default" do
  90 + category = fast_create(Category, :environment_id => environment.id)
  91 + get "/api/v1/categories/?#{params.to_query}"
  92 + json = JSON.parse(last_response.body)
  93 + assert json["categories"].last.has_key?(attr)
  94 + end
  95 + end
  96 +
86 end 97 end