activemodel 5.2.1.1 → 5.2.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 438f3bd0d6ca0a2a05a7e99d66000d8b0d98a950bb9b9d0b0dfb0844fae7f31b
4
- data.tar.gz: 06d4aa63a3080ed7921ce864b2f298df2515df8a1bbf852fbf014b9679373d15
3
+ metadata.gz: 337a43f3957744aee93260ae4f6fd4ae69f6ee02ce3d6bec715704f328e2e65a
4
+ data.tar.gz: db21100aba18efbf69894d52b19df6a0480d0b540f12e4d2d0f1b016415e4b66
5
5
  SHA512:
6
- metadata.gz: 7be0ecf7935a31d50e9da140c0fc3fc4a237b38f286d43d059fd110291dc77d219bd7d6b7cc43dd50ee1cd1800b18087acb4c486a11ba5c59df82c0f06fc7bdf
7
- data.tar.gz: 65a2bef63659b87ca1af453b1dee8bb7937fef7640660c938b3b75081f73399ecd7d6c3297a7990ae9f182244d2e570a76fa98469926c2c7f053e8d21ef267ac
6
+ metadata.gz: 3620ed5a6213e665798c3c0f3c2685396921f5c5fbafecff19c6e6cffc19acc49df9fc690674da35833c08732f21f6fb109254128f89b0d5c62c512fd3c91cae
7
+ data.tar.gz: 7f9a71461be3a394d7513431e6e67ccf084fc6911cfd737f74457d9278f64773d167d5dde7dce38b2a8fa47d792dbba4718c7e11f48c13cbde7ef1071c22152d
@@ -1,3 +1,12 @@
1
+ ## Rails 5.2.2.rc1 (November 28, 2018) ##
2
+
3
+ * Fix numericality validator to still use value before type cast except Active Record.
4
+
5
+ Fixes #33651, #33686.
6
+
7
+ *Ryuta Kamizono*
8
+
9
+
1
10
  ## Rails 5.2.1.1 (November 27, 2018) ##
2
11
 
3
12
  * No changes.
@@ -207,6 +207,7 @@ module ActiveModel
207
207
  raise ActiveModel::MissingAttributeError, "can't write unknown attribute `#{name}`"
208
208
  end
209
209
  alias_method :with_value_from_user, :with_value_from_database
210
+ alias_method :with_cast_value, :with_value_from_database
210
211
  end
211
212
 
212
213
  class Uninitialized < Attribute # :nodoc:
@@ -141,7 +141,9 @@ module ActiveModel
141
141
  @mutations_from_database = nil
142
142
  end
143
143
 
144
- def changes_applied # :nodoc:
144
+ # Clears dirty data and moves +changes+ to +previously_changed+ and
145
+ # +mutations_from_database+ to +mutations_before_last_save+ respectively.
146
+ def changes_applied
145
147
  unless defined?(@attributes)
146
148
  @previously_changed = changes
147
149
  end
@@ -322,11 +322,11 @@ module ActiveModel
322
322
  # person.errors.added? :name, :too_long # => false
323
323
  # person.errors.added? :name, "is too long" # => false
324
324
  def added?(attribute, message = :invalid, options = {})
325
+ message = message.call if message.respond_to?(:call)
326
+
325
327
  if message.is_a? Symbol
326
- self.details[attribute.to_sym].map { |e| e[:error] }.include? message
328
+ details[attribute.to_sym].include? normalize_detail(message, options)
327
329
  else
328
- message = message.call if message.respond_to?(:call)
329
- message = normalize_message(attribute, message, options)
330
330
  self[attribute].include? message
331
331
  end
332
332
  end
@@ -9,8 +9,8 @@ module ActiveModel
9
9
  module VERSION
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
- TINY = 1
13
- PRE = "1"
12
+ TINY = 2
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -29,7 +29,7 @@ module ActiveModel
29
29
  # 'wibble'.to_i will give zero, we want to make sure
30
30
  # that we aren't marking int zero to string zero as
31
31
  # changed.
32
- value.to_s !~ /\A-?\d+\.?\d*\z/
32
+ !/\A[-+]?\d+/.match?(value.to_s)
33
33
  end
34
34
  end
35
35
  end
@@ -21,8 +21,17 @@ module ActiveModel
21
21
  def validate_each(record, attr_name, value)
22
22
  came_from_user = :"#{attr_name}_came_from_user?"
23
23
 
24
- if record.respond_to?(came_from_user) && record.public_send(came_from_user)
25
- raw_value = record.read_attribute_before_type_cast(attr_name)
24
+ if record.respond_to?(came_from_user)
25
+ if record.public_send(came_from_user)
26
+ raw_value = record.read_attribute_before_type_cast(attr_name)
27
+ elsif record.respond_to?(:read_attribute)
28
+ raw_value = record.read_attribute(attr_name)
29
+ end
30
+ else
31
+ before_type_cast = :"#{attr_name}_before_type_cast"
32
+ if record.respond_to?(before_type_cast)
33
+ raw_value = record.public_send(before_type_cast)
34
+ end
26
35
  end
27
36
  raw_value ||= value
28
37
 
@@ -77,13 +86,17 @@ module ActiveModel
77
86
 
78
87
  def parse_raw_value_as_a_number(raw_value)
79
88
  return raw_value.to_i if is_integer?(raw_value)
80
- Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/
89
+ Kernel.Float(raw_value) unless is_hexadecimal_literal?(raw_value)
81
90
  end
82
91
 
83
92
  def is_integer?(raw_value)
84
93
  /\A[+-]?\d+\z/ === raw_value.to_s
85
94
  end
86
95
 
96
+ def is_hexadecimal_literal?(raw_value)
97
+ /\A0[xX]/ === raw_value
98
+ end
99
+
87
100
  def filtered_options(value)
88
101
  filtered = options.except(*RESERVED_OPTIONS)
89
102
  filtered[:value] = value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1.1
4
+ version: 5.2.2.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-27 00:00:00.000000000 Z
11
+ date: 2018-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.1.1
19
+ version: 5.2.2.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.1.1
26
+ version: 5.2.2.rc1
27
27
  description: A toolkit for building modeling frameworks like Active Record. Rich support
28
28
  for attributes, callbacks, validations, serialization, internationalization, and
29
29
  testing.
@@ -100,8 +100,8 @@ homepage: http://rubyonrails.org
100
100
  licenses:
101
101
  - MIT
102
102
  metadata:
103
- source_code_uri: https://github.com/rails/rails/tree/v5.2.1.1/activemodel
104
- changelog_uri: https://github.com/rails/rails/blob/v5.2.1.1/activemodel/CHANGELOG.md
103
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.2.rc1/activemodel
104
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.2.rc1/activemodel/CHANGELOG.md
105
105
  post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths:
@@ -113,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: 2.2.2
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - ">"
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: 1.3.1
119
119
  requirements: []
120
120
  rubyforge_project:
121
121
  rubygems_version: 2.7.6