[Git][noosfero/noosfero][master] 3 commits: create allow_edit_design permission
Leandro Nunes
gitlab at mg.gitlab.com
Fri Aug 4 14:43:57 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
ee7ce2d6 by Leandro Nunes dos Santos at 2017-08-04T10:47:49-03:00
create allow_edit_design permission
- - - - -
d9074f16 by Leandro Nunes dos Santos at 2017-08-04T14:04:24-03:00
should check permission for profile
- - - - -
53ddc99d by Leandro Nunes at 2017-08-04T17:43:40+00:00
Merge branch 'create-permission-edit_design' into 'master'
create allow_edit_design permission
See merge request !1296
- - - - -
4 changed files:
- app/api/entities.rb
- app/models/profile.rb
- test/api/profiles_test.rb
- test/unit/profile_test.rb
Changes:
=====================================
app/api/entities.rb
=====================================
--- a/app/api/entities.rb
+++ b/app/api/entities.rb
@@ -142,7 +142,7 @@ module Api
expose :layout_template
expose :permissions do |profile, options|
Entities.permissions_for_entity(profile, options[:current_person],
- :allow_post_content?, :allow_edit?, :allow_destroy?)
+ :allow_post_content?, :allow_edit?, :allow_destroy?, :allow_edit_design?)
end
expose :theme do |profile, options|
profile.theme || profile.environment.theme
=====================================
app/models/profile.rb
=====================================
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -1241,6 +1241,10 @@ private :generate_url, :url_options
person.kind_of?(Profile) && person.has_permission?('destroy_profile', self)
end
+ def allow_edit_design?(person = nil )
+ person.kind_of?(Profile) && person.has_permission?('edit_profile_design', self)
+ end
+
def in_circle?(circle, follower)
ProfileFollower.with_follower(follower).with_circle(circle).with_profile(self).present?
end
=====================================
test/api/profiles_test.rb
=====================================
--- a/test/api/profiles_test.rb
+++ b/test/api/profiles_test.rb
@@ -303,6 +303,15 @@ class ProfilesTest < ActiveSupport::TestCase
assert_includes json["permissions"], 'allow_post_content'
end
+ should 'list permissions allow_edit_design if ther person has it on profile' do
+ login_api
+ profile = fast_create(Community)
+ give_permission(person, 'edit_profile_design', profile)
+ get "/api/v1/profiles/#{profile.id}?#{params.to_query}"
+ json = JSON.parse(last_response.body)
+ assert_includes json["permissions"], 'allow_edit_design'
+ end
+
should 'update profile image' do
login_api
community = fast_create(Community)
=====================================
test/unit/profile_test.rb
=====================================
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -2339,7 +2339,7 @@ class ProfileTest < ActiveSupport::TestCase
assert_not_includes profiles, p4
end
- ['post_content', 'edit_profile', 'destroy_profile'].each do |permission|
+ ['post_content', 'edit_profile', 'destroy_profile', 'edit_profile_design'].each do |permission|
should "return true in #{permission} when user has this permission" do
profile = fast_create(Profile)
person = fast_create(Person)
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/02e3e9b0d7f33cff6b242cf412ec3e56d13998c6...53ddc99dce2a938b25908dd35692cc2553952a2a
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/02e3e9b0d7f33cff6b242cf412ec3e56d13998c6...53ddc99dce2a938b25908dd35692cc2553952a2a
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/20170804/eee8e0c1/attachment-0001.html>
More information about the Noosfero-dev
mailing list