1
0
Fork 0

Test Pundit policies

This commit is contained in:
Alex Kotov 2018-12-13 08:01:50 +05:00
parent 238d7833c6
commit 75e568e075
No known key found for this signature in database
GPG key ID: 4E831250F47DE154
11 changed files with 34 additions and 134 deletions

View file

@ -204,4 +204,7 @@ group :test do
# It aims to mimic the behaviour of a real user,
# and as such interacts with the HTML of the application.
gem 'selenium-webdriver', '~> 3.14'
# A set of RSpec matchers for testing Pundit authorization policies.
gem 'pundit-matchers', '~> 1.6'
end

View file

@ -250,6 +250,8 @@ GEM
puma (3.12.0)
pundit (2.0.0)
activesupport (>= 3.0.0)
pundit-matchers (1.6.0)
rspec-rails (>= 3.0.0)
rack (2.0.6)
rack-attack (5.4.2)
rack (>= 1.0, < 3)
@ -459,6 +461,7 @@ DEPENDENCIES
pry-rails (~> 0.3)
puma (~> 3.11)
pundit (~> 2.0)
pundit-matchers (~> 1.6)
rack-attack (~> 5.4)
rails (~> 5.2.1)
rails-erd (~> 1.5)

View file

@ -3,23 +3,5 @@
require 'rails_helper'
RSpec.describe <%= class_name %>Policy 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
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ApplicationPolicy do
subject { described_class.new context, record }
let :context do
described_class::Context.new account: account, guest_account: guest_account
end
let(:account) { create :superuser_account }
let(:guest_account) { create :guest_account }
let(:record) { nil }
it do
is_expected.to forbid_actions %i[index show new create edit update destroy]
end
end

View file

@ -3,23 +3,5 @@
require 'rails_helper'
RSpec.describe MembershipAppPolicy 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
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -3,23 +3,5 @@
require 'rails_helper'
RSpec.describe Settings::AccountTelegramContactPolicy 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
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -3,23 +3,5 @@
require 'rails_helper'
RSpec.describe Staff::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
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -3,23 +3,5 @@
require 'rails_helper'
RSpec.describe Staff::PassportPolicy 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
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -3,23 +3,5 @@
require 'rails_helper'
RSpec.describe Staff::TelegramBotPolicy 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
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -3,23 +3,5 @@
require 'rails_helper'
RSpec.describe Staff::TelegramChatPolicy 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
pending "add some examples to (or delete) #{__FILE__}"
end

View file

@ -15,7 +15,7 @@ require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
require 'pundit/rspec'
require 'pundit/matchers'
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are