File tree Expand file tree Collapse file tree 4 files changed +11
-16
lines changed Expand file tree Collapse file tree 4 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ def app_generator
21
21
private
22
22
def generator_options
23
23
options = { api : !!Rails . application . config . api_only , update : true }
24
+ options [ :name ] = Rails . application . class . name . chomp ( "::Application" ) . underscore
24
25
options [ :skip_active_job ] = !defined? ( ActiveJob ::Railtie )
25
26
options [ :skip_active_record ] = !defined? ( ActiveRecord ::Railtie )
26
27
options [ :skip_active_storage ] = !defined? ( ActiveStorage ::Engine )
Original file line number Diff line number Diff line change @@ -11,22 +11,11 @@ def app_name
11
11
end
12
12
13
13
def original_app_name
14
- @original_app_name ||= defined_app_const_base? ? defined_app_name : ( options [ :name ] || File . basename ( destination_root ) )
14
+ @original_app_name ||= ( options [ :name ] || File . basename ( destination_root ) )
15
15
end
16
16
17
- def defined_app_name
18
- defined_app_const_base . underscore
19
- end
20
-
21
- def defined_app_const_base
22
- Rails . respond_to? ( :application ) && defined? ( Rails ::Application ) &&
23
- Rails . application . is_a? ( Rails ::Application ) && Rails . application . class . name . chomp ( "::Application" )
24
- end
25
-
26
- alias :defined_app_const_base? :defined_app_const_base
27
-
28
17
def app_const_base
29
- @app_const_base ||= defined_app_const_base || app_name . gsub ( /\W / , "_" ) . squeeze ( "_" ) . camelize
18
+ @app_const_base ||= app_name . gsub ( /\W / , "_" ) . squeeze ( "_" ) . camelize
30
19
end
31
20
alias :camelized :app_const_base
32
21
Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ def with_bare_config
35
35
assert File . exist? ( File . join ( rails_root , "vendor/plugins/bukkits/test/dummy/config/application.rb" ) )
36
36
end
37
37
38
+ test "allow generating plugin inside Rails app directory" do
39
+ rails "generate" , "plugin" , "vendor/plugins/bukkits"
40
+ assert File . exist? ( File . join ( rails_root , "vendor/plugins/bukkits/test/dummy/config/application.rb" ) )
41
+ end
42
+
38
43
test "generators default values" do
39
44
with_bare_config do |c |
40
45
assert_equal ( true , c . generators . colorize_logging )
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ class ChangeGeneratorTest < Rails::Generators::TestCase
36
36
37
37
assert_file ( "config/database.yml" ) do |content |
38
38
assert_match "adapter: postgresql" , content
39
- assert_match "database: test_app " , content
39
+ assert_match "database: tmp_production " , content
40
40
end
41
41
42
42
assert_file ( "Gemfile" ) do |content |
@@ -50,7 +50,7 @@ class ChangeGeneratorTest < Rails::Generators::TestCase
50
50
51
51
assert_file ( "config/database.yml" ) do |content |
52
52
assert_match "adapter: mysql2" , content
53
- assert_match "database: test_app " , content
53
+ assert_match "database: tmp_production " , content
54
54
end
55
55
56
56
assert_file ( "Gemfile" ) do |content |
@@ -79,7 +79,7 @@ class ChangeGeneratorTest < Rails::Generators::TestCase
79
79
80
80
assert_file ( "config/database.yml" ) do |content |
81
81
assert_match "adapter: mysql2" , content
82
- assert_match "database: test_app " , content
82
+ assert_match "database: tmp_production " , content
83
83
end
84
84
85
85
assert_file ( "Gemfile" ) do |content |
You can’t perform that action at this time.
0 commit comments