1
0
Fork 0
mirror of https://github.com/varvet/pundit.git synced 2022-11-09 12:30:11 -05:00

Merge pull request #516 from yhirano55/improve-policy-generator

Improve policy generator
This commit is contained in:
Linus Marton 2018-05-25 08:09:46 +02:00 committed by GitHub
commit 711df4c359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 4 additions and 6 deletions

View file

@ -1,7 +1,7 @@
module Pundit
module Generators
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
source_root File.expand_path('templates', __dir__)
def copy_application_policy
template 'application_policy.rb', 'app/policies/application_policy.rb'

View file

@ -1,7 +1,7 @@
module Pundit
module Generators
class PolicyGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
source_root File.expand_path('templates', __dir__)
def create_policy
template 'policy.rb', File.join('app/policies', class_path, "#{file_name}_policy.rb")

0
lib/generators/pundit/policy/templates/policy.rb Executable file → Normal file
View file

View file

@ -1,7 +1,7 @@
module Rspec
module Generators
class PolicyGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
source_root File.expand_path('templates', __dir__)
def create_policy_spec
template 'policy_spec.rb', File.join('spec/policies', class_path, "#{file_name}_policy_spec.rb")

View file

@ -1,7 +1,6 @@
require '<%= File.exists?('spec/rails_helper.rb') ? 'rails_helper' : 'spec_helper' %>'
RSpec.describe <%= class_name %>Policy do
let(:user) { User.new }
subject { described_class }

View file

@ -1,7 +1,7 @@
module TestUnit
module Generators
class PolicyGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
source_root File.expand_path('templates', __dir__)
def create_policy_test
template 'policy_test.rb', File.join('test/policies', class_path, "#{file_name}_policy_test.rb")

View file

@ -1,7 +1,6 @@
require 'test_helper'
class <%= class_name %>PolicyTest < ActiveSupport::TestCase
def test_scope
end