Skip to content

Commit

Permalink
Adapt policy classes to changes in base class
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Dec 12, 2018
1 parent 66c123d commit c852d9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/api/app/policies/staging/staging_project_policy.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
class Staging::StagingProjectPolicy < ApplicationPolicy
def initialize(user, record)
raise Pundit::NotAuthorizedError, 'staging workflow does not exist' unless record
@user = user
@record = record
super(user, record, user_optional: true)
end

def create?
ProjectPolicy.new(@user, @record).create?
ProjectPolicy.new(user, record).create?
end

def update?
ProjectPolicy.new(@user, @record).update?
ProjectPolicy.new(user, record).update?
end

def edit?
update?
end

def destroy?
ProjectPolicy.new(@user, @record).destroy?
ProjectPolicy.new(user, record).destroy?
end
end
10 changes: 4 additions & 6 deletions src/api/app/policies/staging/workflow_policy.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
class Staging::WorkflowPolicy < ApplicationPolicy
def initialize(user, record)
raise Pundit::NotAuthorizedError, 'staging workflow does not exist' unless record
@user = user
@record = record
super(user, record, user_optional: true)
end

def create?
ProjectPolicy.new(@user, @record.project).update?
ProjectPolicy.new(user, record.project).update?
end

def update?
ProjectPolicy.new(@user, @record.project).update?
ProjectPolicy.new(user, record.project).update?
end

def assign_managers_group?
Expand All @@ -22,6 +20,6 @@ def edit?
end

def destroy?
ProjectPolicy.new(@user, @record.project).destroy?
ProjectPolicy.new(user, record.project).destroy?
end
end

0 comments on commit c852d9e

Please sign in to comment.