Skip to content

Commit

Permalink
more defensive code
Browse files Browse the repository at this point in the history
  • Loading branch information
mathmerized committed Oct 1, 2018
1 parent 84a0506 commit ed30fa7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/abilities/authorized_asset_event_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(user, organization_ids=[])
#-------------------------------------------------------------------------
# Can manage asset events if the asset is owned by their organization
can :manage, AssetEvent do |ae|
ae.asset_event_type.try(:active) && organization_ids.include?(ae.asset.organization_id)
ae.asset_event_type.try(:active) && organization_ids.include?(ae.asset.try(:organization_id))
end

cannot :create, DispositionUpdateEvent do |ae|
Expand All @@ -30,7 +30,7 @@ def initialize(user, organization_ids=[])

# Can manage asset events if the asset is owned by their organization
can :manage, AssetEvent do |ae|
ae.asset_event_type.try(:active) && organization_ids.include?(ae.transam_asset.organization_id)
ae.asset_event_type.try(:active) && organization_ids.include?(ae.transam_asset.try(:organization_id))
end

cannot :create, DispositionUpdateEvent do |ae|
Expand Down
4 changes: 2 additions & 2 deletions app/models/abilities/manager_asset_event_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(user)
#-------------------------------------------------------------------------
# managers can manage asset events if the asset's organization is in their list
can :manage, AssetEvent do |ae|
ae.asset_event_type.try(:active) && user.organization_ids.include?(ae.asset.organization_id)
ae.asset_event_type.try(:active) && user.organization_ids.include?(ae.asset.try(:organization_id))
end

can :manage, EarlyDispositionRequestUpdateEvent do |ae|
Expand All @@ -26,7 +26,7 @@ def initialize(user)

# managers can manage asset events if the asset's organization is in their list
can :manage, AssetEvent do |ae|
ae.asset_event_type.try(:active) && user.organization_ids.include?(ae.transam_asset.organization_id)
ae.asset_event_type.try(:active) && user.organization_ids.include?(ae.transam_asset.try(:organization_id))
end

cannot :create, DispositionUpdateEvent do |ae|
Expand Down

0 comments on commit ed30fa7

Please sign in to comment.