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