From 75ccdfed8d43d79f6590653212ecea7124759439 Mon Sep 17 00:00:00 2001 From: Lisa Ugray Date: Mon, 24 Jul 2017 14:17:56 -0400 Subject: Stop creating ApplicationRecord on model generation When generating models, we created ApplicationRecord in the default location if no file existed there. That was annoying for people who moved it to somewhere else in the autoload path. At this point, the vast majority of apps should have either run the upgrade script or generated a model since upgrading. For those that haven't the error message after generating a new model should be helpful: NameError: uninitialized constant ApplicationRecord To ease friction in that case, this also adds a generator for ApplicationRecord. --- .../test/generators/application_record_generator_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 railties/test/generators/application_record_generator_test.rb (limited to 'railties/test/generators/application_record_generator_test.rb') diff --git a/railties/test/generators/application_record_generator_test.rb b/railties/test/generators/application_record_generator_test.rb new file mode 100644 index 0000000000..b734d786c0 --- /dev/null +++ b/railties/test/generators/application_record_generator_test.rb @@ -0,0 +1,14 @@ +require "generators/generators_test_helper" +require "rails/generators/rails/application_record/application_record_generator" + +class ApplicationRecordGeneratorTest < Rails::Generators::TestCase + include GeneratorsTestHelper + + def test_application_record_skeleton_is_created + run_generator + assert_file "app/models/application_record.rb" do |record| + assert_match(/class ApplicationRecord < ActiveRecord::Base/, record) + assert_match(/self\.abstract_class = true/, record) + end + end +end -- cgit v1.2.3