aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/test/template/sprockets_helper_test.rb4
-rw-r--r--activerecord/lib/active_record/railties/databases.rake3
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb4
-rw-r--r--activerecord/test/cases/schema_dumper_test.rb15
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb6
-rw-r--r--activesupport/lib/active_support/dependencies.rb11
-rw-r--r--activesupport/test/safe_buffer_test.rb6
-rw-r--r--railties/lib/rails/generators/app_base.rb6
-rw-r--r--railties/lib/rails/generators/rails/app/templates/Gemfile3
-rw-r--r--railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb1
-rw-r--r--railties/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory0
-rw-r--r--railties/test/generators/plugin_new_generator_test.rb9
12 files changed, 46 insertions, 22 deletions
diff --git a/actionpack/test/template/sprockets_helper_test.rb b/actionpack/test/template/sprockets_helper_test.rb
index b9161b62c5..f4b5344d63 100644
--- a/actionpack/test/template/sprockets_helper_test.rb
+++ b/actionpack/test/template/sprockets_helper_test.rb
@@ -97,7 +97,7 @@ class SprocketsHelperTest < ActionView::TestCase
end
test "stylesheets served without a controller in scope cannot access the request" do
- remove_instance_variable("@controller")
+ @controller = nil
@config.action_controller.asset_host = Proc.new do |asset, request|
fail "This should not have been called."
end
@@ -107,7 +107,7 @@ class SprocketsHelperTest < ActionView::TestCase
end
test "stylesheets served without a controller in do not use asset hosts when the default protocol is :request" do
- remove_instance_variable("@controller")
+ @controller = nil
@config.action_controller.asset_host = "assets-%d.example.com"
@config.action_controller.default_asset_host_protocol = :request
@config.action_controller.perform_caching = true
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 0ee7e20cf1..ec00f7faad 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -341,7 +341,8 @@ db_namespace = namespace :db do
desc 'Create a db/schema.rb file that can be portably used against any DB supported by AR'
task :dump => :load_config do
require 'active_record/schema_dumper'
- File.open(ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb", "w") do |file|
+ filename = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb"
+ File.open(filename, "w:utf-8") do |file|
ActiveRecord::Base.establish_connection(Rails.env)
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
end
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 19585f6214..6fe305f843 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -40,6 +40,10 @@ module ActiveRecord
def header(stream)
define_params = @version ? ":version => #{@version}" : ""
+ if stream.respond_to?(:external_encoding)
+ stream.puts "# encoding: #{stream.external_encoding.name}"
+ end
+
stream.puts <<HEADER
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb
index 4adecf8e83..5da3f59a1f 100644
--- a/activerecord/test/cases/schema_dumper_test.rb
+++ b/activerecord/test/cases/schema_dumper_test.rb
@@ -3,11 +3,20 @@ require 'stringio'
class SchemaDumperTest < ActiveRecord::TestCase
+ def setup
+ @stream = StringIO.new
+ end
+
def standard_dump
- stream = StringIO.new
+ @stream = StringIO.new
ActiveRecord::SchemaDumper.ignore_tables = []
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
- stream.string
+ ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, @stream)
+ @stream.string
+ end
+
+ def test_magic_comment
+ skip "only test magic comments on 1.9" if RUBY_VERSION < '1.9'
+ assert_match "# encoding: #{@stream.external_encoding.name}", standard_dump
end
def test_schema_dump
diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb
index 3bf4edbdef..6d6c4912bb 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -86,6 +86,12 @@ module ActiveSupport #:nodoc:
end
end
+ def[](*args)
+ new_safe_buffer = super
+ new_safe_buffer.instance_eval { @dirty = false }
+ new_safe_buffer
+ end
+
def safe_concat(value)
raise SafeConcatError if dirty?
original_concat(value)
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 8cd4d15e4c..3f6c93e860 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -478,10 +478,6 @@ module ActiveSupport #:nodoc:
qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore
- trace = caller.reject {|l| l.starts_with? __FILE__ }
- name_error = NameError.new("uninitialized constant #{qualified_name}")
- name_error.set_backtrace(trace)
-
file_path = search_for_file(path_suffix)
if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load
@@ -500,11 +496,12 @@ module ActiveSupport #:nodoc:
return parent.const_missing(const_name)
rescue NameError => e
raise unless e.missing_name? qualified_name_for(parent, const_name)
- raise name_error
end
- else
- raise name_error
end
+
+ raise NameError,
+ "uninitialized constant #{qualified_name}",
+ caller.reject {|l| l.starts_with? __FILE__ }
end
# Remove the constants that have been autoloaded, and those that have been
diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb
index 7662e9b765..8f77999d25 100644
--- a/activesupport/test/safe_buffer_test.rb
+++ b/activesupport/test/safe_buffer_test.rb
@@ -106,4 +106,10 @@ class SafeBufferTest < ActiveSupport::TestCase
test "should not fail if the returned object is not a string" do
assert_kind_of NilClass, @buffer.slice("chipchop")
end
+
+ test "Should initialize @dirty to false for new instance when sliced" do
+ dirty = @buffer[0,0].send(:dirty?)
+ assert_not_nil dirty
+ assert !dirty
+ end
end
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index bbdd000ad9..21a2ae4e28 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -200,9 +200,11 @@ module Rails
def assets_gemfile_entry
<<-GEMFILE.strip_heredoc
+ # 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'
- gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails'
+ gem 'sass-rails', :git => 'git://github.com/rails/sass-rails.git'
+ gem 'coffee-rails', :git => 'git://github.com/rails/coffee-rails.git'
gem 'uglifier'
end
GEMFILE
diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile
index 88eea40b1b..c83e7ddf80 100644
--- a/railties/lib/rails/generators/rails/app/templates/Gemfile
+++ b/railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -7,10 +7,7 @@ source 'http://rubygems.org'
<%= "gem 'jruby-openssl'\n" if defined?(JRUBY_VERSION) -%>
<%= "gem 'json'\n" if RUBY_VERSION < "1.9.2" -%>
-# Gems used only for assets and not required
-# in production environments by default.
<%= assets_gemfile_entry %>
-
<%= javascript_gemfile_entry %>
# Use unicorn as the web server
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 56b1587760..c46422437d 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
@@ -19,6 +19,7 @@ module Rails
empty_directory_with_gitkeep "app/controllers"
empty_directory_with_gitkeep "app/views"
empty_directory_with_gitkeep "app/helpers"
+ empty_directory_with_gitkeep "app/mailers"
empty_directory_with_gitkeep "app/assets/images/#{name}"
end
end
diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory b/railties/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/railties/lib/rails/generators/rails/plugin_new/templates/app/mailers/.empty_directory
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index e6ea1cbc33..19e80eee89 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -25,10 +25,6 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
# brings setup, teardown, and some tests
include SharedGeneratorTests
- def default_files
- ::DEFAULT_PLUGIN_FILES
- end
-
def test_invalid_plugin_name_raises_an_error
content = capture(:stderr){ run_generator [File.join(destination_root, "43-things")] }
assert_equal "Invalid plugin name 43-things. Please give a name which does not start with numbers.\n", content
@@ -176,6 +172,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
assert_file "app/controllers"
assert_file "app/views"
assert_file "app/helpers"
+ assert_file "app/mailers"
assert_file "config/routes.rb", /Rails.application.routes.draw do/
assert_file "lib/bukkits/engine.rb", /module Bukkits\n class Engine < ::Rails::Engine\n end\nend/
assert_file "lib/bukkits.rb", /require "bukkits\/engine"/
@@ -257,6 +254,10 @@ protected
silence(:stdout){ generator.send(*args, &block) }
end
+protected
+ def default_files
+ ::DEFAULT_PLUGIN_FILES
+ end
end
class CustomPluginGeneratorTest < Rails::Generators::TestCase