mini_form 0.2.3 → 0.2.4

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
- SHA1:
3
- metadata.gz: af66d71eb698d18223627223fcdd23773c8c44ed
4
- data.tar.gz: b230cebf0fca7e3287487ab88c3eeae7b8e98063
2
+ SHA256:
3
+ metadata.gz: 4fae1bbe2eb9f254e0315e13364a0d9a19a87515061f066a37fd89689be9c657
4
+ data.tar.gz: 34c5ac1537cf058c0c67cdaa7ef4c88dd7aaaef63412cbabddbad5e13be73435
5
5
  SHA512:
6
- metadata.gz: b6487e2c427e3e427b140d71830f8a54cc180d4a2db00dce7d414171f729aea38a261c400c5487804fa972a4f13d42ee21312c88fc191c324ed6bff3833f568c
7
- data.tar.gz: 645b04ee90f9514b74af2e0fecf2cf83f9a15ecd33be71e3849209f4023424f33ac39acad741992cacad0ea19834490f3d12756e78db3c2a05514472a20cb9f3
6
+ metadata.gz: ada501cc629ff6fd8701162248d095868bf2a7a9ac0e7e23f74caae5d08d1f8cbd31d9202fd47f52283cbb3117cd8c0d1a2705b9c074a09a6c95cb622ac2e4ee
7
+ data.tar.gz: 8cb38e2bf06594be100078b2d2b0ee10c4d5a356808ba4249fc2f63f060478619c97dc8d776004d20c5f52cb2b1dfef5b93099ca9307379c7921006a40bfa0ee
data/CHANGELOG.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## Version 0.2.3
3
+ ## Version 0.2.4
4
+
5
+ * Rails 6+ support (@emilov)
4
6
 
7
+ ## Version 0.2.3
5
8
 
6
9
  * Fix handling delegated attributes prefixes in `attribute_names` (@rstankov)
7
10
 
@@ -5,7 +5,8 @@ module MiniForm
5
5
  def initialize(object)
6
6
  @errors = object.errors
7
7
 
8
- super "Form validation failed for: #{errors.keys.join(', ')}"
8
+ arr_obj = errors.respond_to?(:attribute_names) ? errors.attribute_names : errors.keys
9
+ super "Form validation failed for: #{arr_obj.join(', ')}"
9
10
  end
10
11
  end
11
12
  end
@@ -5,6 +5,15 @@ module MiniForm
5
5
  def validate_each(record, _, relation)
6
6
  return if relation.valid?
7
7
 
8
+ if record.errors.respond_to?(:merge!)
9
+ # Rails 6.1+ where accessing ActiveModel::Errors as a hash has been
10
+ # deprecated and the errors array is frozen. For this reason we use the new
11
+ # method merge!() which appends the errors as NestedErrors to the array. "This is the way."
12
+ record.errors.merge!(relation.errors)
13
+ return
14
+ end
15
+
16
+ # Rails < 6.1
8
17
  relation.errors.each do |name, value|
9
18
  record.errors.add name, value
10
19
  end
@@ -1,3 +1,3 @@
1
1
  module MiniForm
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
data/mini_form.gemspec CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'activemodel', '>= 4.0'
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.3'
24
- spec.add_development_dependency 'rake', '< 11.0'
23
+ spec.add_development_dependency 'bundler', '>= 2.1.4'
24
+ spec.add_development_dependency 'rake', '>= 12.3.3'
25
25
  spec.add_development_dependency 'rspec', '~> 2.14'
26
26
  spec.add_development_dependency 'rspec-mocks', '>= 2.12.3'
27
27
  spec.add_development_dependency 'coveralls'
@@ -51,6 +51,10 @@ module MiniForm
51
51
  expect(value).to eq(expected_value), message
52
52
  end
53
53
 
54
+ def assert_respond_to(klass, method, message = nil)
55
+ expect(klass).to respond_to(method), message
56
+ end
57
+
54
58
  ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |method|
55
59
  example(method.gsub('_', ' ')) { send method }
56
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radoslav Stankov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-08 00:00:00.000000000 Z
11
+ date: 2022-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: 2.1.4
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: 2.1.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "<"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '11.0'
47
+ version: 12.3.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "<"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '11.0'
54
+ version: 12.3.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -152,7 +152,7 @@ homepage: https://github.com/RStankov/MiniForm
152
152
  licenses:
153
153
  - MIT
154
154
  metadata: {}
155
- post_install_message:
155
+ post_install_message:
156
156
  rdoc_options: []
157
157
  require_paths:
158
158
  - lib
@@ -167,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.6.13
172
- signing_key:
170
+ rubygems_version: 3.1.4
171
+ signing_key:
173
172
  specification_version: 4
174
173
  summary: Easy to use form objects in Rails projects
175
174
  test_files: