diff options
24 files changed, 174 insertions, 96 deletions
diff --git a/RAILS_VERSION b/RAILS_VERSION index dd8b7cd23b..8733761b56 100644 --- a/RAILS_VERSION +++ b/RAILS_VERSION @@ -1 +1 @@ -3.2.0.beta +3.2.0.rc1 diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb index b74ba3cb0d..b33733fb6a 100644 --- a/actionmailer/lib/action_mailer/version.rb +++ b/actionmailer/lib/action_mailer/version.rb @@ -3,7 +3,7 @@ module ActionMailer MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index 1aa346929e..fe5bed70a9 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -20,7 +20,6 @@ Gem::Specification.new do |s| s.add_dependency('activemodel', version) s.add_dependency('rack-cache', '~> 1.1') s.add_dependency('builder', '~> 3.0.0') - s.add_dependency('i18n', '~> 0.6') s.add_dependency('rack', '~> 1.3.5') s.add_dependency('rack-test', '~> 0.6.1') s.add_dependency('journey', '~> 1.0.0.rc1') diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index 8b6136d6ba..cb3b793418 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -241,6 +241,7 @@ module AbstractController # the template name # false:: There is no layout # true:: raise an ArgumentError + # nil:: Force default layout behavior with inheritance # # ==== Parameters # * <tt>layout</tt> - The layout to use. @@ -254,7 +255,7 @@ module AbstractController conditions.each {|k, v| conditions[k] = Array(v).map {|a| a.to_s} } self._layout_conditions = conditions - @_layout = layout || false # Converts nil to false + @_layout = layout _write_layout_method end diff --git a/actionpack/lib/action_pack/version.rb b/actionpack/lib/action_pack/version.rb index add6b56425..d9bb41e80c 100644 --- a/actionpack/lib/action_pack/version.rb +++ b/actionpack/lib/action_pack/version.rb @@ -3,7 +3,7 @@ module ActionPack MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 10797c010f..eac6287b0b 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -173,6 +173,50 @@ module ActionView @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", '') : identifier end + # This method is responsible for properly setting the encoding of the + # source. Until this point, we assume that the source is BINARY data. + # If no additional information is supplied, we assume the encoding is + # the same as <tt>Encoding.default_external</tt>. + # + # The user can also specify the encoding via a comment on the first + # line of the template (# encoding: NAME-OF-ENCODING). This will work + # with any template engine, as we process out the encoding comment + # before passing the source on to the template engine, leaving a + # blank line in its stead. + def encode! + return unless source.encoding_aware? && source.encoding == Encoding::BINARY + + # Look for # encoding: *. If we find one, we'll encode the + # String in that encoding, otherwise, we'll use the + # default external encoding. + if source.sub!(/\A#{ENCODING_FLAG}/, '') + encoding = magic_encoding = $1 + else + encoding = Encoding.default_external + end + + # Tag the source with the default external encoding + # or the encoding specified in the file + source.force_encoding(encoding) + + # If the user didn't specify an encoding, and the handler + # handles encodings, we simply pass the String as is to + # the handler (with the default_external tag) + if !magic_encoding && @handler.respond_to?(:handles_encoding?) && @handler.handles_encoding? + source + # Otherwise, if the String is valid in the encoding, + # encode immediately to default_internal. This means + # that if a handler doesn't handle encodings, it will + # always get Strings in the default_internal + elsif source.valid_encoding? + source.encode! + # Otherwise, since the String is invalid in the encoding + # specified, raise an exception + else + raise WrongEncodingError.new(source, encoding) + end + end + protected # Compile a template. This method ensures a template is compiled @@ -195,15 +239,7 @@ module ActionView end # Among other things, this method is responsible for properly setting - # the encoding of the source. Until this point, we assume that the - # source is BINARY data. If no additional information is supplied, - # we assume the encoding is the same as <tt>Encoding.default_external</tt>. - # - # The user can also specify the encoding via a comment on the first - # line of the template (# encoding: NAME-OF-ENCODING). This will work - # with any template engine, as we process out the encoding comment - # before passing the source on to the template engine, leaving a - # blank line in its stead. + # the encoding of the compiled template. # # If the template engine handles encodings, we send the encoded # String to the engine without further processing. This allows @@ -215,40 +251,8 @@ module ActionView # In general, this means that templates will be UTF-8 inside of Rails, # regardless of the original source encoding. def compile(view, mod) #:nodoc: + encode! method_name = self.method_name - - if source.encoding_aware? - # Look for # encoding: *. If we find one, we'll encode the - # String in that encoding, otherwise, we'll use the - # default external encoding. - if source.sub!(/\A#{ENCODING_FLAG}/, '') - encoding = magic_encoding = $1 - else - encoding = Encoding.default_external - end - - # Tag the source with the default external encoding - # or the encoding specified in the file - source.force_encoding(encoding) - - # If the user didn't specify an encoding, and the handler - # handles encodings, we simply pass the String as is to - # the handler (with the default_external tag) - if !magic_encoding && @handler.respond_to?(:handles_encoding?) && @handler.handles_encoding? - source - # Otherwise, if the String is valid in the encoding, - # encode immediately to default_internal. This means - # that if a handler doesn't handle encodings, it will - # always get Strings in the default_internal - elsif source.valid_encoding? - source.encode! - # Otherwise, since the String is invalid in the encoding - # specified, raise an exception - else - raise WrongEncodingError.new(source, encoding) - end - end - code = @handler.call(self) # Make sure that the resulting String to be evalled is in the @@ -297,7 +301,11 @@ module ActionView raise e else assigns = view.respond_to?(:assigns) ? view.assigns : {} - template = @virtual_path ? refresh(view) : self + template = self + unless template.source + template = refresh(view) + template.encode! + end raise Template::Error.new(template, assigns, e) end end diff --git a/actionpack/lib/action_view/template/error.rb b/actionpack/lib/action_view/template/error.rb index fe27e54037..587e37a84f 100644 --- a/actionpack/lib/action_view/template/error.rb +++ b/actionpack/lib/action_view/template/error.rb @@ -89,14 +89,10 @@ module ActionView line_counter = start_on_line return unless source_code = source_code[start_on_line..end_on_line] - extract = source_code.sum do |line| + source_code.sum do |line| line_counter += 1 "#{indent}#{line_counter}: #{line}\n" end - - extract.encode! if extract.respond_to?(:encode!) - - extract end def sub_template_of(template_path) diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb index de6f42d826..61d35756b1 100644 --- a/actionpack/test/abstract/layouts_test.rb +++ b/actionpack/test/abstract/layouts_test.rb @@ -14,7 +14,10 @@ module AbstractControllerTests "layouts/overwrite.erb" => "Overwrite <%= yield %>", "layouts/with_false_layout.erb" => "False Layout <%= yield %>", "abstract_controller_tests/layouts/with_string_implied_child.erb" => - "With Implied <%= yield %>" + "With Implied <%= yield %>", + "abstract_controller_tests/layouts/with_grand_child_of_implied.erb" => + "With Grand Child <%= yield %>" + )] end @@ -57,16 +60,16 @@ module AbstractControllerTests layout "hello_override" end - class WithNilChild < WithString - layout nil - end - class WithStringImpliedChild < WithString end class WithChildOfImplied < WithStringImpliedChild end + class WithGrandChildOfImplied < WithStringImpliedChild + layout nil + end + class WithProc < Base layout proc { |c| "overwrite" } @@ -262,12 +265,6 @@ module AbstractControllerTests assert_equal "With Implied Hello string!", controller.response_body end - test "when a child controller specifies layout nil, do not use the parent layout" do - controller = WithNilChild.new - controller.process(:index) - assert_equal "Hello string!", controller.response_body - end - test "when a grandchild has no layout specified, the child has an implied layout, and the " \ "parent has specified a layout, use the child controller layout" do controller = WithChildOfImplied.new @@ -275,6 +272,13 @@ module AbstractControllerTests assert_equal "With Implied Hello string!", controller.response_body end + test "when a grandchild has nil layout specified, the child has an implied layout, and the " \ + "parent has specified a layout, use the child controller layout" do + controller = WithGrandChildOfImplied.new + controller.process(:index) + assert_equal "With Grand Child Hello string!", controller.response_body + end + test "raises an exception when specifying layout true" do assert_raises ArgumentError do Object.class_eval do diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 243bad8749..f42a04d670 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -25,6 +25,8 @@ end class TestController < ActionController::Base protect_from_forgery + before_filter :set_variable_for_layout + class LabellingFormBuilder < ActionView::Helpers::FormBuilder end @@ -364,17 +366,14 @@ class TestController < ActionController::Base end def layout_test_with_different_layout - @variable_for_layout = nil render :action => "hello_world", :layout => "standard" end def layout_test_with_different_layout_and_string_action - @variable_for_layout = nil render "hello_world", :layout => "standard" end def layout_test_with_different_layout_and_symbol_action - @variable_for_layout = nil render :hello_world, :layout => "standard" end @@ -383,7 +382,6 @@ class TestController < ActionController::Base end def layout_overriding_layout - @variable_for_layout = nil render :action => "hello_world", :layout => "standard" end @@ -666,8 +664,11 @@ class TestController < ActionController::Base private + def set_variable_for_layout + @variable_for_layout = nil + end + def determine_layout - @variable_for_layout ||= nil case action_name when "hello_world", "layout_test", "rendering_without_layout", "rendering_nothing_on_layout", "render_text_hello_world", diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 062fc1f94e..f40d663ae8 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -85,6 +85,57 @@ class LegacyRouteSetTests < Test::Unit::TestCase @rs.clear! end + def test_class_and_lambda_constraints + subdomain = Class.new { + def matches? request + request.subdomain.present? and request.subdomain != 'clients' + end + } + + @rs.draw do + match '/', :constraints => subdomain.new, + :to => lambda { |env| [200, {}, 'default'] } + match '/', :constraints => { :subdomain => 'clients' }, + :to => lambda { |env| [200, {}, 'clients'] } + end + + body = @rs.call({'PATH_INFO' => '/', + 'REQUEST_METHOD' => 'GET', + 'HTTP_HOST' => 'www.example.org'})[2] + + assert_equal 'default', body + + body = @rs.call({'PATH_INFO' => '/', + 'REQUEST_METHOD' => 'GET', + 'HTTP_HOST' => 'clients.example.org'})[2] + + assert_equal 'clients', body + end + + def test_lambda_constraints + @rs.draw do + match '/', :constraints => lambda { |req| + req.subdomain.present? and req.subdomain != "clients" }, + :to => lambda { |env| [200, {}, 'default'] } + + match '/', :constraints => lambda { |req| + req.subdomain.present? && req.subdomain == "clients" }, + :to => lambda { |env| [200, {}, 'clients'] } + end + + body = @rs.call({'PATH_INFO' => '/', + 'REQUEST_METHOD' => 'GET', + 'HTTP_HOST' => 'www.example.org'})[2] + + assert_equal 'default', body + + body = @rs.call({'PATH_INFO' => '/', + 'REQUEST_METHOD' => 'GET', + 'HTTP_HOST' => 'clients.example.org'})[2] + + assert_equal 'clients', body + end + def test_draw_with_block_arity_one_raises assert_raise(RuntimeError) do @rs.draw { |map| map.match '/:controller(/:action(/:id))' } diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb index 1a032539b9..f7a746120e 100644 --- a/actionpack/test/dispatch/mount_test.rb +++ b/actionpack/test/dispatch/mount_test.rb @@ -51,4 +51,4 @@ class TestRoutingMount < ActionDispatch::IntegrationTest get "/fakeengine" assert_equal "OK", response.body end -end
\ No newline at end of file +end diff --git a/activemodel/activemodel.gemspec b/activemodel/activemodel.gemspec index 49f664bf89..283c3ee324 100644 --- a/activemodel/activemodel.gemspec +++ b/activemodel/activemodel.gemspec @@ -18,5 +18,4 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', version) s.add_dependency('builder', '~> 3.0.0') - s.add_dependency('i18n', '~> 0.6') end diff --git a/activemodel/lib/active_model/version.rb b/activemodel/lib/active_model/version.rb index dbda55ca7c..834cbf96e3 100644 --- a/activemodel/lib/active_model/version.rb +++ b/activemodel/lib/active_model/version.rb @@ -3,7 +3,7 @@ module ActiveModel MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 0d1d9845ae..199eee4359 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -446,26 +446,39 @@ db_namespace = namespace :db do end namespace :test do - # desc "Recreate the test database from the current schema.rb" + + # desc "Recreate the test database from the current schema" task :load => 'db:test:purge' do - ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) - ActiveRecord::Schema.verbose = false - db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby + case ActiveRecord::Base.schema_format + when :ruby + db_namespace["test:load_schema"].invoke + when :sql + db_namespace["test:load_structure"].invoke + end + end + # desc "Recreate the test database from an existent structure.sql file" + task :load_structure => 'db:test:purge' do begin old_env, ENV['RAILS_ENV'] = ENV['RAILS_ENV'], 'test' - db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql + db_namespace["structure:load"].invoke ensure ENV['RAILS_ENV'] = old_env end + end + # desc "Recreate the test database from an existent schema.rb file" + task :load_schema => 'db:test:purge' do + ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) + ActiveRecord::Schema.verbose = false + db_namespace["schema:load"].invoke end - # desc "Recreate the test database from the current environment's database schema" - task :clone => %w(db:schema:dump db:test:load) + # desc "Recreate the test database from a fresh schema.rb file" + task :clone => %w(db:schema:dump db:test:load_schema) - # desc "Recreate the test databases from the structure.sql file" - task :clone_structure => [ "db:structure:dump", "db:test:load" ] + # desc "Recreate the test database from a fresh structure.sql file" + task :clone_structure => [ "db:structure:dump", "db:test:load_structure" ] # desc "Empty the test database" task :purge => :environment do diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb index 9840cbccae..6b5070808a 100644 --- a/activerecord/lib/active_record/scoping/default.rb +++ b/activerecord/lib/active_record/scoping/default.rb @@ -12,7 +12,7 @@ module ActiveRecord end module ClassMethods - # Returns a scope for this class without taking into account the default_scope. + # Returns a scope for the model without the default_scope. # # class Post < ActiveRecord::Base # def self.default_scope @@ -23,18 +23,20 @@ module ActiveRecord # Post.all # Fires "SELECT * FROM posts WHERE published = true" # Post.unscoped.all # Fires "SELECT * FROM posts" # - # This method also accepts a block meaning that all queries inside the block will + # This method also accepts a block. All queries inside the block will # not use the default_scope: # # Post.unscoped { # Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10" # } # - # It is recommended to use block form of unscoped because chaining unscoped with <tt>scope</tt> - # does not work. Assuming that <tt>published</tt> is a <tt>scope</tt> following two statements are same. + # It is recommended to use the block form of unscoped because chaining + # unscoped with <tt>scope</tt> does not work. Assuming that + # <tt>published</tt> is a <tt>scope</tt>, the following two statements + # are equal: the default_scope is applied on both. # - # Post.unscoped.published - # Post.published + # Post.unscoped.published + # Post.published def unscoped #:nodoc: block_given? ? relation.scoping { yield } : relation end diff --git a/activerecord/lib/active_record/version.rb b/activerecord/lib/active_record/version.rb index 838aa8fb1e..2e16a52392 100644 --- a/activerecord/lib/active_record/version.rb +++ b/activerecord/lib/active_record/version.rb @@ -3,7 +3,7 @@ module ActiveRecord MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end diff --git a/activeresource/lib/active_resource/version.rb b/activeresource/lib/active_resource/version.rb index d53374b261..1cb96ac005 100644 --- a/activeresource/lib/active_resource/version.rb +++ b/activeresource/lib/active_resource/version.rb @@ -3,7 +3,7 @@ module ActiveResource MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb index bd8e7f907a..f1387c9f39 100644 --- a/activesupport/lib/active_support/version.rb +++ b/activesupport/lib/active_support/version.rb @@ -3,7 +3,7 @@ module ActiveSupport MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end diff --git a/railties/guides/source/migrations.textile b/railties/guides/source/migrations.textile index 92356edf90..66160f8b26 100644 --- a/railties/guides/source/migrations.textile +++ b/railties/guides/source/migrations.textile @@ -814,7 +814,7 @@ replaying the entire migration history. It is much simpler and faster to just load into the database a description of the current schema. For example, this is how the test database is created: the current development -database is dumped (either to +db/schema.rb+ or +db/development.sql+) and then +database is dumped (either to +db/schema.rb+ or +db/structure.sql+) and then loaded into the test database. Schema files are also useful if you want a quick look at what attributes an diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 197b692469..0b50d7e125 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -200,8 +200,8 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git' - gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails.git' + gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git', :branch => '3-2-stable' + gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails.git', :branch => '3-2-stable' #{"gem 'therubyrhino'\n" if defined?(JRUBY_VERSION)} gem 'uglifier', '>= 1.0.3' end diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index c260cc999b..082642d5cd 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -13,6 +13,9 @@ source 'https://rubygems.org' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' +# To use Jbuilder templates for JSON +# gem 'jbuilder' + # Use unicorn as the web server # gem 'unicorn' diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index 254227ecf7..9844cbe34b 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -3,7 +3,7 @@ module Rails MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end diff --git a/railties/test/application/middleware/exceptions_test.rb b/railties/test/application/middleware/exceptions_test.rb index a9cde42be8..aedc4fe648 100644 --- a/railties/test/application/middleware/exceptions_test.rb +++ b/railties/test/application/middleware/exceptions_test.rb @@ -99,7 +99,7 @@ module ApplicationTests app_file 'app/views/foo/index.html.erb', <<-ERB <% raise 'boooom' %> - ✓ + ✓測試テスト시험 ERB app_file 'config/routes.rb', <<-RUBY @@ -110,6 +110,7 @@ module ApplicationTests post '/foo', :utf8 => '✓' assert_match(/boooom/, last_response.body) + assert_match(/測試テスト시험/, last_response.body) end end end diff --git a/version.rb b/version.rb index 254227ecf7..9844cbe34b 100644 --- a/version.rb +++ b/version.rb @@ -3,7 +3,7 @@ module Rails MAJOR = 3 MINOR = 2 TINY = 0 - PRE = "beta" + PRE = "rc1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end |