diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-02 16:36:21 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-11-02 17:00:48 +0300 |
commit | f1e9c97d64b96bdd398616743ad048f8d147e26b (patch) | |
tree | c90b227256a610d4b639183c5e9b093de35d60f9 /app/serializers | |
parent | acfe394018df50bfc08aa9e41265231747675646 (diff) |
Use entity request object in environment entity
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/environment_entity.rb | 14 | ||||
-rw-r--r-- | app/serializers/project_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/request_aware_entity.rb | 5 |
3 files changed, 14 insertions, 9 deletions
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index 9415f1dd450..006b2841e8f 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -9,9 +9,17 @@ class EnvironmentEntity < Grape::Entity as: :deployment, using: API::Entities::Deployment - expose :environment_path + expose :gitlab_path do |environment| + namespace_project_environment_path( + environment.project.namespace, + environment.project, + environment + ) + end + + expose :can_read? - def environment_path - request.path + def can_read? + Ability.allowed?(request.user, :read_environment, @object) end end diff --git a/app/serializers/project_entity.rb b/app/serializers/project_entity.rb index b8e23db470b..047366eb687 100644 --- a/app/serializers/project_entity.rb +++ b/app/serializers/project_entity.rb @@ -1,8 +1,10 @@ class ProjectEntity < Grape::Entity + include RequestAwareEntity + expose :id expose :name expose :test do |project| - 'something' + request.user.email end end diff --git a/app/serializers/request_aware_entity.rb b/app/serializers/request_aware_entity.rb index f6b6f64d0f8..fc7d1698b1a 100644 --- a/app/serializers/request_aware_entity.rb +++ b/app/serializers/request_aware_entity.rb @@ -1,9 +1,4 @@ module RequestAwareEntity - # We use SerializableRequest class to collect parameters and variables - # from the controller. Because options that are being passed to the entity - # are appear in each entity in the chain, we need a way to access data - # that is present in the controller (see #20045). - # def request options[:request] || raise(StandardError, 'Request not set!!') |