Skip to content

Commit

Permalink
Fix errors in RepublishedFeedPolicy
Browse files Browse the repository at this point in the history
The acl9 gem now raises an error when checking for a role
against nil objects.
  • Loading branch information
Patrick Lewis committed May 15, 2018
1 parent 7ed937b commit dad45ae
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/policies/republished_feed_policy.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# frozen_string_literal: true
class RepublishedFeedPolicy < ApplicationPolicy
def create?
return false unless user.present?
return false if user.blank?
return true if user.has_role?(:superadmin)
return false if record.hub.blank?

user.has_role?(:superadmin) ||
user.has_role?(:owner, record.hub) ||
user.has_role?(:remixer, record.hub)
user.has_role?(:owner, record.hub) || user.has_role?(:remixer, record.hub)
end

def destroy?
return false unless user.present?
return false if user.blank?
return true if user.has_role?(:superadmin)
return true if user.has_role?(:owner, record)

user.has_role?(:superadmin) ||
user.has_role?(:owner, record.hub) ||
user.has_role?(:owner, record)
record.hub.present? && user.has_role?(:owner, record.hub)
end

def inputs?
Expand All @@ -33,10 +33,10 @@ def removals?
end

def update?
return false unless user.present?
return false if user.blank?
return true if user.has_role?(:superadmin)
return true if user.has_role?(:owner, record)

user.has_role?(:superadmin) ||
user.has_role?(:owner, record.hub) ||
user.has_role?(:owner, record)
record.hub.present? && user.has_role?(:owner, record.hub)
end
end

0 comments on commit dad45ae

Please sign in to comment.