Skip to content

Commit 46fc393

Browse files
committed
Merge branch 'master' into inflector-with-lru-cache
2 parents b8ad411 + a6a8415 commit 46fc393

File tree

68 files changed

+599
-495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+599
-495
lines changed

actionpack/lib/action_dispatch/http/parameters.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def normalize_encode_params(params)
6565

6666
new_hash = {}
6767
params.each do |k, v|
68-
new_key = k.is_a?(String) ? k.dup.force_encoding("UTF-8").encode! : k
68+
new_key = k.is_a?(String) ? k.dup.force_encoding(Encoding::UTF_8).encode! : k
6969
new_hash[new_key] =
7070
case v
7171
when Hash

actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
padding: 0.5em 1.5em;
3535
}
3636

37+
h1 {
38+
margin: 0.2em 0;
39+
line-height: 1.1em;
40+
font-size: 2em;
41+
}
42+
3743
h2 {
3844
color: #C52F24;
3945
line-height: 25px;

actionpack/test/dispatch/request/json_params_parsing_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def teardown
5050
output = StringIO.new
5151
json = "[\"person]\": {\"name\": \"David\"}}"
5252
post "/parse", json, {'CONTENT_TYPE' => 'application/json', 'action_dispatch.show_exceptions' => true, 'action_dispatch.logger' => ActiveSupport::Logger.new(output)}
53-
assert_response :error
53+
assert_response :bad_request
5454
output.rewind && err = output.read
5555
assert err =~ /Error occurred while parsing request parameters/
5656
end

activemodel/lib/active_model/attribute_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def instance_method_already_implemented?(method_name) #:nodoc:
343343
# significantly (in our case our test suite finishes 10% faster with
344344
# this cache).
345345
def attribute_method_matchers_cache #:nodoc:
346-
@attribute_method_matchers_cache ||= ThreadSafe::Cache.new(:initial_capacity => 4)
346+
@attribute_method_matchers_cache ||= ThreadSafe::Cache.new(initial_capacity: 4)
347347
end
348348

349349
def attribute_method_matcher(method_name) #:nodoc:

activemodel/lib/active_model/callbacks.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ def self.extended(base) #:nodoc:
100100
def define_model_callbacks(*callbacks)
101101
options = callbacks.extract_options!
102102
options = {
103-
:terminator => "result == false",
104-
:skip_after_callbacks_if_terminated => true,
105-
:scope => [:kind, :name],
106-
:only => [:before, :around, :after]
103+
terminator: "result == false",
104+
skip_after_callbacks_if_terminated: true,
105+
scope: [:kind, :name],
106+
only: [:before, :around, :after]
107107
}.merge!(options)
108108

109109
types = Array(options.delete(:only))

activemodel/lib/active_model/dirty.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module Dirty
9191

9292
included do
9393
attribute_method_suffix '_changed?', '_change', '_will_change!', '_was'
94-
attribute_method_affix :prefix => 'reset_', :suffix => '!'
94+
attribute_method_affix prefix: 'reset_', suffix: '!'
9595
end
9696

9797
# Returns +true+ if any attribute have unsaved changes, +false+ otherwise.

activemodel/lib/active_model/errors.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def empty?
231231
# # <error>name must be specified</error>
232232
# # </errors>
233233
def to_xml(options={})
234-
to_a.to_xml({ :root => "errors", :skip_types => true }.merge!(options))
234+
to_a.to_xml({ root: "errors", skip_types: true }.merge!(options))
235235
end
236236

237237
# Returns a Hash that can be used as the JSON representation for this
@@ -370,11 +370,11 @@ def full_messages_for(attribute)
370370
def full_message(attribute, message)
371371
return message if attribute == :base
372372
attr_name = attribute.to_s.tr('.', '_').humanize
373-
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
373+
attr_name = @base.class.human_attribute_name(attribute, default: attr_name)
374374
I18n.t(:"errors.format", {
375-
:default => "%{attribute} %{message}",
376-
:attribute => attr_name,
377-
:message => message
375+
default: "%{attribute} %{message}",
376+
attribute: attr_name,
377+
message: message
378378
})
379379
end
380380

@@ -426,10 +426,10 @@ def generate_message(attribute, type = :invalid, options = {})
426426
value = (attribute != :base ? @base.send(:read_attribute_for_validation, attribute) : nil)
427427

428428
options = {
429-
:default => defaults,
430-
:model => @base.class.model_name.human,
431-
:attribute => @base.class.human_attribute_name(attribute),
432-
:value => value
429+
default: defaults,
430+
model: @base.class.model_name.human,
431+
attribute: @base.class.human_attribute_name(attribute),
432+
value: value
433433
}.merge!(options)
434434

435435
I18n.translate(key, options)

activemodel/lib/active_model/naming.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Name
129129
#
130130
# Equivalent to +to_s+.
131131
delegate :==, :===, :<=>, :=~, :"!~", :eql?, :to_s,
132-
:to_str, :to => :name
132+
:to_str, to: :name
133133

134134
# Returns a new ActiveModel::Name instance. By default, the +namespace+
135135
# and +name+ option will take the namespace and name of the given class
@@ -183,7 +183,7 @@ def human(options={})
183183
defaults << options[:default] if options[:default]
184184
defaults << @human
185185

186-
options = { :scope => [@klass.i18n_scope, :models], :count => 1, :default => defaults }.merge!(options.except(:default))
186+
options = { scope: [@klass.i18n_scope, :models], count: 1, default: defaults }.merge!(options.except(:default))
187187
I18n.translate(defaults.shift, options)
188188
end
189189

activemodel/lib/active_model/secure_password.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def has_secure_password(options = {})
5757

5858
if options.fetch(:validations, true)
5959
validates_confirmation_of :password
60-
validates_presence_of :password, :on => :create
60+
validates_presence_of :password, on: :create
6161

6262
before_create { raise "Password digest missing on new record" if password_digest.blank? }
6363
end

activemodel/lib/active_model/serializers/xml.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def serialize
7979
require 'builder' unless defined? ::Builder
8080

8181
options[:indent] ||= 2
82-
options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent])
82+
options[:builder] ||= ::Builder::XmlMarkup.new(indent: options[:indent])
8383

8484
@builder = options[:builder]
8585
@builder.instruct! unless options[:skip_instruct]
@@ -88,8 +88,8 @@ def serialize
8888
root = ActiveSupport::XmlMini.rename_key(root, options)
8989

9090
args = [root]
91-
args << {:xmlns => options[:namespace]} if options[:namespace]
92-
args << {:type => options[:type]} if options[:type] && !options[:skip_types]
91+
args << { xmlns: options[:namespace] } if options[:namespace]
92+
args << { type: options[:type] } if options[:type] && !options[:skip_types]
9393

9494
@builder.tag!(*args) do
9595
add_attributes_and_methods
@@ -132,7 +132,7 @@ def add_associations(association, records, opts)
132132
records = records.to_ary
133133

134134
tag = ActiveSupport::XmlMini.rename_key(association.to_s, options)
135-
type = options[:skip_types] ? { } : {:type => "array"}
135+
type = options[:skip_types] ? { } : { type: "array" }
136136
association_name = association.to_s.singularize
137137
merged_options[:root] = association_name
138138

@@ -145,7 +145,7 @@ def add_associations(association, records, opts)
145145
record_type = {}
146146
else
147147
record_class = (record.class.to_s.underscore == association_name) ? nil : record.class.name
148-
record_type = {:type => record_class}
148+
record_type = { type: record_class }
149149
end
150150

151151
record.to_xml merged_options.merge(record_type)

0 commit comments

Comments
 (0)