diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/engine.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/observer/USAGE | 12 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/observer/observer_generator.rb | 7 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/observer/observer_generator.rb | 13 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb | 9 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 21 | ||||
-rw-r--r-- | railties/test/application/console_test.rb | 17 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 22 | ||||
-rw-r--r-- | railties/test/generators/namespaced_generators_test.rb | 21 | ||||
-rw-r--r-- | railties/test/generators/observer_generator_test.rb | 27 |
13 files changed, 4 insertions, 155 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index f6721c617f..725295004f 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -106,7 +106,7 @@ module Rails # # The <tt>Application</tt> class adds a couple more paths to this set. And as in your # <tt>Application</tt>, all folders under +app+ are automatically added to the load path. - # If you have an <tt>app/observers</tt> folder for example, it will be added by default. + # If you have an <tt>app/services/tt> folder for example, it will be added by default. # # == Endpoint # diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 367f9288b8..d9a91b74d1 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -172,13 +172,11 @@ module Rails "resource_route", "#{orm}:migration", "#{orm}:model", - "#{orm}:observer", "#{test}:controller", "#{test}:helper", "#{test}:integration", "#{test}:mailer", "#{test}:model", - "#{test}:observer", "#{test}:scaffold", "#{test}:view", "#{test}:performance", diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 5c4e81431c..b96ee9295e 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -78,7 +78,7 @@ module Rails # end # # environment(nil, env: "development") do - # "config.active_record.observers = :cacher" + # "config.autoload_paths += %W(#{config.root}/extras)" # end def environment(data=nil, options={}, &block) sentinel = /class [a-z_:]+ < Rails::Application/i diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 84f8f76838..cc10fd9177 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -169,10 +169,10 @@ module Rails # # ==== Examples # - # check_class_collision suffix: "Observer" + # check_class_collision suffix: "Decorator" # # If the generator is invoked with class name Admin, it will check for - # the presence of "AdminObserver". + # the presence of "AdminDecorator". # def self.check_class_collision(options={}) define_method :check_class_collision do diff --git a/railties/lib/rails/generators/rails/observer/USAGE b/railties/lib/rails/generators/rails/observer/USAGE deleted file mode 100644 index 177ff49e4a..0000000000 --- a/railties/lib/rails/generators/rails/observer/USAGE +++ /dev/null @@ -1,12 +0,0 @@ -Description: - Stubs out a new observer. Pass the observer name, either CamelCased or - under_scored, as an argument. - - This generator only invokes your ORM and test framework generators. - -Example: - `rails generate observer Account` - - For ActiveRecord and TestUnit it creates: - Observer: app/models/account_observer.rb - TestUnit: test/models/account_observer_test.rb diff --git a/railties/lib/rails/generators/rails/observer/observer_generator.rb b/railties/lib/rails/generators/rails/observer/observer_generator.rb deleted file mode 100644 index 7a4d701ac6..0000000000 --- a/railties/lib/rails/generators/rails/observer/observer_generator.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Rails - module Generators - class ObserverGenerator < NamedBase # :nodoc: - hook_for :orm, required: true - end - end -end diff --git a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb deleted file mode 100644 index 64fe694a8b..0000000000 --- a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'rails/generators/test_unit' - -module TestUnit # :nodoc: - module Generators # :nodoc: - class ObserverGenerator < Base # :nodoc: - check_class_collision suffix: "ObserverTest" - - def create_test_files - template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_observer_test.rb") - end - end - end -end diff --git a/railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb b/railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb deleted file mode 100644 index 28aa23626a..0000000000 --- a/railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>ObserverTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end -<% end -%> diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index b9d18f4582..ae1127b509 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -582,27 +582,6 @@ module ApplicationTests assert app.config.colorize_logging end - test "config.active_record.observers" do - add_to_config <<-RUBY - config.active_record.observers = :foo_observer - RUBY - - app_file 'app/models/foo.rb', <<-RUBY - class Foo < ActiveRecord::Base - end - RUBY - - app_file 'app/models/foo_observer.rb', <<-RUBY - class FooObserver < ActiveRecord::Observer - end - RUBY - - require "#{app_path}/config/environment" - - ActiveRecord::Base - assert defined?(FooObserver) - end - test "config.session_store with :active_record_store with activerecord-session_store gem" do begin make_basic_app do |app| diff --git a/railties/test/application/console_test.rb b/railties/test/application/console_test.rb index f372afa51c..3cb3643e3a 100644 --- a/railties/test/application/console_test.rb +++ b/railties/test/application/console_test.rb @@ -95,21 +95,4 @@ class ConsoleTest < ActiveSupport::TestCase load_environment(true) assert value end - - def test_active_record_does_not_panic_when_referencing_an_observed_constant - add_to_config "config.active_record.observers = :user_observer" - - app_file "app/models/user.rb", <<-MODEL - class User < ActiveRecord::Base - end - MODEL - - app_file "app/models/user_observer.rb", <<-MODEL - class UserObserver < ActiveRecord::Observer - end - MODEL - - load_environment - assert_nothing_raised { User } - end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 076c5b3bbd..f2234ab111 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -249,28 +249,6 @@ module ApplicationTests assert !File.exists?(File.join(app_path, 'db', 'schema_cache.dump')) end - def test_load_activerecord_base_when_we_use_observers - Dir.chdir(app_path) do - `bundle exec rails g model user; - bundle exec rake db:migrate; - bundle exec rails g observer user;` - - add_to_config "config.active_record.observers = :user_observer" - - assert_equal "0", `bundle exec rails r "puts User.count"`.strip - - app_file "lib/tasks/count_user.rake", <<-RUBY - namespace :user do - task count: :environment do - puts User.count - end - end - RUBY - - assert_equal "0", `bundle exec rake user:count`.strip - end - end - def test_copy_templates Dir.chdir(app_path) do `bundle exec rake rails:templates:copy` diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index db268ed6f2..a4d8b3d1b0 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -1,7 +1,6 @@ require 'generators/generators_test_helper' require 'rails/generators/rails/controller/controller_generator' require 'rails/generators/rails/model/model_generator' -require 'rails/generators/rails/observer/observer_generator' require 'rails/generators/mailer/mailer_generator' require 'rails/generators/rails/scaffold/scaffold_generator' @@ -142,26 +141,6 @@ class NamespacedModelGeneratorTest < NamespacedGeneratorTestCase end end -class NamespacedObserverGeneratorTest < NamespacedGeneratorTestCase - arguments %w(account) - tests Rails::Generators::ObserverGenerator - - def test_invokes_default_orm - run_generator - assert_file "app/models/test_app/account_observer.rb", /module TestApp/, / class AccountObserver < ActiveRecord::Observer/ - end - - def test_invokes_default_orm_with_class_path - run_generator ["admin/account"] - assert_file "app/models/test_app/admin/account_observer.rb", /module TestApp/, / class Admin::AccountObserver < ActiveRecord::Observer/ - end - - def test_invokes_default_test_framework - run_generator - assert_file "test/models/test_app/account_observer_test.rb", /module TestApp/, / class AccountObserverTest < ActiveSupport::TestCase/ - end -end - class NamespacedMailerGeneratorTest < NamespacedGeneratorTestCase arguments %w(notifier foo bar) tests Rails::Generators::MailerGenerator diff --git a/railties/test/generators/observer_generator_test.rb b/railties/test/generators/observer_generator_test.rb deleted file mode 100644 index 1231827466..0000000000 --- a/railties/test/generators/observer_generator_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'generators/generators_test_helper' -require 'rails/generators/rails/observer/observer_generator' - -class ObserverGeneratorTest < Rails::Generators::TestCase - include GeneratorsTestHelper - arguments %w(account) - - def test_invokes_default_orm - run_generator - assert_file "app/models/account_observer.rb", /class AccountObserver < ActiveRecord::Observer/ - end - - def test_invokes_default_orm_with_class_path - run_generator ["admin/account"] - assert_file "app/models/admin/account_observer.rb", /class Admin::AccountObserver < ActiveRecord::Observer/ - end - - def test_invokes_default_test_framework - run_generator - assert_file "test/models/account_observer_test.rb", /class AccountObserverTest < ActiveSupport::TestCase/ - end - - def test_logs_if_the_test_framework_cannot_be_found - content = run_generator ["account", "--test-framework=rspec"] - assert_match(/rspec \[not found\]/, content) - end -end |