aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Schneeman <richard.schneeman@gmail.com>2016-07-05 10:15:00 -0500
committerGitHub <noreply@github.com>2016-07-05 10:15:00 -0500
commit67d5783f96e4adf4b9dd2d8bd60987e3b7020b13 (patch)
tree91ac4776c09b0cc3cf4be206505a838311376cb4
parent2b554318469a44e2066f1429142d9b6ad3424218 (diff)
parent9442239b45142dfaae48a9dc2812efbf2575a7f4 (diff)
downloadrails-67d5783f96e4adf4b9dd2d8bd60987e3b7020b13.tar.gz
rails-67d5783f96e4adf4b9dd2d8bd60987e3b7020b13.tar.bz2
rails-67d5783f96e4adf4b9dd2d8bd60987e3b7020b13.zip
Merge pull request #25257 from ta1kt0me/inspect_initializers
Display railtie class name in `rails initializers`
-rw-r--r--railties/lib/rails/initializable.rb4
-rw-r--r--railties/lib/rails/tasks/initializers.rake2
-rw-r--r--railties/test/initializable_test.rb5
3 files changed, 10 insertions, 1 deletions
diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb
index 1a0b6d1e1a..292379e3f3 100644
--- a/railties/lib/rails/initializable.rb
+++ b/railties/lib/rails/initializable.rb
@@ -34,6 +34,10 @@ module Rails
return self if @context
Initializer.new(@name, context, @options, &block)
end
+
+ def context_class
+ @context.class
+ end
end
class Collection < Array
diff --git a/railties/lib/rails/tasks/initializers.rake b/railties/lib/rails/tasks/initializers.rake
index 2968b5cb53..6522f2ae5a 100644
--- a/railties/lib/rails/tasks/initializers.rake
+++ b/railties/lib/rails/tasks/initializers.rake
@@ -1,6 +1,6 @@
desc "Print out all defined initializers in the order they are invoked by Rails."
task initializers: :environment do
Rails.application.initializers.tsort_each do |initializer|
- puts initializer.name
+ puts "#{initializer.context_class}.#{initializer.name}"
end
end
diff --git a/railties/test/initializable_test.rb b/railties/test/initializable_test.rb
index ed9573453b..d4eafebfa4 100644
--- a/railties/test/initializable_test.rb
+++ b/railties/test/initializable_test.rb
@@ -174,6 +174,11 @@ module InitializableTests
end
end
end
+
+ test "Initializer provides context's class name" do
+ foo = Foo.new
+ assert_equal foo.class, foo.initializers.first.context_class
+ end
end
class BeforeAfter < ActiveSupport::TestCase