Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into i18n

  • Loading branch information...
commit 9dac5547ad65e82a6fbb6a6243ab5c95d9c44db0 2 parents a6e05b1 + c0dd0ce
Jeremy Kemper jeremy authored
12 actionmailer/test/mail_render_test.rb
View
@@ -20,13 +20,13 @@ def rxml_template(recipient)
subject "rendering rxml template"
from "tester@example.com"
end
-
+
def included_subtemplate(recipient)
recipients recipient
subject "Including another template in the one being rendered"
from "tester@example.com"
end
-
+
def included_old_subtemplate(recipient)
recipients recipient
subject "Including another template in the one being rendered"
@@ -83,17 +83,11 @@ def test_rxml_template
mail = RenderMailer.deliver_rxml_template(@recipient)
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip
end
-
+
def test_included_subtemplate
mail = RenderMailer.deliver_included_subtemplate(@recipient)
assert_equal "Hey Ho, let's go!", mail.body.strip
end
-
- def test_deprecated_old_subtemplate
- assert_raises ActionView::ActionViewError do
- RenderMailer.deliver_included_old_subtemplate(@recipient)
- end
- end
end
class FirstSecondHelperTest < Test::Unit::TestCase
2  actionpack/lib/action_view/partials.rb
View
@@ -156,7 +156,7 @@ def render_partial(options = {}) #:nodoc:
local_assigns.merge!(builder_partial_path.to_sym => partial_path)
render_partial(:partial => builder_partial_path, :object => options[:object], :locals => local_assigns)
when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope
- partial_path.any? ? render_partial(:collection => partial_path, :locals => local_assigns) : ""
+ render_partial_collection(options.except(:partial).merge(:collection => partial_path))
else
object = partial_path
render_partial(
10 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
View
@@ -39,6 +39,11 @@ def render_with_record_collection
@developers = Developer.find(:all)
render :partial => @developers
end
+
+ def render_with_record_collection_and_spacer_template
+ @developer = Developer.find(1)
+ render :partial => @developer.projects, :spacer_template => 'test/partial_only'
+ end
end
class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
@@ -81,6 +86,11 @@ def test_render_with_record_collection
assert_equal 'DavidJamisfixture_3fixture_4fixture_5fixture_6fixture_7fixture_8fixture_9fixture_10Jamis', @response.body
end
+ def test_render_with_record_collection_and_spacer_template
+ get :render_with_record_collection_and_spacer_template
+ assert_equal 'Active Recordonly partialActive Controller', @response.body
+ end
+
def test_rendering_partial_with_has_one_association
mascot = Company.find(1).mascot
get :render_with_has_one_association
4 actionpack/test/template/render_test.rb
View
@@ -95,6 +95,10 @@ def test_render_partial_with_nil_collection_should_return_nil
assert_nil @view.render(:partial => "test/customer", :collection => nil)
end
+ def test_render_partial_with_empty_array_should_return_nil
+ assert_nil @view.render(:partial => [])
+ end
+
# TODO: The reason for this test is unclear, improve documentation
def test_render_partial_and_fallback_to_layout
assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" })
7 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
View
@@ -443,9 +443,10 @@ def #{column_type}(*args)
# Appends <tt>:datetime</tt> columns <tt>:created_at</tt> and
# <tt>:updated_at</tt> to the table.
- def timestamps
- column(:created_at, :datetime)
- column(:updated_at, :datetime)
+ def timestamps(*args)
+ options = args.extract_options!
+ column(:created_at, :datetime, options)
+ column(:updated_at, :datetime, options)
end
def references(*args)
6 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
View
@@ -534,13 +534,13 @@ def create_database(name, options = {})
option_string = options.symbolize_keys.sum do |key, value|
case key
when :owner
- " OWNER = '#{value}'"
+ " OWNER = \"#{value}\""
when :template
- " TEMPLATE = #{value}"
+ " TEMPLATE = \"#{value}\""
when :encoding
" ENCODING = '#{value}'"
when :tablespace
- " TABLESPACE = #{value}"
+ " TABLESPACE = \"#{value}\""
when :connection_limit
" CONNECTION LIMIT = #{value}"
else
2  activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
View
@@ -452,7 +452,7 @@ def test_find_in_association_with_custom_finder_sql
def test_find_in_association_with_custom_finder_sql_and_multiple_interpolations
# interpolate once:
- assert_equal [developers(:david), developers(:poor_jamis), developers(:jamis)], projects(:active_record).developers_with_finder_sql, "first interpolation"
+ assert_equal [developers(:david), developers(:jamis), developers(:poor_jamis)], projects(:active_record).developers_with_finder_sql, "first interpolation"
# interpolate again, for a different project id
assert_equal [developers(:david)], projects(:action_controller).developers_with_finder_sql, "second interpolation"
end
37 activerecord/test/cases/migration_test.rb
View
@@ -237,6 +237,39 @@ def test_create_table_with_force_true_does_not_drop_nonexisting_table
end
end
+ def test_create_table_with_timestamps_should_create_datetime_columns
+ table_name = :testings
+
+ Person.connection.create_table table_name do |t|
+ t.timestamps
+ end
+ created_columns = Person.connection.columns(table_name)
+
+ created_at_column = created_columns.detect {|c| c.name == 'created_at' }
+ updated_at_column = created_columns.detect {|c| c.name == 'updated_at' }
+
+ assert created_at_column.null
+ assert updated_at_column.null
+ ensure
+ Person.connection.drop_table table_name rescue nil
+ end
+
+ def test_create_table_with_timestamps_should_create_datetime_columns_with_options
+ table_name = :testings
+
+ Person.connection.create_table table_name do |t|
+ t.timestamps :null => false
+ end
+ created_columns = Person.connection.columns(table_name)
+
+ created_at_column = created_columns.detect {|c| c.name == 'created_at' }
+ updated_at_column = created_columns.detect {|c| c.name == 'updated_at' }
+
+ assert !created_at_column.null
+ assert !updated_at_column.null
+ ensure
+ Person.connection.drop_table table_name rescue nil
+ end
# SQL Server, Sybase, and SQLite3 will not allow you to add a NOT NULL
# column to a table without a default value.
@@ -1192,8 +1225,8 @@ def test_belongs_to_works_like_references
def test_timestamps_creates_updated_at_and_created_at
with_new_table do |t|
- t.expects(:column).with(:created_at, :datetime)
- t.expects(:column).with(:updated_at, :datetime)
+ t.expects(:column).with(:created_at, :datetime, kind_of(Hash))
+ t.expects(:column).with(:updated_at, :datetime, kind_of(Hash))
t.timestamps
end
end
2  activerecord/test/models/project.rb
View
@@ -7,7 +7,7 @@ class Project < ActiveRecord::Base
has_and_belongs_to_many :developers_named_david, :class_name => "Developer", :conditions => "name = 'David'", :uniq => true
has_and_belongs_to_many :developers_named_david_with_hash_conditions, :class_name => "Developer", :conditions => { :name => 'David' }, :uniq => true
has_and_belongs_to_many :salaried_developers, :class_name => "Developer", :conditions => "salary > 0"
- has_and_belongs_to_many :developers_with_finder_sql, :class_name => "Developer", :finder_sql => 'SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id}'
+ has_and_belongs_to_many :developers_with_finder_sql, :class_name => "Developer", :finder_sql => 'SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id} ORDER BY t.id'
has_and_belongs_to_many :developers_by_sql, :class_name => "Developer", :delete_sql => "DELETE FROM developers_projects WHERE project_id = \#{id} AND developer_id = \#{record.id}"
has_and_belongs_to_many :developers_with_callbacks, :class_name => "Developer", :before_add => Proc.new {|o, r| o.developers_log << "before_adding#{r.id || '<new>'}"},
:after_add => Proc.new {|o, r| o.developers_log << "after_adding#{r.id || '<new>'}"},
2  activesupport/lib/active_support/inflector.rb
View
@@ -173,7 +173,7 @@ def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
if first_letter_in_uppercase
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
else
- lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1]
+ lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
end
end
4 activesupport/test/core_ext/string_ext_test.rb
View
@@ -32,6 +32,10 @@ def test_camelize
end
end
+ def test_camelize_lower
+ assert_equal('capital', 'Capital'.camelize(:lower))
+ end
+
def test_underscore
CamelToUnderscore.each do |camel, underscore|
assert_equal(underscore, camel.underscore)
4 activesupport/test/inflector_test.rb
View
@@ -46,6 +46,10 @@ def test_camelize
end
end
+ def test_camelize_with_lower_downcases_the_first_letter
+ assert_equal('capital', ActiveSupport::Inflector.camelize('Capital', false))
+ end
+
def test_underscore
CamelToUnderscore.each do |camel, underscore|
assert_equal(underscore, ActiveSupport::Inflector.underscore(camel))
2  railties/lib/initializer.rb
View
@@ -356,7 +356,7 @@ def load_application_classes
if configuration.cache_classes
configuration.eager_load_paths.each do |load_path|
matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/
- Dir.glob("#{load_path}/**/*.rb").each do |file|
+ Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
require_dependency file.sub(matcher, '\1')
end
end
1  railties/lib/tasks/documentation.rake
View
@@ -62,6 +62,7 @@ namespace :doc do
options << "-o doc/plugins/#{plugin}"
options << "--title '#{plugin.titlecase} Plugin Documentation'"
options << '--line-numbers' << '--inline-source'
+ options << '--charset' << 'utf-8'
options << '-T html'
files.include("#{plugin_base}/lib/**/*.rb")
3  railties/test/fixtures/eager/zoo.rb
View
@@ -0,0 +1,3 @@
+class Zoo
+ include ReptileHouse
+end
2  railties/test/fixtures/eager/zoo/reptile_house.rb
View
@@ -0,0 +1,2 @@
+module Zoo::ReptileHouse
+end
18 railties/test/initializer_test.rb
View
@@ -30,6 +30,24 @@ def test_load_environment_with_constant
end
+class Initializer_eager_loading_Test < Test::Unit::TestCase
+ def setup
+ @config = ConfigurationMock.new("")
+ @config.cache_classes = true
+ @config.load_paths = [File.expand_path(File.dirname(__FILE__) + "/fixtures/eager")]
+ @config.eager_load_paths = [File.expand_path(File.dirname(__FILE__) + "/fixtures/eager")]
+ @initializer = Rails::Initializer.new(@config)
+ @initializer.set_load_path
+ @initializer.set_autoload_paths
+ end
+
+ def test_eager_loading_loads_parent_classes_before_children
+ assert_nothing_raised do
+ @initializer.load_application_classes
+ end
+ end
+end
+
uses_mocha 'Initializer after_initialize' do
class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase
def setup
Please sign in to comment.
Something went wrong with that request. Please try again.