aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb24
-rw-r--r--railties/test/application/assets_test.rb1
-rw-r--r--railties/test/application/initializers/active_record_test.rb15
-rw-r--r--railties/test/application/route_inspect_test.rb4
4 files changed, 26 insertions, 18 deletions
diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
index 6c53d8bebb..1b7f5dee2a 100644
--- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -214,6 +214,18 @@ task :default => :test
public_task :apply_rails_template, :run_bundle
+ def name
+ @name ||= begin
+ # same as ActiveSupport::Inflector#underscore except not replacing '-'
+ underscored = original_name.dup
+ underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
+ underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
+ underscored.downcase!
+
+ underscored
+ end
+ end
+
protected
def app_templates_dir
@@ -254,18 +266,6 @@ task :default => :test
@original_name ||= File.basename(destination_root)
end
- def name
- @name ||= begin
- # same as ActiveSupport::Inflector#underscore except not replacing '-'
- underscored = original_name.dup
- underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
- underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
- underscored.downcase!
-
- underscored
- end
- end
-
def camelized
@camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
end
diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb
index 9e9702efb6..adec9533a9 100644
--- a/railties/test/application/assets_test.rb
+++ b/railties/test/application/assets_test.rb
@@ -2,6 +2,7 @@
require 'isolation/abstract_unit'
require 'active_support/core_ext/kernel/reporting'
require 'rack/test'
+require 'yaml'
module ApplicationTests
class AssetsTest < Test::Unit::TestCase
diff --git a/railties/test/application/initializers/active_record_test.rb b/railties/test/application/initializers/active_record_test.rb
index edf78a8a0a..b62943a278 100644
--- a/railties/test/application/initializers/active_record_test.rb
+++ b/railties/test/application/initializers/active_record_test.rb
@@ -23,10 +23,17 @@ module ApplicationTests
boot_rails
simple_controller
- get '/foo'
- assert last_response.body.include?("We're sorry, but something went wrong (500)")
+ # ActiveSupport::LogSubscriber.flush_all! in lib/rails/rack/logger.rb blew up in Ruby 2.0
+ # because it tries to open the database. This behavior doesn't happen in Ruby 1.9.3.
+ # However, regardless, the server blew up.
+ if RUBY_VERSION >= '2.0.0'
+ assert_raises (Errno::ENOENT) { get '/foo' }
+ else
+ get '/foo'
+ assert last_response.body.include?("We're sorry, but something went wrong (500)")
+ end
end
-
+
test "uses DATABASE_URL env var when config/database.yml doesn't exist" do
database_path = "/db/foo.sqlite3"
FileUtils.rm_rf("#{app_path}/config/database.yml")
@@ -35,7 +42,7 @@ module ApplicationTests
get '/foo'
assert_equal 'foo', last_response.body
-
+
# clean up
FileUtils.rm("#{app_path}/#{database_path}")
end
diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb
index 5c920cb33a..dea0ee71c9 100644
--- a/railties/test/application/route_inspect_test.rb
+++ b/railties/test/application/route_inspect_test.rb
@@ -18,7 +18,7 @@ module ApplicationTests
def test_displaying_routes_for_engines
engine = Class.new(Rails::Engine) do
- def self.to_s
+ def self.inspect
"Blog::Engine"
end
end
@@ -136,7 +136,7 @@ module ApplicationTests
def test_rake_routes_shows_route_with_rack_app_nested_with_dynamic_constraints
constraint = Class.new do
- def to_s
+ def inspect
"( my custom constraint )"
end
end