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:
commit
711df4c359
7 changed files with 4 additions and 6 deletions
|
@ -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'
|
||||
|
|
|
@ -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
0
lib/generators/pundit/policy/templates/policy.rb
Executable file → Normal 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")
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class <%= class_name %>PolicyTest < ActiveSupport::TestCase
|
||||
|
||||
def test_scope
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue