aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG.md2
-rw-r--r--railties/lib/rails/application/route_inspector.rb4
-rw-r--r--railties/lib/rails/commands/console.rb2
-rw-r--r--railties/lib/rails/commands/dbconsole.rb9
-rw-r--r--railties/lib/rails/commands/runner.rb2
-rw-r--r--railties/lib/rails/configuration.rb10
-rw-r--r--railties/lib/rails/engine/configuration.rb2
-rw-r--r--railties/lib/rails/generators/actions.rb2
-rw-r--r--railties/lib/rails/generators/active_model.rb2
-rw-r--r--railties/lib/rails/generators/named_base.rb4
-rw-r--r--railties/lib/rails/generators/rails/controller/templates/controller.rb4
-rw-r--r--railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb4
-rw-r--r--railties/lib/rails/generators/test_case.rb1
-rw-r--r--railties/test/application/generators_test.rb18
-rw-r--r--railties/test/application/route_inspect_test.rb56
-rw-r--r--railties/test/commands/dbconsole_test.rb35
-rw-r--r--railties/test/configuration/middleware_stack_proxy_test.rb59
-rw-r--r--railties/test/generators/actions_test.rb8
-rw-r--r--railties/test/generators/namespaced_generators_test.rb19
-rw-r--r--railties/test/generators/plugin_new_generator_test.rb4
-rw-r--r--railties/test/railties/engine_test.rb4
22 files changed, 186 insertions, 67 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 1f88843ee9..ccccc178c5 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Improved `rake routes` output for redirects *Łukasz Strzałkowski & Andrew White*
+
* Load all environments available in `config.paths["config/environments"]`. *Piotr Sarnacki*
* The application generator generates `public/humans.txt` with some basic data. *Paul Campbell*
diff --git a/railties/lib/rails/application/route_inspector.rb b/railties/lib/rails/application/route_inspector.rb
index 1e5ce67a58..b23fb3e920 100644
--- a/railties/lib/rails/application/route_inspector.rb
+++ b/railties/lib/rails/application/route_inspector.rb
@@ -16,7 +16,7 @@ module Rails
class_name = app.class.name.to_s
if class_name == "ActionDispatch::Routing::Mapper::Constraints"
rack_app(app.app)
- elsif class_name !~ /^ActionDispatch::Routing/
+ elsif ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/
app
end
end
@@ -67,7 +67,7 @@ module Rails
@engines = Hash.new
end
- def format all_routes, filter = nil
+ def format(all_routes, filter = nil)
if filter
all_routes = all_routes.select{ |route| route.defaults[:controller] == filter }
end
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb
index cd6a03fe51..b95df3e545 100644
--- a/railties/lib/rails/commands/console.rb
+++ b/railties/lib/rails/commands/console.rb
@@ -22,7 +22,7 @@ module Rails
options = {}
OptionParser.new do |opt|
- opt.banner = "Usage: console [environment] [options]"
+ opt.banner = "Usage: rails console [environment] [options]"
opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
opt.on("-e", "--environment=name", String,
"Specifies the environment to run this console under (test/development/production).",
diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb
index aaba47117f..cc7caffc3d 100644
--- a/railties/lib/rails/commands/dbconsole.rb
+++ b/railties/lib/rails/commands/dbconsole.rb
@@ -42,7 +42,7 @@ module Rails
include_password = false
options = {}
OptionParser.new do |opt|
- opt.banner = "Usage: dbconsole [environment] [options]"
+ opt.banner = "Usage: rails dbconsole [environment] [options]"
opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
include_password = true
end
@@ -56,6 +56,11 @@ module Rails
options['header'] = h
end
+ opt.on("-h", "--help", "Show this help message.") do
+ puts opt
+ exit
+ end
+
opt.parse!(arguments)
abort opt.to_s unless (0..1).include?(arguments.size)
end
@@ -96,7 +101,7 @@ module Rails
args << "-#{options['mode']}" if options['mode']
args << "-header" if options['header']
- args << config['database']
+ args << File.expand_path(config['database'], Rails.root)
find_cmd_and_exec('sqlite3', *args)
diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb
index 2802981e7a..77f1b15fb4 100644
--- a/railties/lib/rails/commands/runner.rb
+++ b/railties/lib/rails/commands/runner.rb
@@ -9,7 +9,7 @@ if ARGV.first.nil?
end
ARGV.clone.options do |opts|
- opts.banner = "Usage: runner [options] ('Some.ruby(code)' or a filename)"
+ opts.banner = "Usage: rails runner [options] ('Some.ruby(code)' or a filename)"
opts.separator ""
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index 3d66019e5e..5fa7f043c6 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -39,25 +39,25 @@ module Rails
end
def insert_before(*args, &block)
- @operations << [:insert_before, args, block]
+ @operations << [__method__, args, block]
end
alias :insert :insert_before
def insert_after(*args, &block)
- @operations << [:insert_after, args, block]
+ @operations << [__method__, args, block]
end
def swap(*args, &block)
- @operations << [:swap, args, block]
+ @operations << [__method__, args, block]
end
def use(*args, &block)
- @operations << [:use, args, block]
+ @operations << [__method__, args, block]
end
def delete(*args, &block)
- @operations << [:delete, args, block]
+ @operations << [__method__, args, block]
end
def merge_into(other) #:nodoc:
diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb
index d3b42021fc..e31df807a6 100644
--- a/railties/lib/rails/engine/configuration.rb
+++ b/railties/lib/rails/engine/configuration.rb
@@ -20,7 +20,7 @@ module Rails
# Holds generators configuration:
#
# config.generators do |g|
- # g.orm :datamapper, :migration => true
+ # g.orm :data_mapper, :migration => true
# g.template_engine :haml
# g.test_framework :rspec
# end
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index 6cd2ea2bbd..92f40b9e31 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -27,7 +27,7 @@ module Rails
log :gemfile, message
options.each do |option, value|
- parts << ":#{option} => #{value.inspect}"
+ parts << "#{option}: #{value.inspect}"
end
in_root do
diff --git a/railties/lib/rails/generators/active_model.rb b/railties/lib/rails/generators/active_model.rb
index 454327f765..0e51b9c568 100644
--- a/railties/lib/rails/generators/active_model.rb
+++ b/railties/lib/rails/generators/active_model.rb
@@ -11,7 +11,7 @@ module Rails
# ActiveRecord::Generators::ActiveModel.find(Foo, "params[:id]")
# # => "Foo.find(params[:id])"
#
- # Datamapper::Generators::ActiveModel.find(Foo, "params[:id]")
+ # DataMapper::Generators::ActiveModel.find(Foo, "params[:id]")
# # => "Foo.get(params[:id])"
#
# On initialization, the ActiveModel accepts the instance name that will
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index e85d1b8fa2..63703176de 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -79,6 +79,10 @@ module Rails
@class_path
end
+ def namespaced_file_path
+ @namespaced_file_path ||= namespaced_class_path.join("/")
+ end
+
def namespaced_class_path
@namespaced_class_path ||= begin
namespace_path = namespace.name.split("::").map {|m| m.underscore }
diff --git a/railties/lib/rails/generators/rails/controller/templates/controller.rb b/railties/lib/rails/generators/rails/controller/templates/controller.rb
index 52243f4a2f..ece6bbba3b 100644
--- a/railties/lib/rails/generators/rails/controller/templates/controller.rb
+++ b/railties/lib/rails/generators/rails/controller/templates/controller.rb
@@ -1,3 +1,7 @@
+<% if namespaced? -%>
+require_dependency "<%= namespaced_file_path %>/application_controller"
+<% end -%>
+
<% module_namespacing do -%>
class <%= class_name %>Controller < ApplicationController
<% actions.each do |action| -%>
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 722e37e20b..7088367462 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
@@ -139,7 +139,7 @@ task :default => :test
gemfile_in_app_path = File.join(rails_app_path, "Gemfile")
if File.exist? gemfile_in_app_path
- entry = "gem '#{name}', :path => '#{relative_path}'"
+ entry = "gem '#{name}', path: '#{relative_path}'"
append_file gemfile_in_app_path, entry
end
end
diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
index b95aea5f19..0294bde582 100644
--- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
+++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
@@ -1,3 +1,7 @@
+<% if namespaced? -%>
+require_dependency "<%= namespaced_file_path %>/application_controller"
+<% end -%>
+
<% module_namespacing do -%>
class <%= controller_class_name %>Controller < ApplicationController
# GET <%= route_url %>
diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb
index 508e221c60..ff9cf0087e 100644
--- a/railties/lib/rails/generators/test_case.rb
+++ b/railties/lib/rails/generators/test_case.rb
@@ -31,7 +31,6 @@ module Rails
include FileUtils
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
- delegate :destination_root, :current_path, :generator_class, :default_arguments, :to => :'self.class'
# Generators frequently change the current path using +FileUtils.cd+.
# So we need to store the path at file load and revert back to it after each test.
diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb
index bf58bb3f74..b80244f1d2 100644
--- a/railties/test/application/generators_test.rb
+++ b/railties/test/application/generators_test.rb
@@ -45,10 +45,10 @@ module ApplicationTests
test "generators set rails options" do
with_bare_config do |c|
- c.generators.orm = :datamapper
+ c.generators.orm = :data_mapper
c.generators.test_framework = :rspec
c.generators.helper = false
- expected = { :rails => { :orm => :datamapper, :test_framework => :rspec, :helper => false } }
+ expected = { :rails => { :orm => :data_mapper, :test_framework => :rspec, :helper => false } }
assert_equal(expected, c.generators.options)
end
end
@@ -64,7 +64,7 @@ module ApplicationTests
test "generators aliases, options, templates and fallbacks on initialization" do
add_to_config <<-RUBY
config.generators.rails :aliases => { :test_framework => "-w" }
- config.generators.orm :datamapper
+ config.generators.orm :data_mapper
config.generators.test_framework :rspec
config.generators.fallbacks[:shoulda] = :test_unit
config.generators.templates << "some/where"
@@ -95,15 +95,15 @@ module ApplicationTests
test "generators with hashes for options and aliases" do
with_bare_config do |c|
c.generators do |g|
- g.orm :datamapper, :migration => false
+ g.orm :data_mapper, :migration => false
g.plugin :aliases => { :generator => "-g" },
:generator => true
end
expected = {
- :rails => { :orm => :datamapper },
+ :rails => { :orm => :data_mapper },
:plugin => { :generator => true },
- :datamapper => { :migration => false }
+ :data_mapper => { :migration => false }
}
assert_equal expected, c.generators.options
@@ -114,12 +114,12 @@ module ApplicationTests
test "generators with string and hash for options should generate symbol keys" do
with_bare_config do |c|
c.generators do |g|
- g.orm 'datamapper', :migration => false
+ g.orm 'data_mapper', :migration => false
end
expected = {
- :rails => { :orm => :datamapper },
- :datamapper => { :migration => false }
+ :rails => { :orm => :data_mapper },
+ :data_mapper => { :migration => false }
}
assert_equal expected, c.generators.options
diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb
index 453ba8196c..3b8c874b5b 100644
--- a/railties/test/application/route_inspect_test.rb
+++ b/railties/test/application/route_inspect_test.rb
@@ -16,6 +16,11 @@ module ApplicationTests
Rails.stubs(:env).returns("development")
end
+ def draw(&block)
+ @set.draw(&block)
+ @inspector.format(@set.routes)
+ end
+
def test_displaying_routes_for_engines
engine = Class.new(Rails::Engine) do
def self.to_s
@@ -26,12 +31,11 @@ module ApplicationTests
get '/cart', :to => 'cart#show'
end
- @set.draw do
+ output = draw do
get '/custom/assets', :to => 'custom_assets#show'
mount engine => "/blog", :as => "blog"
end
- output = @inspector.format @set.routes
expected = [
"custom_assets GET /custom/assets(.:format) custom_assets#show",
" blog /blog Blog::Engine",
@@ -42,26 +46,23 @@ module ApplicationTests
end
def test_cart_inspect
- @set.draw do
+ output = draw do
get '/cart', :to => 'cart#show'
end
- output = @inspector.format @set.routes
assert_equal ["cart GET /cart(.:format) cart#show"], output
end
def test_inspect_shows_custom_assets
- @set.draw do
+ output = draw do
get '/custom/assets', :to => 'custom_assets#show'
end
- output = @inspector.format @set.routes
assert_equal ["custom_assets GET /custom/assets(.:format) custom_assets#show"], output
end
def test_inspect_routes_shows_resources_route
- @set.draw do
+ output = draw do
resources :articles
end
- output = @inspector.format @set.routes
expected = [
" articles GET /articles(.:format) articles#index",
" POST /articles(.:format) articles#create",
@@ -75,50 +76,44 @@ module ApplicationTests
end
def test_inspect_routes_shows_root_route
- @set.draw do
+ output = draw do
root :to => 'pages#main'
end
- output = @inspector.format @set.routes
assert_equal ["root GET / pages#main"], output
end
def test_inspect_routes_shows_dynamic_action_route
- @set.draw do
+ output = draw do
get 'api/:action' => 'api'
end
- output = @inspector.format @set.routes
assert_equal [" GET /api/:action(.:format) api#:action"], output
end
def test_inspect_routes_shows_controller_and_action_only_route
- @set.draw do
+ output = draw do
get ':controller/:action'
end
- output = @inspector.format @set.routes
assert_equal [" GET /:controller/:action(.:format) :controller#:action"], output
end
def test_inspect_routes_shows_controller_and_action_route_with_constraints
- @set.draw do
+ output = draw do
get ':controller(/:action(/:id))', :id => /\d+/
end
- output = @inspector.format @set.routes
assert_equal [" GET /:controller(/:action(/:id))(.:format) :controller#:action {:id=>/\\d+/}"], output
end
def test_rake_routes_shows_route_with_defaults
- @set.draw do
+ output = draw do
get 'photos/:id' => 'photos#show', :defaults => {:format => 'jpg'}
end
- output = @inspector.format @set.routes
assert_equal [%Q[ GET /photos/:id(.:format) photos#show {:format=>"jpg"}]], output
end
def test_rake_routes_shows_route_with_constraints
- @set.draw do
+ output = draw do
get 'photos/:id' => 'photos#show', :id => /[A-Z]\d{5}/
end
- output = @inspector.format @set.routes
assert_equal [" GET /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}"], output
end
@@ -128,10 +123,9 @@ module ApplicationTests
end
def test_rake_routes_shows_route_with_rack_app
- @set.draw do
+ output = draw do
get 'foo/:id' => RackApp, :id => /[A-Z]\d{5}/
end
- output = @inspector.format @set.routes
assert_equal [" GET /foo/:id(.:format) #{RackApp.name} {:id=>/[A-Z]\\d{5}/}"], output
end
@@ -142,23 +136,33 @@ module ApplicationTests
end
end
- @set.draw do
+ output = draw do
scope :constraint => constraint.new do
mount RackApp => '/foo'
end
end
- output = @inspector.format @set.routes
assert_equal [" /foo #{RackApp.name} {:constraint=>( my custom constraint )}"], output
end
def test_rake_routes_dont_show_app_mounted_in_assets_prefix
- @set.draw do
+ output = draw do
get '/sprockets' => RackApp
end
- output = @inspector.format @set.routes
assert_no_match(/RackApp/, output.first)
assert_no_match(/\/sprockets/, output.first)
end
+
+ def test_redirect
+ output = draw do
+ get "/foo" => redirect("/foo/bar"), :constraints => { :subdomain => "admin" }
+ get "/bar" => redirect(path: "/foo/bar", status: 307)
+ get "/foobar" => redirect{ "/foo/bar" }
+ end
+
+ assert_equal " foo GET /foo(.:format) redirect(301, /foo/bar) {:subdomain=>\"admin\"}", output[0]
+ assert_equal " bar GET /bar(.:format) redirect(307, path: /foo/bar)", output[1]
+ assert_equal "foobar GET /foobar(.:format) redirect(301)", output[2]
+ end
end
end
diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb
index 85a7edfacd..6d0f5ca073 100644
--- a/railties/test/commands/dbconsole_test.rb
+++ b/railties/test/commands/dbconsole_test.rb
@@ -92,20 +92,25 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
end
def test_sqlite3
- dbconsole.expects(:find_cmd_and_exec).with('sqlite3', 'db')
- start(adapter: 'sqlite3', database: 'db')
+ dbconsole.expects(:find_cmd_and_exec).with('sqlite3', Rails.root.join('db.sqlite3').to_s)
+ start(adapter: 'sqlite3', database: 'db.sqlite3')
assert !aborted
end
def test_sqlite3_mode
- dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-html', 'db')
- start({adapter: 'sqlite3', database: 'db'}, ['--mode', 'html'])
+ dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-html', Rails.root.join('db.sqlite3').to_s)
+ start({adapter: 'sqlite3', database: 'db.sqlite3'}, ['--mode', 'html'])
assert !aborted
end
def test_sqlite3_header
- dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-header', 'db')
- start({adapter: 'sqlite3', database: 'db'}, ['--header'])
+ dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-header', Rails.root.join('db.sqlite3').to_s)
+ start({adapter: 'sqlite3', database: 'db.sqlite3'}, ['--header'])
+ end
+
+ def test_sqlite3_db_absolute_path
+ dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '/tmp/db.sqlite3')
+ start(adapter: 'sqlite3', database: '/tmp/db.sqlite3')
assert !aborted
end
@@ -127,6 +132,24 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase
assert_match /Unknown command-line client for db/, output
end
+ def test_print_help_short
+ stdout = capture(:stdout) do
+ start({}, ['-h'])
+ end
+ assert aborted
+ assert_equal '', output
+ assert_match /Usage:.*dbconsole/, stdout
+ end
+
+ def test_print_help_long
+ stdout = capture(:stdout) do
+ start({}, ['--help'])
+ end
+ assert aborted
+ assert_equal '', output
+ assert_match /Usage:.*dbconsole/, stdout
+ end
+
private
attr_reader :aborted, :output
diff --git a/railties/test/configuration/middleware_stack_proxy_test.rb b/railties/test/configuration/middleware_stack_proxy_test.rb
new file mode 100644
index 0000000000..5984c0b425
--- /dev/null
+++ b/railties/test/configuration/middleware_stack_proxy_test.rb
@@ -0,0 +1,59 @@
+require 'minitest/autorun'
+require 'rails/configuration'
+require 'active_support/test_case'
+
+module Rails
+ module Configuration
+ class MiddlewareStackProxyTest < ActiveSupport::TestCase
+ def setup
+ @stack = MiddlewareStackProxy.new
+ end
+
+ def test_playback_insert_before
+ @stack.insert_before :foo
+ assert_playback :insert_before, :foo
+ end
+
+ def test_playback_insert_after
+ @stack.insert_after :foo
+ assert_playback :insert_after, :foo
+ end
+
+ def test_playback_swap
+ @stack.swap :foo
+ assert_playback :swap, :foo
+ end
+
+ def test_playback_use
+ @stack.use :foo
+ assert_playback :use, :foo
+ end
+
+ def test_playback_delete
+ @stack.delete :foo
+ assert_playback :delete, :foo
+ end
+
+ def test_order
+ @stack.swap :foo
+ @stack.delete :foo
+
+ mock = MiniTest::Mock.new
+ mock.expect :send, nil, [:swap, :foo]
+ mock.expect :send, nil, [:delete, :foo]
+
+ @stack.merge_into mock
+ mock.verify
+ end
+
+ private
+
+ def assert_playback(msg_name, args)
+ mock = MiniTest::Mock.new
+ mock.expect :send, nil, [msg_name, args]
+ @stack.merge_into(mock)
+ mock.verify
+ end
+ end
+ end
+end
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index a8c8fcd5b7..bc086c5986 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -67,6 +67,14 @@ class ActionsTest < Rails::Generators::TestCase
assert_file 'Gemfile', /^gem "rspec-rails"$/
end
+ def test_gem_should_include_options
+ run_generator
+
+ action :gem, 'rspec', github: 'dchelimsky/rspec', tag: '1.2.9.rc1'
+
+ assert_file 'Gemfile', /gem "rspec", github: "dchelimsky\/rspec", tag: "1\.2\.9\.rc1"/
+ end
+
def test_gem_group_should_wrap_gems_in_a_group
run_generator
diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb
index 6f00fc5d26..09169ef2d2 100644
--- a/railties/test/generators/namespaced_generators_test.rb
+++ b/railties/test/generators/namespaced_generators_test.rb
@@ -20,8 +20,14 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase
def test_namespaced_controller_skeleton_is_created
run_generator
- assert_file "app/controllers/test_app/account_controller.rb", /module TestApp/, / class AccountController < ApplicationController/
- assert_file "test/functional/test_app/account_controller_test.rb", /module TestApp/, / class AccountControllerTest/
+ assert_file "app/controllers/test_app/account_controller.rb",
+ /require_dependency "test_app\/application_controller"/,
+ /module TestApp/,
+ / class AccountController < ApplicationController/
+
+ assert_file "test/functional/test_app/account_controller_test.rb",
+ /module TestApp/,
+ / class AccountControllerTest/
end
def test_skipping_namespace
@@ -66,7 +72,7 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase
run_generator
assert_file "app/controllers/test_app/account_controller.rb" do |content|
content.split("\n").each do |line|
- assert_no_match line, /^\s+$/, "Don't indent blank lines"
+ assert_no_match(/^\s+$/, line, "Don't indent blank lines")
end
end
end
@@ -227,9 +233,10 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
end
# Controller
- assert_file "app/controllers/test_app/product_lines_controller.rb" do |content|
- assert_match(/module TestApp\n class ProductLinesController < ApplicationController/, content)
- end
+ assert_file "app/controllers/test_app/product_lines_controller.rb",
+ /require_dependency "test_app\/application_controller"/,
+ /module TestApp/,
+ /class ProductLinesController < ApplicationController/
assert_file "test/functional/test_app/product_lines_controller_test.rb",
/module TestApp\n class ProductLinesControllerTest < ActionController::TestCase/
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index 51374e5f3f..58740978aa 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -279,7 +279,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
run_generator [destination_root]
- assert_file gemfile_path, /gem 'bukkits', :path => 'tmp\/bukkits'/
+ assert_file gemfile_path, /gem 'bukkits', path: 'tmp\/bukkits'/
ensure
Object.send(:remove_const, 'APP_PATH')
FileUtils.rm gemfile_path
@@ -294,7 +294,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
run_generator [destination_root, "--skip-gemfile-entry"]
assert_file gemfile_path do |contents|
- assert_no_match(/gem 'bukkits', :path => 'tmp\/bukkits'/, contents)
+ assert_no_match(/gem 'bukkits', path: 'tmp\/bukkits'/, contents)
end
ensure
Object.send(:remove_const, 'APP_PATH')
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 55f72f532f..7a047ef93a 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -882,7 +882,7 @@ YAML
module Bukkits
class Engine < ::Rails::Engine
config.generators do |g|
- g.orm :datamapper
+ g.orm :data_mapper
g.template_engine :haml
g.test_framework :rspec
end
@@ -910,7 +910,7 @@ YAML
assert_equal :test_unit, app_generators[:test_framework]
generators = Bukkits::Engine.config.generators.options[:rails]
- assert_equal :datamapper, generators[:orm]
+ assert_equal :data_mapper, generators[:orm]
assert_equal :haml , generators[:template_engine]
assert_equal :rspec , generators[:test_framework]
end