diff options
| author | Alban Peignier | 2017-12-20 09:41:53 +0100 |
|---|---|---|
| committer | Alban Peignier | 2017-12-20 09:42:07 +0100 |
| commit | 38ab26f1ea40b7ab5774ff0c18fba54204767b88 (patch) | |
| tree | 6cac0527da202aae01664e8cda4e5c4649164add /spec/support | |
| parent | 023fdab6840c7bb2d87d8ffee2df478574158d6e (diff) | |
| parent | 0a5c1fd25403c327593a5cbe10c7c58be6128c89 (diff) | |
| download | chouette-core-38ab26f1ea40b7ab5774ff0c18fba54204767b88.tar.bz2 | |
Merge branch 'master' into 5333-add-policies-for-referentials-sharing5333-add-policies-for-referentials-sharing
Diffstat (limited to 'spec/support')
| -rw-r--r-- | spec/support/pundit/pundit_view_policy.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/spec/support/pundit/pundit_view_policy.rb b/spec/support/pundit/pundit_view_policy.rb index b8434cac0..91be0624c 100644 --- a/spec/support/pundit/pundit_view_policy.rb +++ b/spec/support/pundit/pundit_view_policy.rb @@ -1,16 +1,16 @@ module Pundit module PunditViewPolicy - extend ActiveSupport::Concern + def self.included into + into.let(:permissions){ nil } + into.let(:organisation){ referential.try(:organisation) } + into.let(:current_referential){ referential || build_stubbed(:referential) } + into.let(:current_user){ build_stubbed :user, permissions: permissions, organisation: organisation } + into.let(:pundit_user){ UserContext.new(current_user, referential: current_referential) } + into.before do + allow(view).to receive(:pundit_user) { pundit_user } - included do - before do - controller.singleton_class.class_eval do - def policy(instance) - Class.new do - def method_missing(*args, &block); true; end - end.new - end - helper_method :policy + allow(view).to receive(:policy) do |instance| + ::Pundit.policy pundit_user, instance end end end |
