diff options
| author | Robert | 2017-05-24 08:31:24 +0200 |
|---|---|---|
| committer | Robert | 2017-05-24 08:31:24 +0200 |
| commit | a83ee0d627ac4a9c4626bfdc2e5ecd2157577b24 (patch) | |
| tree | b06a95421582f5941e249f3087586dd25816d95a | |
| parent | 571ce311bb44e5042189529cfb63bd09106ddc22 (diff) | |
| download | chouette-core-a83ee0d627ac4a9c4626bfdc2e5ecd2157577b24.tar.bz2 | |
Fixes #3446; adding routing_contstraint_zones policies
| -rw-r--r-- | app/policies/application_policy.rb | 2 | ||||
| -rw-r--r-- | app/policies/routing_constraint_zone_policy.rb | 3 | ||||
| -rw-r--r-- | spec/features/line_footnotes_spec.rb | 3 | ||||
| -rw-r--r-- | spec/policies/routing_constraint_zone_policy_spec.rb | 22 |
4 files changed, 26 insertions, 4 deletions
diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index 00d6729f0..fccc5e3a3 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -8,7 +8,7 @@ class ApplicationPolicy end def archived? - referential.ready + referential.try(:ready) end def referential diff --git a/app/policies/routing_constraint_zone_policy.rb b/app/policies/routing_constraint_zone_policy.rb index 58cbaa9e1..abba5639c 100644 --- a/app/policies/routing_constraint_zone_policy.rb +++ b/app/policies/routing_constraint_zone_policy.rb @@ -1,10 +1,13 @@ class RoutingConstraintZonePolicy < BoivPolicy + extend Policies::Chain class Scope < Scope def resolve scope end end + chain_policies :archived?, :!, policies: %i{create? destroy? edit?} + def create? user.has_permission?('routing_constraint_zones.create') # organisation match via referential is checked in the view end diff --git a/spec/features/line_footnotes_spec.rb b/spec/features/line_footnotes_spec.rb index 4d77cba41..6a359ad50 100644 --- a/spec/features/line_footnotes_spec.rb +++ b/spec/features/line_footnotes_spec.rb @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -require 'spec_helper' - describe 'Line Footnotes', type: :feature do login_user diff --git a/spec/policies/routing_constraint_zone_policy_spec.rb b/spec/policies/routing_constraint_zone_policy_spec.rb new file mode 100644 index 000000000..d017c1379 --- /dev/null +++ b/spec/policies/routing_constraint_zone_policy_spec.rb @@ -0,0 +1,22 @@ +RSpec.describe RoutingConstraintZonePolicy, type: :policy do + + permissions :create? do + it_behaves_like 'permitted policy', 'routing_constraint_zones.create', restricted_ready: true + end + + permissions :destroy? do + it_behaves_like 'permitted policy and same organisation', 'routing_constraint_zones.destroy', restricted_ready: true + end + + permissions :edit? do + it_behaves_like 'permitted policy and same organisation', 'routing_constraint_zones.edit', restricted_ready: true + end + + permissions :new? do + it_behaves_like 'permitted policy', 'routing_constraint_zones.create', restricted_ready: true + end + + permissions :update? do + it_behaves_like 'permitted policy and same organisation', 'routing_constraint_zones.edit', restricted_ready: true + end +end |
