diff --git a/lib/noosfero/api/entities.rb b/lib/noosfero/api/entities.rb index 2ab320d..d234e63 100644 --- a/lib/noosfero/api/entities.rb +++ b/lib/noosfero/api/entities.rb @@ -205,14 +205,15 @@ module Noosfero class User < Entity root 'users', 'user' - attrs = [:id,:login,:email] + attrs = [:id,:login,:email,:activated?] + aliases = {:activated? => :activated} attrs.each do |attribute| - expose attribute, :if => lambda{|user,options| Entities.can_display?(user.person, options, attribute)} + name = aliases.has_key?(attribute) ? aliases[attribute] : attribute + expose attribute, :as => name, :if => lambda{|user,options| Entities.can_display?(user.person, options, attribute)} end expose :person, :using => Person - expose :activated?, as: :activated expose :permissions, :if => lambda{|user,options| Entities.can_display?(user.person, options, :permissions, :self)} do |user, options| output = {} user.person.role_assignments.map do |role_assigment| diff --git a/test/api/articles_test.rb b/test/api/articles_test.rb index fc23fe7..db6e92e 100644 --- a/test/api/articles_test.rb +++ b/test/api/articles_test.rb @@ -207,14 +207,6 @@ class ArticlesTest < ActiveSupport::TestCase end end - should 'not update hit attribute of a specific child if a article is archived' do - folder = fast_create(Folder, :profile_id => user.person.id, :archived => true) - article = fast_create(Article, :parent_id => folder.id, :profile_id => user.person.id) - get "/api/v1/articles/#{folder.id}/children/#{article.id}?#{params.to_query}" - json = JSON.parse(last_response.body) - assert_equal 0, json['article']['hits'] - end - should 'find archived articles' do article1 = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") article2 = fast_create(Article, :profile_id => user.person.id, :name => "Some thing", :archived => true) diff --git a/test/api/helpers_test.rb b/test/api/helpers_test.rb index 26c8833..f239c63 100644 --- a/test/api/helpers_test.rb +++ b/test/api/helpers_test.rb @@ -140,10 +140,6 @@ class APIHelpersTest < ActiveSupport::TestCase assert_not_nil make_conditions_with_parameter('until' => '2010-10-10')[:created_at] end - should 'make_conditions_with_parameter return archived parameter if archived was defined' do - assert_not_nil make_conditions_with_parameter('archived' => true)[:archived] - end - should 'make_conditions_with_parameter return created_at as the first existent date as parameter if only until is defined' do assert_equal Time.at(0).to_datetime, make_conditions_with_parameter(:until => '2010-10-10')[:created_at].min end -- libgit2 0.21.2