Permalink
Browse files

Merge branch 'master' into inflector-with-lru-cache

  • Loading branch information...
2 parents b8ad411 + a6a8415 commit 46fc3937750a26a53f4b52f165ffaa52d6f41c15 @fxn fxn committed May 2, 2013
Showing with 599 additions and 495 deletions.
  1. +1 −1 actionpack/lib/action_dispatch/http/parameters.rb
  2. +6 −0 actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
  3. +1 −1 actionpack/test/dispatch/request/json_params_parsing_test.rb
  4. +1 −1 activemodel/lib/active_model/attribute_methods.rb
  5. +4 −4 activemodel/lib/active_model/callbacks.rb
  6. +1 −1 activemodel/lib/active_model/dirty.rb
  7. +9 −9 activemodel/lib/active_model/errors.rb
  8. +2 −2 activemodel/lib/active_model/naming.rb
  9. +1 −1 activemodel/lib/active_model/secure_password.rb
  10. +5 −5 activemodel/lib/active_model/serializers/xml.rb
  11. +1 −1 activemodel/lib/active_model/translation.rb
  12. +1 −1 activemodel/lib/active_model/validations.rb
  13. +1 −1 activemodel/lib/active_model/validations/acceptance.rb
  14. +1 −1 activemodel/lib/active_model/validations/callbacks.rb
  15. +1 −1 activemodel/lib/active_model/validations/confirmation.rb
  16. +1 −1 activemodel/lib/active_model/validations/exclusion.rb
  17. +1 −1 activemodel/lib/active_model/validations/format.rb
  18. +1 −1 activemodel/lib/active_model/validations/inclusion.rb
  19. +2 −2 activemodel/lib/active_model/validations/length.rb
  20. +5 −5 activemodel/lib/active_model/validations/numericality.rb
  21. +2 −2 activemodel/lib/active_model/validations/validates.rb
  22. +2 −2 activemodel/test/cases/attribute_methods_test.rb
  23. +3 −3 activemodel/test/cases/callbacks_test.rb
  24. +2 −2 activemodel/test/cases/conversion_test.rb
  25. +4 −4 activemodel/test/cases/errors_test.rb
  26. +2 −2 activemodel/test/cases/model_test.rb
  27. +17 −17 activemodel/test/cases/serialization_test.rb
  28. +1 −1 activemodel/test/cases/serializers/json_serialization_test.rb
  29. +27 −27 activemodel/test/cases/serializers/xml_serialization_test.rb
  30. +23 −20 activemodel/test/cases/translation_test.rb
  31. +2 −2 activemodel/test/cases/validations/acceptance_validation_test.rb
  32. +17 −17 activemodel/test/cases/validations/conditional_validation_test.rb
  33. +3 −3 activemodel/test/cases/validations/confirmation_validation_test.rb
  34. +6 −6 activemodel/test/cases/validations/exclusion_validation_test.rb
  35. +14 −14 activemodel/test/cases/validations/format_validation_test.rb
  36. +25 −25 activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
  37. +58 −59 activemodel/test/cases/validations/i18n_validation_test.rb
  38. +13 −13 activemodel/test/cases/validations/inclusion_validation_test.rb
  39. +23 −23 activemodel/test/cases/validations/numericality_validation_test.rb
  40. +18 −18 activemodel/test/cases/validations/validates_test.rb
  41. +4 −4 activemodel/test/cases/validations/validations_context_test.rb
  42. +18 −18 activemodel/test/cases/validations/with_validation_test.rb
  43. +23 −23 activemodel/test/cases/validations_test.rb
  44. +2 −2 activemodel/test/models/automobile.rb
  45. +1 −1 activemodel/test/models/contact.rb
  46. +3 −3 activemodel/test/models/reply.rb
  47. +24 −0 activerecord/CHANGELOG.md
  48. +29 −1 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  49. +18 −8 activerecord/lib/active_record/relation/calculations.rb
  50. +4 −0 activerecord/lib/active_record/relation/predicate_builder.rb
  51. +30 −0 activerecord/test/cases/adapters/postgresql/uuid_test.rb
  52. +0 −73 activerecord/test/cases/base_test.rb
  53. +12 −0 activerecord/test/cases/calculations_test.rb
  54. +2 −1 activerecord/test/cases/finder_test.rb
  55. +87 −0 activerecord/test/cases/integration_test.rb
  56. +8 −0 activerecord/test/cases/relation/where_test.rb
  57. +2 −0 activerecord/test/models/company.rb
  58. +1 −0 activesupport/lib/active_support/core_ext/date_time/calculations.rb
  59. +1 −0 activesupport/lib/active_support/core_ext/date_time/conversions.rb
  60. +1 −0 activesupport/lib/active_support/core_ext/date_time/zones.rb
  61. +9 −19 activesupport/lib/active_support/core_ext/object/inclusion.rb
  62. +1 −1 activesupport/test/callbacks_test.rb
  63. +0 −10 activesupport/test/core_ext/object/inclusion_test.rb
  64. +3 −0 activesupport/test/test_case_test.rb
  65. +1 −2 guides/source/active_support_core_extensions.md
  66. +4 −18 railties/lib/rails/test_unit/testing.rake
  67. +2 −2 railties/lib/rails/version.rb
  68. +1 −9 railties/test/initializable_test.rb
@@ -65,7 +65,7 @@ def normalize_encode_params(params)
new_hash = {}
params.each do |k, v|
- new_key = k.is_a?(String) ? k.dup.force_encoding("UTF-8").encode! : k
+ new_key = k.is_a?(String) ? k.dup.force_encoding(Encoding::UTF_8).encode! : k
new_hash[new_key] =
case v
when Hash
@@ -34,6 +34,12 @@
padding: 0.5em 1.5em;
}
+ h1 {
+ margin: 0.2em 0;
+ line-height: 1.1em;
+ font-size: 2em;
+ }
+
h2 {
color: #C52F24;
line-height: 25px;
@@ -50,7 +50,7 @@ def teardown
output = StringIO.new
json = "[\"person]\": {\"name\": \"David\"}}"
post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => ActiveSupport::Logger.new(output)}
- assert_response :error
+ assert_response :bad_request
output.rewind && err = output.read
assert err =~ /Error occurred while parsing request parameters/
end
@@ -343,7 +343,7 @@ def instance_method_already_implemented?(method_name) #:nodoc:
# significantly (in our case our test suite finishes 10% faster with
# this cache).
def attribute_method_matchers_cache #:nodoc:
- @attribute_method_matchers_cache ||= ThreadSafe::Cache.new(:initial_capacity => 4)
+ @attribute_method_matchers_cache ||= ThreadSafe::Cache.new(initial_capacity: 4)
end
def attribute_method_matcher(method_name) #:nodoc:
@@ -100,10 +100,10 @@ def self.extended(base) #:nodoc:
def define_model_callbacks(*callbacks)
options = callbacks.extract_options!
options = {
- :terminator => "result == false",
- :skip_after_callbacks_if_terminated => true,
- :scope => [:kind, :name],
- :only => [:before, :around, :after]
+ terminator: "result == false",
+ skip_after_callbacks_if_terminated: true,
+ scope: [:kind, :name],
+ only: [:before, :around, :after]
}.merge!(options)
types = Array(options.delete(:only))
@@ -91,7 +91,7 @@ module Dirty
included do
attribute_method_suffix '_changed?', '_change', '_will_change!', '_was'
- attribute_method_affix :prefix => 'reset_', :suffix => '!'
+ attribute_method_affix prefix: 'reset_', suffix: '!'
end
# Returns +true+ if any attribute have unsaved changes, +false+ otherwise.
@@ -231,7 +231,7 @@ def empty?
# # <error>name must be specified</error>
# # </errors>
def to_xml(options={})
- to_a.to_xml({ :root => "errors", :skip_types => true }.merge!(options))
+ to_a.to_xml({ root: "errors", skip_types: true }.merge!(options))
end
# Returns a Hash that can be used as the JSON representation for this
@@ -370,11 +370,11 @@ def full_messages_for(attribute)
def full_message(attribute, message)
return message if attribute == :base
attr_name = attribute.to_s.tr('.', '_').humanize
- attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
+ attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
I18n.t(:"errors.format", {
- :default => "%{attribute} %{message}",
- :attribute => attr_name,
- :message => message
+ default: "%{attribute} %{message}",
+ attribute: attr_name,
+ message: message
})
end
@@ -426,10 +426,10 @@ def generate_message(attribute, type = :invalid, options = {})
value = (attribute != :base ? @base.send(:read_attribute_for_validation, attribute) : nil)
options = {
- :default => defaults,
- :model => @base.class.model_name.human,
- :attribute => @base.class.human_attribute_name(attribute),
- :value => value
+ default: defaults,
+ model: @base.class.model_name.human,
+ attribute: @base.class.human_attribute_name(attribute),
+ value: value
}.merge!(options)
I18n.translate(key, options)
@@ -129,7 +129,7 @@ class Name
#
# Equivalent to +to_s+.
delegate :==, :===, :<=>, :=~, :"!~", :eql?, :to_s,
- :to_str, :to => :name
+ :to_str, to: :name
# Returns a new ActiveModel::Name instance. By default, the +namespace+
# and +name+ option will take the namespace and name of the given class
@@ -183,7 +183,7 @@ def human(options={})
defaults << options[:default] if options[:default]
defaults << @human
- options = { :scope => [@klass.i18n_scope, :models], :count => 1, :default => defaults }.merge!(options.except(:default))
+ options = { scope: [@klass.i18n_scope, :models], count: 1, default: defaults }.merge!(options.except(:default))
I18n.translate(defaults.shift, options)
end
@@ -57,7 +57,7 @@ def has_secure_password(options = {})
if options.fetch(:validations, true)
validates_confirmation_of :password
- validates_presence_of :password, :on => :create
+ validates_presence_of :password, on: :create
before_create { raise "Password digest missing on new record" if password_digest.blank? }
end
@@ -79,7 +79,7 @@ def serialize
require 'builder' unless defined? ::Builder
options[:indent] ||= 2
- options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent])
+ options[:builder] ||= ::Builder::XmlMarkup.new(indent: options[:indent])
@builder = options[:builder]
@builder.instruct! unless options[:skip_instruct]
@@ -88,8 +88,8 @@ def serialize
root = ActiveSupport::XmlMini.rename_key(root, options)
args = [root]
- args << {:xmlns => options[:namespace]} if options[:namespace]
- args << {:type => options[:type]} if options[:type] && !options[:skip_types]
+ args << { xmlns: options[:namespace] } if options[:namespace]
+ args << { type: options[:type] } if options[:type] && !options[:skip_types]
@builder.tag!(*args) do
add_attributes_and_methods
@@ -132,7 +132,7 @@ def add_associations(association, records, opts)
records = records.to_ary
tag = ActiveSupport::XmlMini.rename_key(association.to_s, options)
- type = options[:skip_types] ? { } : {:type => "array"}
+ type = options[:skip_types] ? { } : { type: "array" }
association_name = association.to_s.singularize
merged_options[:root] = association_name
@@ -145,7 +145,7 @@ def add_associations(association, records, opts)
record_type = {}
else
record_class = (record.class.to_s.underscore == association_name) ? nil : record.class.name
- record_type = {:type => record_class}
+ record_type = { type: record_class }
end
record.to_xml merged_options.merge(record_type)
@@ -41,7 +41,7 @@ def lookup_ancestors
#
# Specify +options+ with additional translating options.
def human_attribute_name(attribute, options = {})
- options = { :count => 1 }.merge!(options)
+ options = { count: 1 }.merge!(options)
parts = attribute.to_s.split(".")
attribute = parts.pop
namespace = parts.join("/") unless parts.empty?
@@ -46,7 +46,7 @@ module Validations
include HelperMethods
attr_accessor :validation_context
- define_callbacks :validate, :scope => :name
+ define_callbacks :validate, scope: :name
class_attribute :_validators
self._validators = Hash.new { |h,k| h[k] = [] }
@@ -3,7 +3,7 @@ module ActiveModel
module Validations
class AcceptanceValidator < EachValidator # :nodoc:
def initialize(options)
- super({ :allow_nil => true, :accept => "1" }.merge!(options))
+ super({ allow_nil: true, accept: "1" }.merge!(options))
end
def validate_each(record, attribute, value)
@@ -22,7 +22,7 @@ module Callbacks
included do
include ActiveSupport::Callbacks
- define_callbacks :validation, :terminator => "result == false", :skip_after_callbacks_if_terminated => true, :scope => [:kind, :name]
+ define_callbacks :validation, terminator: "result == false", skip_after_callbacks_if_terminated: true, scope: [:kind, :name]
end
module ClassMethods
@@ -5,7 +5,7 @@ class ConfirmationValidator < EachValidator # :nodoc:
def validate_each(record, attribute, value)
if (confirmed = record.send("#{attribute}_confirmation")) && (value != confirmed)
human_attribute_name = record.class.human_attribute_name(attribute)
- record.errors.add(:"#{attribute}_confirmation", :confirmation, options.merge(:attribute => human_attribute_name))
+ record.errors.add(:"#{attribute}_confirmation", :confirmation, options.merge(attribute: human_attribute_name))
end
end
@@ -8,7 +8,7 @@ class ExclusionValidator < EachValidator # :nodoc:
def validate_each(record, attribute, value)
if include?(record, value)
- record.errors.add(attribute, :exclusion, options.except(:in, :within).merge!(:value => value))
+ record.errors.add(attribute, :exclusion, options.except(:in, :within).merge!(value: value))
end
end
end
@@ -29,7 +29,7 @@ def option_call(record, name)
end
def record_error(record, attribute, name, value)
- record.errors.add(attribute, :invalid, options.except(name).merge!(:value => value))
+ record.errors.add(attribute, :invalid, options.except(name).merge!(value: value))
end
def regexp_using_multiline_anchors?(regexp)
@@ -8,7 +8,7 @@ class InclusionValidator < EachValidator # :nodoc:
def validate_each(record, attribute, value)
unless include?(record, value)
- record.errors.add(attribute, :inclusion, options.except(:in, :within).merge!(:value => value))
+ record.errors.add(attribute, :inclusion, options.except(:in, :within).merge!(value: value))
end
end
end
@@ -3,8 +3,8 @@ module ActiveModel
# == Active \Model Length \Validator
module Validations
class LengthValidator < EachValidator # :nodoc:
- MESSAGES = { :is => :wrong_length, :minimum => :too_short, :maximum => :too_long }.freeze
- CHECKS = { :is => :==, :minimum => :>=, :maximum => :<= }.freeze
+ MESSAGES = { is: :wrong_length, minimum: :too_short, maximum: :too_long }.freeze
+ CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze
RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long]
@@ -2,9 +2,9 @@ module ActiveModel
module Validations
class NumericalityValidator < EachValidator # :nodoc:
- CHECKS = { :greater_than => :>, :greater_than_or_equal_to => :>=,
- :equal_to => :==, :less_than => :<, :less_than_or_equal_to => :<=,
- :odd => :odd?, :even => :even?, :other_than => :!= }.freeze
+ CHECKS = { greater_than: :>, greater_than_or_equal_to: :>=,
+ equal_to: :==, less_than: :<, less_than_or_equal_to: :<=,
+ odd: :odd?, even: :even?, other_than: :!= }.freeze
RESERVED_OPTIONS = CHECKS.keys + [:only_integer]
@@ -47,7 +47,7 @@ def validate_each(record, attr_name, value)
option_value = record.send(option_value) if option_value.is_a?(Symbol)
unless value.send(CHECKS[option], option_value)
- record.errors.add(attr_name, option, filtered_options(value).merge(:count => option_value))
+ record.errors.add(attr_name, option, filtered_options(value).merge(count: option_value))
end
end
end
@@ -73,7 +73,7 @@ def parse_raw_value_as_an_integer(raw_value)
end
def filtered_options(value)
- options.except(*RESERVED_OPTIONS).merge!(:value => value)
+ options.except(*RESERVED_OPTIONS).merge!(value: value)
end
end
@@ -159,9 +159,9 @@ def _parse_validates_options(options) # :nodoc:
when Hash
options
when Range, Array
- { :in => options }
+ { in: options }
else
- { :with => options }
+ { with: options }
end
end
end
@@ -10,7 +10,7 @@ class << self
end
def attributes
- { :foo => 'value of foo', :baz => 'value of baz' }
+ { foo: 'value of foo', baz: 'value of baz' }
end
private
@@ -80,7 +80,7 @@ class ModelWithRubyKeywordNamedAttributes
include ActiveModel::AttributeMethods
def attributes
- { :begin => 'value of begin', :end => 'value of end' }
+ { begin: 'value of begin', end: 'value of end' }
end
private
@@ -15,9 +15,9 @@ class ModelCallbacks
extend ActiveModel::Callbacks
define_model_callbacks :create
- define_model_callbacks :initialize, :only => :after
- define_model_callbacks :multiple, :only => [:before, :around]
- define_model_callbacks :empty, :only => []
+ define_model_callbacks :initialize, only: :after
+ define_model_callbacks :multiple, only: [:before, :around]
+ define_model_callbacks :empty, only: []
before_create :before_create
around_create CallbackValidator.new
@@ -13,15 +13,15 @@ class ConversionTest < ActiveModel::TestCase
end
test "to_key default implementation returns the id in an array for persisted records" do
- assert_equal [1], Contact.new(:id => 1).to_key
+ assert_equal [1], Contact.new(id: 1).to_key
end
test "to_param default implementation returns nil for new records" do
assert_nil Contact.new.to_param
end
test "to_param default implementation returns a string of ids for persisted records" do
- assert_equal "1", Contact.new(:id => 1).to_param
+ assert_equal "1", Contact.new(id: 1).to_param
end
test "to_partial_path default implementation returns a string giving a relative path" do
@@ -271,8 +271,8 @@ def test_has_key?
test "add_on_empty generates message with custom default message" do
person = Person.new
- person.errors.expects(:generate_message).with(:name, :empty, {:message => 'custom'})
- person.errors.add_on_empty :name, :message => 'custom'
+ person.errors.expects(:generate_message).with(:name, :empty, { message: 'custom' })
+ person.errors.add_on_empty :name, message: 'custom'
end
test "add_on_empty generates message with empty string value" do
@@ -297,7 +297,7 @@ def test_has_key?
test "add_on_blank generates message with custom default message" do
person = Person.new
- person.errors.expects(:generate_message).with(:name, :blank, {:message => 'custom'})
- person.errors.add_on_blank :name, :message => 'custom'
+ person.errors.expects(:generate_message).with(:name, :blank, { message: 'custom' })
+ person.errors.add_on_blank :name, message: 'custom'
end
end
@@ -13,7 +13,7 @@ def setup
end
def test_initialize_with_params
- object = BasicModel.new(:attr => "value")
+ object = BasicModel.new(attr: "value")
assert_equal object.attr, "value"
end
@@ -26,7 +26,7 @@ def test_initialize_with_nil_or_empty_hash_params_does_not_explode
end
def test_persisted_is_always_false
- object = BasicModel.new(:attr => "value")
+ object = BasicModel.new(attr: "value")
assert object.persisted? == false
end
end
Oops, something went wrong. Retry.

0 comments on commit 46fc393

Please sign in to comment.