aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb37
-rw-r--r--actionpack/lib/action_controller/base.rb23
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb36
-rw-r--r--actionpack/lib/action_view/base.rb14
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb8
-rw-r--r--actionpack/lib/action_view/helpers/cache_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb12
-rw-r--r--actionpack/test/abstract/render_test.rb35
-rwxr-xr-xactiverecord/lib/active_record/base.rb5
-rw-r--r--activerecord/lib/active_record/relation.rb4
-rw-r--r--activerecord/test/cases/method_scoping_test.rb8
-rw-r--r--activerecord/test/cases/named_scope_test.rb9
-rw-r--r--activerecord/test/cases/relations_test.rb5
-rw-r--r--activerecord/test/models/post.rb5
-rw-r--r--railties/lib/generators/rails/app/templates/config.ru2
-rw-r--r--railties/lib/generators/rails/app/templates/config/databases/ibm_db.yml2
-rw-r--r--railties/lib/generators/rails/app/templates/config/environments/development.rb.tt2
-rw-r--r--railties/lib/generators/rails/app/templates/config/environments/production.rb.tt2
-rw-r--r--railties/lib/generators/rails/app/templates/config/environments/test.rb.tt2
-rw-r--r--railties/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb2
-rw-r--r--railties/lib/generators/rails/app/templates/config/locales/en.yml2
-rw-r--r--railties/lib/generators/rails/app/templates/db/seeds.rb2
-rwxr-xr-xrailties/lib/generators/rails/app/templates/script/console.tt2
-rwxr-xr-xrailties/lib/generators/rails/app/templates/script/dbconsole.tt2
-rw-r--r--railties/lib/generators/rails/metal/templates/metal.rb4
-rw-r--r--railties/lib/generators/rails/plugin/templates/Rakefile.tt12
-rw-r--r--railties/lib/generators/rails/stylesheets/templates/scaffold.css1
-rw-r--r--railties/lib/rails/application.rb8
-rw-r--r--railties/test/application/middleware_test.rb2
-rw-r--r--railties/test/application/routing_test.rb28
-rw-r--r--railties/test/generators/plugin_generator_test.rb2
31 files changed, 177 insertions, 103 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index 826e82c8c6..a168b1b4c5 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -98,18 +98,9 @@ module AbstractController
_view_paths
end
- # Normalize options, by converting render "foo" to render :template => "foo"
- # and render "/foo" to render :file => "/foo".
- def _normalize_options(action=nil, options={})
- case action
- when Hash
- options, action = action, nil
- when String
- key = (action.index("/") == 0 ? :file : :template)
- options.merge!(key => action)
- end
-
- options
+ # The prefix used in render "foo" shortcuts.
+ def _prefix
+ controller_path
end
# Return a string representation of a Rack-compatible response body.
@@ -126,6 +117,28 @@ module AbstractController
private
+ # Normalize options, by converting render "foo" to render :template => "prefix/foo"
+ # and render "/foo" to render :file => "/foo".
+ def _normalize_options(action=nil, options={})
+ case action
+ when Hash
+ options, action = action, nil
+ when String, Symbol
+ action = action.to_s
+ case action.index("/")
+ when NilClass
+ options[:_prefix] = _prefix
+ options[:_template_name] = action
+ when 0
+ options[:file] = action
+ else
+ options[:template] = action
+ end
+ end
+
+ options
+ end
+
# Take in a set of options and determine the template to render
#
# ==== Options
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index a66aafd80e..f46231d72b 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -81,28 +81,5 @@ module ActionController
filter << block if block
filter
end
-
- def _normalize_options(action=nil, options={}, &blk)
- case action
- when NilClass
- when Hash, String
- options = super
- when Symbol
- options.merge! :action => action
- else
- options.merge! :partial => action
- end
-
- if options.key?(:action) && options[:action].to_s.index("/")
- options[:template] = options.delete(:action)
- end
-
- if options[:status]
- options[:status] = Rack::Utils.status_code(options[:status])
- end
-
- options[:update] = blk if block_given?
- options
- end
end
end
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index 475ed54167..72e2bbd00e 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -25,18 +25,6 @@ module ActionController
end
private
- def _prefix
- controller_path
- end
-
- def _determine_template(options)
- if (options.keys & [:partial, :file, :template, :text, :inline]).empty?
- options[:_template_name] ||= options[:action]
- options[:_prefix] = _prefix
- end
-
- super
- end
def _render_partial(options)
options[:partial] = action_name if options[:partial] == true
@@ -54,5 +42,29 @@ module ActionController
self.content_type = content_type if content_type
self.headers["Location"] = url_for(location) if location
end
+
+ def _normalize_options(action=nil, options={}, &blk)
+ case action
+ when NilClass
+ when Hash
+ options = super(action.delete(:action), action)
+ when String, Symbol
+ options = super
+ else
+ options.merge! :partial => action
+ end
+
+ if (options.keys & [:partial, :file, :template, :text, :inline]).empty?
+ options[:_template_name] ||= options[:action]
+ options[:_prefix] = _prefix
+ end
+
+ if options[:status]
+ options[:status] = Rack::Utils.status_code(options[:status])
+ end
+
+ options[:update] = blk if block_given?
+ options
+ end
end
end
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 4970c768e8..c4b0455c2a 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -181,7 +181,6 @@ module ActionView #:nodoc:
extend ActiveSupport::Memoizable
attr_accessor :base_path, :assigns, :template_extension, :formats
- attr_accessor :controller
attr_internal :captures
def reset_formats(formats)
@@ -277,13 +276,13 @@ module ActionView #:nodoc:
@config = nil
@formats = formats
@assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) }
- @controller = controller
+ @_controller = controller
@helpers = self.class.helpers || Module.new
@_content_for = Hash.new {|h,k| h[k] = ActionView::SafeBuffer.new }
self.view_paths = view_paths
end
- attr_internal :template
+ attr_internal :controller, :template
attr_reader :view_paths
def view_paths=(paths)
@@ -298,12 +297,11 @@ module ActionView #:nodoc:
# Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc:
- if @controller
- variables = @controller.instance_variable_names
- variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables)
- variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) }
+ if controller
+ variables = controller.instance_variable_names
+ variables -= controller.protected_instance_variables if controller.respond_to?(:protected_instance_variables)
+ variables.each { |name| instance_variable_set(name, controller.instance_variable_get(name)) }
end
end
-
end
end
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 15b70ecff5..83357dd76f 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -634,8 +634,8 @@ module ActionView
# Prefix with <tt>/dir/</tt> if lacking a leading +/+. Account for relative URL
# roots. Rewrite the asset path for cache-busting asset ids. Include
# asset host, if configured, with the correct request protocol.
- def compute_public_path(source, dir, ext = nil, include_host = true)
- has_request = @controller.respond_to?(:request)
+ def compute_public_path(source, dir, ext = nil, include_host = true)
+ has_request = controller.respond_to?(:request)
source_ext = File.extname(source)[1..-1]
if ext && !is_uri?(source) && (source_ext.blank? || (ext != source_ext && File.exist?(File.join(config.assets_dir, dir, "#{source}.#{ext}"))))
@@ -658,7 +658,7 @@ module ActionView
host = compute_asset_host(source)
if has_request && !host.blank? && !is_uri?(host)
- host = "#{@controller.request.protocol}#{host}"
+ host = "#{controller.request.protocol}#{host}"
end
"#{host}#{source}"
@@ -681,7 +681,7 @@ module ActionView
if host.is_a?(Proc) || host.respond_to?(:call)
case host.is_a?(Proc) ? host.arity : host.method(:call).arity
when 2
- request = @controller.respond_to?(:request) && @controller.request
+ request = controller.respond_to?(:request) && controller.request
host.call(source, request)
else
host.call(source)
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb
index 64d1ad2715..d5cc14b29a 100644
--- a/actionpack/lib/action_view/helpers/cache_helper.rb
+++ b/actionpack/lib/action_view/helpers/cache_helper.rb
@@ -32,7 +32,7 @@ module ActionView
# <i>Topics listed alphabetically</i>
# <% end %>
def cache(name = {}, options = nil, &block)
- @controller.fragment_for(output_buffer, name, options, &block)
+ controller.fragment_for(output_buffer, name, options, &block)
end
end
end
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 14628c5404..511386fede 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -13,7 +13,7 @@ module ActionView
# Need to map default url options to controller one.
def default_url_options(*args) #:nodoc:
- @controller.send(:default_url_options, *args)
+ controller.send(:default_url_options, *args)
end
# Returns the URL for the set of +options+ provided. This takes the
@@ -89,10 +89,10 @@ module ActionView
when Hash
options = { :only_path => options[:host].nil? }.update(options.symbolize_keys)
escape = options.key?(:escape) ? options.delete(:escape) : false
- @controller.send(:url_for, options)
+ controller.send(:url_for, options)
when :back
escape = false
- @controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
+ controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
else
escape = false
polymorphic_path(options)
@@ -546,10 +546,10 @@ module ActionView
# # => false
def current_page?(options)
url_string = CGI.unescapeHTML(url_for(options))
- request = @controller.request
- # We ignore any extra parameters in the request_uri if the
+ request = controller.request
+ # We ignore any extra parameters in the request_uri if the
# submitted url doesn't have any either. This lets the function
- # work with things like ?order=asc
+ # work with things like ?order=asc
if url_string.index("?")
request_uri = request.request_uri
else
diff --git a/actionpack/test/abstract/render_test.rb b/actionpack/test/abstract/render_test.rb
index 4bec44c9ae..ffd430fa86 100644
--- a/actionpack/test/abstract/render_test.rb
+++ b/actionpack/test/abstract/render_test.rb
@@ -6,9 +6,16 @@ module AbstractController
class ControllerRenderer < AbstractController::Base
include AbstractController::Rendering
+ def _prefix
+ "renderer"
+ end
+
self.view_paths = [ActionView::FixtureResolver.new(
"default.erb" => "With Default",
"template.erb" => "With Template",
+ "renderer/string.erb" => "With String",
+ "renderer/symbol.erb" => "With Symbol",
+ "string/with_path.erb" => "With String With Path",
"some/file.erb" => "With File",
"template_name.erb" => "With Template Name"
)]
@@ -33,8 +40,16 @@ module AbstractController
render
end
- def shortcut
- render "template"
+ def string
+ render "string"
+ end
+
+ def string_with_path
+ render "string/with_path"
+ end
+
+ def symbol
+ render :symbol
end
def template_name
@@ -77,9 +92,19 @@ module AbstractController
assert_equal "With Default", @controller.response_body
end
- def test_render_template_through_shortcut
- @controller.process(:shortcut)
- assert_equal "With Template", @controller.response_body
+ def test_render_string
+ @controller.process(:string)
+ assert_equal "With String", @controller.response_body
+ end
+
+ def test_render_symbol
+ @controller.process(:symbol)
+ assert_equal "With Symbol", @controller.response_body
+ end
+
+ def test_render_string_with_path
+ @controller.process(:string_with_path)
+ assert_equal "With String With Path", @controller.response_body
end
def test_render_template_name
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index f1b2b3b979..12feef4849 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1236,7 +1236,7 @@ module ActiveRecord #:nodoc:
end
def construct_finder_arel(options = {}, scope = nil)
- relation = unscoped.apply_finder_options(options)
+ relation = options.is_a?(Hash) ? unscoped.apply_finder_options(options) : unscoped.merge(options)
relation = scope.merge(relation) if scope
relation
end
@@ -1450,7 +1450,8 @@ module ActiveRecord #:nodoc:
end
def scoped_methods #:nodoc:
- Thread.current[:"#{self}_scoped_methods"] ||= self.default_scoping.dup
+ key = :"#{self}_scoped_methods"
+ Thread.current[key] = Thread.current[key].presence || self.default_scoping.dup
end
def current_scoped_methods #:nodoc:
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 04b85119cb..1a96cdad17 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -32,7 +32,7 @@ module ActiveRecord
end
def respond_to?(method, include_private = false)
- return true if arel.respond_to?(method, include_private) || Array.method_defined?(method)
+ return true if arel.respond_to?(method, include_private) || Array.method_defined?(method) || @klass.respond_to?(method, include_private)
if match = DynamicFinderMatch.match(method)
return true if @klass.send(:all_attributes_exists?, match.attribute_names)
@@ -301,6 +301,8 @@ module ActiveRecord
def method_missing(method, *args, &block)
if Array.method_defined?(method)
to_a.send(method, *args, &block)
+ elsif @klass.respond_to?(method)
+ @klass.send(:with_scope, self) { @klass.send(method, *args, &block) }
elsif arel.respond_to?(method)
arel.send(method, *args, &block)
elsif match = DynamicFinderMatch.match(method)
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index fbd1adf088..1081aa40a9 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -588,7 +588,7 @@ class HasAndBelongsToManyScopingTest< ActiveRecord::TestCase
end
class DefaultScopingTest < ActiveRecord::TestCase
- fixtures :developers
+ fixtures :developers, :posts
def test_default_scope
expected = Developer.find(:all, :order => 'salary DESC').collect { |dev| dev.salary }
@@ -657,6 +657,12 @@ class DefaultScopingTest < ActiveRecord::TestCase
received = DeveloperOrderedBySalary.find(:all, :order => 'salary').collect { |dev| dev.salary }
assert_equal expected, received
end
+
+ def test_default_scope_using_relation
+ posts = PostWithComment.scoped
+ assert_equal 2, posts.count
+ assert_equal posts(:thinking), posts.first
+ end
end
=begin
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index 2c34ab787d..894d96346e 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -380,6 +380,15 @@ class NamedScopeTest < ActiveRecord::TestCase
assert_deprecated('named_scope has been deprecated') { Topic.named_scope :deprecated_named_scope }
end
+ def test_named_scopes_on_relations
+ # Topic.replied
+ approved_topics = Topic.scoped.approved.order('id DESC')
+ assert_equal topics(:fourth), approved_topics.first
+
+ replied_approved_topics = approved_topics.replied
+ assert_equal topics(:third), replied_approved_topics.first
+ end
+
def test_index_on_named_scope
approved = Topic.approved.order('id ASC')
assert_equal topics(:second), approved[0]
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index d34c9b4895..1e345399f5 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -164,6 +164,11 @@ class RelationTest < ActiveRecord::TestCase
end
end
+ def test_respond_to_class_methods_and_named_scopes
+ assert DeveloperOrderedBySalary.scoped.respond_to?(:all_ordered_by_name)
+ assert Topic.scoped.respond_to?(:by_lifo)
+ end
+
def test_find_with_readonly_option
Developer.scoped.each { |d| assert !d.readonly? }
Developer.scoped.readonly.each { |d| assert d.readonly? }
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index f48b35486c..704313649a 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -100,3 +100,8 @@ end
class SubStiPost < StiPost
self.table_name = Post.table_name
end
+
+class PostWithComment < ActiveRecord::Base
+ self.table_name = 'posts'
+ default_scope where("posts.comments_count > 0").order("posts.comments_count ASC")
+end
diff --git a/railties/lib/generators/rails/app/templates/config.ru b/railties/lib/generators/rails/app/templates/config.ru
index 2ab821e38d..fcfbc6b07a 100644
--- a/railties/lib/generators/rails/app/templates/config.ru
+++ b/railties/lib/generators/rails/app/templates/config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-run <%= app_const %>.instance
+run <%= app_const %>
diff --git a/railties/lib/generators/rails/app/templates/config/databases/ibm_db.yml b/railties/lib/generators/rails/app/templates/config/databases/ibm_db.yml
index a9716ddb44..2cecb5c879 100644
--- a/railties/lib/generators/rails/app/templates/config/databases/ibm_db.yml
+++ b/railties/lib/generators/rails/app/templates/config/databases/ibm_db.yml
@@ -59,4 +59,4 @@ production:
#account: my_account
#app_user: my_app_user
#application: my_application
- #workstation: my_workstation \ No newline at end of file
+ #workstation: my_workstation
diff --git a/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt
index b10103b436..177ce44d41 100644
--- a/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt
+++ b/railties/lib/generators/rails/app/templates/config/environments/development.rb.tt
@@ -16,4 +16,4 @@
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
-end \ No newline at end of file
+end
diff --git a/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt
index 543a40108c..ee071df63b 100644
--- a/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt
+++ b/railties/lib/generators/rails/app/templates/config/environments/production.rb.tt
@@ -30,4 +30,4 @@
# Enable threaded mode
# config.threadsafe!
-end \ No newline at end of file
+end
diff --git a/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt
index 428fa35633..f6c38f3c0d 100644
--- a/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt
+++ b/railties/lib/generators/rails/app/templates/config/environments/test.rb.tt
@@ -26,4 +26,4 @@
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
-end \ No newline at end of file
+end
diff --git a/railties/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb b/railties/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb
index 839d4cde19..59385cdf37 100644
--- a/railties/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb
+++ b/railties/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb
@@ -4,4 +4,4 @@
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
-# Rails.backtrace_cleaner.remove_silencers! \ No newline at end of file
+# Rails.backtrace_cleaner.remove_silencers!
diff --git a/railties/lib/generators/rails/app/templates/config/locales/en.yml b/railties/lib/generators/rails/app/templates/config/locales/en.yml
index f265c068d8..a747bfa698 100644
--- a/railties/lib/generators/rails/app/templates/config/locales/en.yml
+++ b/railties/lib/generators/rails/app/templates/config/locales/en.yml
@@ -2,4 +2,4 @@
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
- hello: "Hello world" \ No newline at end of file
+ hello: "Hello world"
diff --git a/railties/lib/generators/rails/app/templates/db/seeds.rb b/railties/lib/generators/rails/app/templates/db/seeds.rb
index bc8695e6f0..664d8c74c8 100644
--- a/railties/lib/generators/rails/app/templates/db/seeds.rb
+++ b/railties/lib/generators/rails/app/templates/db/seeds.rb
@@ -2,6 +2,6 @@
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
-#
+#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
diff --git a/railties/lib/generators/rails/app/templates/script/console.tt b/railties/lib/generators/rails/app/templates/script/console.tt
index daba8ba2f1..915c5b8294 100755
--- a/railties/lib/generators/rails/app/templates/script/console.tt
+++ b/railties/lib/generators/rails/app/templates/script/console.tt
@@ -2,4 +2,4 @@ require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/console'
require File.expand_path('../../config/application', __FILE__)
-Rails::Console.start(<%= app_const %>.instance)
+Rails::Console.start(<%= app_const %>)
diff --git a/railties/lib/generators/rails/app/templates/script/dbconsole.tt b/railties/lib/generators/rails/app/templates/script/dbconsole.tt
index a7f114a97f..a92f6f2844 100755
--- a/railties/lib/generators/rails/app/templates/script/dbconsole.tt
+++ b/railties/lib/generators/rails/app/templates/script/dbconsole.tt
@@ -2,4 +2,4 @@ require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands/dbconsole'
require File.expand_path('../../config/application', __FILE__)
-Rails::DBConsole.start(<%= app_const %>.instance)
+Rails::DBConsole.start(<%= app_const %>)
diff --git a/railties/lib/generators/rails/metal/templates/metal.rb b/railties/lib/generators/rails/metal/templates/metal.rb
index e94982b69a..2f5d4e7593 100644
--- a/railties/lib/generators/rails/metal/templates/metal.rb
+++ b/railties/lib/generators/rails/metal/templates/metal.rb
@@ -1,12 +1,12 @@
# Allow the metal piece to run in isolation
-require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
+require File.expand_path('../../../config/environment', __FILE__)
class <%= class_name %>
def self.call(env)
if env["PATH_INFO"] =~ /^\/<%= file_name %>/
[200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
else
- [404, {"Content-Type" => "text/html"}, ["Not Found"]]
+ [404, {"Content-Type" => "text/html", "X-Cascade" => "pass"}, ["Not Found"]]
end
end
end
diff --git a/railties/lib/generators/rails/plugin/templates/Rakefile.tt b/railties/lib/generators/rails/plugin/templates/Rakefile.tt
index 23c2245a41..e94c0bfc77 100644
--- a/railties/lib/generators/rails/plugin/templates/Rakefile.tt
+++ b/railties/lib/generators/rails/plugin/templates/Rakefile.tt
@@ -1,22 +1,10 @@
-require 'rake'
require 'rake/testtask'
-require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the <%= file_name %> plugin.'
Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
end
-
-desc 'Generate documentation for the <%= file_name %> plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = '<%= class_name %>'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
diff --git a/railties/lib/generators/rails/stylesheets/templates/scaffold.css b/railties/lib/generators/rails/stylesheets/templates/scaffold.css
index d9fa2cf2dc..de6669ad9e 100644
--- a/railties/lib/generators/rails/stylesheets/templates/scaffold.css
+++ b/railties/lib/generators/rails/stylesheets/templates/scaffold.css
@@ -59,4 +59,3 @@ div.field, div.actions {
font-size: 12px;
list-style: square;
}
-
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 5c9892c630..8366127476 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -8,7 +8,13 @@ module Rails
class << self
attr_writer :config
alias configure class_eval
- delegate :initialize!, :load_tasks, :load_generators, :root, :to => :instance
+ delegate :call,
+ :initialize!,
+ :load_generators,
+ :load_tasks,
+ :middleware,
+ :root,
+ :to => :instance
private :new
def instance
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index 8c4247e840..31696598ce 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -76,7 +76,7 @@ module ApplicationTests
end
def middleware
- AppTemplate::Application.instance.middleware.active.map(&:klass).map(&:name)
+ AppTemplate::Application.middleware.active.map(&:klass).map(&:name)
end
end
end
diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb
index 725dd06929..50cb9e3acc 100644
--- a/railties/test/application/routing_test.rb
+++ b/railties/test/application/routing_test.rb
@@ -176,5 +176,33 @@ module ApplicationTests
get '/foo'
assert_equal 'baz', last_response.body
end
+
+ test 'resource routing with irrigular inflection' do
+ app_file 'config/initializers/inflection.rb', <<-RUBY
+ ActiveSupport::Inflector.inflections do |inflect|
+ inflect.irregular 'yazi', 'yazilar'
+ end
+ RUBY
+
+ app_file 'config/routes.rb', <<-RUBY
+ AppTemplate::Application.routes.draw do |map|
+ resources :yazilar
+ end
+ RUBY
+
+ controller 'yazilar', <<-RUBY
+ class YazilarController < ActionController::Base
+ def index
+ render :text => 'yazilar#index'
+ end
+ end
+ RUBY
+
+ get '/yazilars'
+ assert_equal 404, last_response.status
+
+ get '/yazilar'
+ assert_equal 200, last_response.status
+ end
end
end
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index 4bfe210efb..0a79e2cfb8 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -17,11 +17,11 @@ class PluginGeneratorTest < Rails::Generators::TestCase
vendor/plugins/plugin_fu/uninstall.rb
vendor/plugins/plugin_fu/lib
vendor/plugins/plugin_fu/lib/plugin_fu.rb
+ vendor/plugins/plugin_fu/Rakefile
).each{ |path| assert_file path }
%w(
vendor/plugins/plugin_fu/README
- vendor/plugins/plugin_fu/Rakefile
).each{ |path| assert_file path, /PluginFu/ }
%w(