From 220063b67089f24c435affed28496d26e9fffc35 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 30 Nov 2018 13:24:40 +0500 Subject: [PATCH] Add PasswordConfirmationPolicy --- app/policies/passport_confirmation_policy.rb | 10 ++++++++ .../passport_confirmation_policy_spec.rb | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 app/policies/passport_confirmation_policy.rb create mode 100644 spec/policies/passport_confirmation_policy_spec.rb diff --git a/app/policies/passport_confirmation_policy.rb b/app/policies/passport_confirmation_policy.rb new file mode 100644 index 0000000..cdc4176 --- /dev/null +++ b/app/policies/passport_confirmation_policy.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class PassportConfirmationPolicy < ApplicationPolicy + def create? + return false if record.passport.nil? + return false if record.user != user + + policy(record.passport).show? + end +end diff --git a/spec/policies/passport_confirmation_policy_spec.rb b/spec/policies/passport_confirmation_policy_spec.rb new file mode 100644 index 0000000..c3fb288 --- /dev/null +++ b/spec/policies/passport_confirmation_policy_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe PassportConfirmationPolicy do + permissions '.scope' do + pending "add some examples to (or delete) #{__FILE__}" + end + + permissions :show? do + pending "add some examples to (or delete) #{__FILE__}" + end + + permissions :create? do + pending "add some examples to (or delete) #{__FILE__}" + end + + permissions :update? do + pending "add some examples to (or delete) #{__FILE__}" + end + + permissions :destroy? do + pending "add some examples to (or delete) #{__FILE__}" + end +end