[Git][noosfero/noosfero][master] 2 commits: api: return environment theme when profile theme is not defined
Leandro Nunes
gitlab at mg.gitlab.com
Tue May 16 10:10:39 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
f2ad586c by Victor Costa at 2017-05-15T13:28:33-03:00
api: return environment theme when profile theme is not defined
- - - - -
78a37e85 by Leandro Nunes at 2017-05-16T13:10:30+00:00
Merge branch 'api-profile-theme' into 'master'
api: return environment theme when profile theme is not defined
See merge request !1211
- - - - -
2 changed files:
- app/api/entities.rb
- test/api/profiles_test.rb
Changes:
=====================================
app/api/entities.rb
=====================================
--- a/app/api/entities.rb
+++ b/app/api/entities.rb
@@ -148,7 +148,9 @@ module Api
Entities.permissions_for_entity(profile, options[:current_person],
:allow_post_content?, :allow_edit?, :allow_destroy?)
end
- expose :theme
+ expose :theme do |profile, options|
+ profile.theme || profile.environment.theme
+ end
end
class UserBasic < Entity
=====================================
test/api/profiles_test.rb
=====================================
--- a/test/api/profiles_test.rb
+++ b/test/api/profiles_test.rb
@@ -413,4 +413,20 @@ class ProfilesTest < ActiveSupport::TestCase
json = JSON.parse(last_response.body)
assert_equal some_person.id, json['id']
end
+
+ should "return profile theme when it is defined" do
+ some_person = fast_create(Person, theme: 'person-theme')
+ get "/api/v1/profiles/#{some_person.id}?#{params.to_query}"
+ json = JSON.parse(last_response.body)
+ assert_equal 'person-theme', json['theme']
+ end
+
+ should "return environment theme when profile theme is not defined" do
+ some_person = fast_create(Person)
+ environment = some_person.environment
+ environment.update_attribute(:theme, 'environment-theme')
+ get "/api/v1/profiles/#{some_person.id}?#{params.to_query}"
+ json = JSON.parse(last_response.body)
+ assert_equal 'environment-theme', json['theme']
+ end
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/08b6a3899fcb59198f327ec71d877fe2b0399090...78a37e85517ce32c2c7dfa7a52047dd3de5554ca
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/08b6a3899fcb59198f327ec71d877fe2b0399090...78a37e85517ce32c2c7dfa7a52047dd3de5554ca
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170516/0633be4d/attachment-0001.html>
More information about the Noosfero-dev
mailing list