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

correctly presence check of application_record.rb in plugin

This commit is contained in:
yuuji.yaginuma 2016-01-02 13:20:46 +09:00
parent 541caffa39
commit 571b090a85
2 changed files with 16 additions and 1 deletions

View file

@ -45,7 +45,13 @@ module ActiveRecord
def determine_default_parent_class
application_record = nil
in_root { application_record = File.exist?('app/models/application_record.rb') }
in_root do
application_record = if mountable_engine?
File.exist?("app/models/#{namespaced_path}/application_record.rb")
else
File.exist?('app/models/application_record.rb')
end
end
if application_record
"ApplicationRecord"

View file

@ -621,6 +621,15 @@ class PluginGeneratorTest < Rails::Generators::TestCase
assert_no_directory "app/views"
end
def test_model_with_existent_application_record_in_mountable_engine
run_generator [destination_root, '--mountable']
capture(:stdout) do
`#{destination_root}/bin/rails g model article`
end
assert_file "app/models/bukkits/article.rb", /class Article < ApplicationRecord/
end
protected
def action(*args, &block)
silence(:stdout){ generator.send(*args, &block) }