mongoid-embedded-errors 3.0.1 → 4.0.0

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: 129c9a68d1921837c6cd5942d64272049bbc8fd8f756c29b0a825faa4c1d1527
4
- data.tar.gz: 57c35bcc8813866051d60d5139e5901169b8478ce4d5be291e862e0bb0604e17
3
+ metadata.gz: 5a086d5eabe3e2746bbf05833787ee55f8e4b838f666e3aea1c5780e860aa58c
4
+ data.tar.gz: 1f8a09d1d856795631b53f6cbfe1bf832f385a350ff9e8a4e6f7cc0f4c0815c5
5
5
  SHA512:
6
- metadata.gz: 857c87ef479cc4eb0ea15462f9c6386d2eff11987d0a0f895bc3429f14ffd9242fcbce2292bb7de04f2588481fa76bbdc1d0d9874bd2b6a4bcffc02b5149f22a
7
- data.tar.gz: 3935c4a3d82f9e343b21f2272c05d4e8cf642191d79be7b89e82116220c76ba73b56b1e24885824e5fe6c9f17312a4f083cf2714a8356cb2768c0f1b4b57b488
6
+ metadata.gz: 9a6735fbef90d1143c2e724cdc2d33d669e6c829425e7ca4e1f548e2b7b11db5f817d1579cf1a6ba308c1758e628e70afc53865a3b35e84cbe2b3efee42d83cf
7
+ data.tar.gz: 7828bf072974db784c32622002c80650f0debb0858c10f4749906e77cb1ce5daa7658f483614b51b683e66db6f62c5334b4b322282eea247ff481e1ee3976422
data/Appraisals CHANGED
@@ -1,15 +1,7 @@
1
- appraise 'mongoid-4' do
2
- gem 'mongoid', '~> 4.0'
3
- end
4
-
5
- appraise 'mongoid-5' do
6
- gem 'mongoid', '~> 5.0'
7
- end
8
-
9
- appraise 'mongoid-6' do
10
- gem 'mongoid', '~> 6.0'
11
- end
12
-
13
1
  appraise 'mongoid-7' do
14
2
  gem 'mongoid', '~> 7.0'
15
3
  end
4
+
5
+ appraise 'mongoid-8' do
6
+ gem 'mongoid', '~> 8.0'
7
+ end
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  ## [Unreleased]
7
7
  - TODO
8
8
 
9
+ ## [v4.0.0] - 2022-08-31
10
+ - Fix rails 6 active model error deprecations (#22)
11
+ - Added Mongoid 8 support
12
+ - Dropped support for Mongoid 4, 5 and 6
13
+
9
14
  ## [v3.0.1] - 2020-09-29
10
15
  ### Added
11
16
  - Started 🔎 tracking changes in a changelog!
@@ -22,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
22
27
  ## [v3.0.0] - 2020-09-29 [YANKED]
23
28
  - Yanked due to wrong dependencies in gemspec.
24
29
 
25
- [Unreleased]: https://github.com/glooko/mongoid-embedded-errors/compare/v3.0.1...HEAD
30
+ [Unreleased]: https://github.com/glooko/mongoid-embedded-errors/compare/v4.0.0...HEAD
31
+ [v4.0.0]: https://github.com/glooko/mongoid-embedded-errors/compare/v3.0.1...v4.0.0
26
32
  [v3.0.1]: https://github.com/glooko/mongoid-embedded-errors/compare/v3.0.0...v3.0.1
27
- [v3.0.0]: https://github.com/glooko/mongoid-embedded-errors/compare/f1ce0d8ed140de86c894b2fad7ad197504fefd5a...v3.0.0
33
+ [v3.0.0]: https://github.com/glooko/mongoid-embedded-errors/compare/f1ce0d8ed140de86c894b2fad7ad197504fefd5a...v3.0.0
data/Gemfile CHANGED
@@ -4,10 +4,13 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development do
7
+ gem 'rake'
8
+ end
9
+
10
+ group :test do
7
11
  gem 'appraisal'
8
- gem 'database_cleaner'
12
+ gem 'database_cleaner-mongoid', '~> 2.0', '>= 2.0.1'
9
13
  gem 'guard-rspec'
10
14
  gem 'mutant-rspec'
11
- gem 'rake'
12
15
  gem 'rspec'
13
16
  end
@@ -5,11 +5,14 @@ source "https://rubygems.org"
5
5
  gem "mongoid", "~> 7.0"
6
6
 
7
7
  group :development do
8
+ gem "rake"
9
+ end
10
+
11
+ group :test do
8
12
  gem "appraisal"
9
- gem "database_cleaner"
13
+ gem "database_cleaner-mongoid", "~> 2.0", ">= 2.0.1"
10
14
  gem "guard-rspec"
11
15
  gem "mutant-rspec"
12
- gem "rake"
13
16
  gem "rspec"
14
17
  end
15
18
 
@@ -0,0 +1,19 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "mongoid", "~> 8.0"
6
+
7
+ group :development do
8
+ gem "rake"
9
+ end
10
+
11
+ group :test do
12
+ gem "appraisal"
13
+ gem "database_cleaner-mongoid", "~> 2.0", ">= 2.0.1"
14
+ gem "guard-rspec"
15
+ gem "mutant-rspec"
16
+ gem "rspec"
17
+ end
18
+
19
+ gemspec path: "../"
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mongoid; end
4
4
  module Mongoid::EmbeddedErrors
5
- VERSION = '3.0.1'
5
+ VERSION = '4.0.0'
6
6
  end
@@ -19,8 +19,8 @@ module Mongoid::EmbeddedErrors
19
19
  # if there is an 'is invalid' message for the relation then let's work it:
20
20
  next unless Array(public_send(name)).any? { |doc| doc.errors.any? }
21
21
 
22
- # first delete the unless 'is invalid' error for the relation
23
- errs[name].delete 'is invalid'
22
+ # first delete the generic 'is invalid' error for the relation
23
+ errs.delete name.to_sym, :invalid
24
24
  errs.delete name.to_sym if errs[name].empty?
25
25
 
26
26
  # next, loop through each of the relations (pages, sections, etc...)
@@ -28,19 +28,21 @@ module Mongoid::EmbeddedErrors
28
28
  next unless rel.errors.any?
29
29
 
30
30
  # get each of their individual message and add them to the parent's errors:
31
- rel.errors.each do |k, v|
31
+ rel.errors.each do |error|
32
+ attribute = error.attribute
33
+ message = error.message
32
34
  relation = if Gem::Version.new(Mongoid::VERSION) >= Gem::Version.new('7.0.0')
33
35
  metadata.class
34
36
  else
35
37
  metadata.relation
36
38
  end
37
39
  key = if relation.equal? EMBEDS_MANY
38
- "#{name}[#{i}].#{k}"
40
+ "#{name}[#{i}].#{attribute}"
39
41
  else
40
- "#{name}.#{k}"
42
+ "#{name}.#{attribute}"
41
43
  end.to_sym
42
44
  errs.delete(key)
43
- errs.add key, v if v.present?
45
+ errs.add key, message if message.present?
44
46
  end
45
47
  end
46
48
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26
26
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
27
27
  gem.require_paths = ['lib']
28
28
 
29
- gem.add_dependency 'mongoid', '>=4.0', '<8.0.0'
29
+ gem.add_dependency 'mongoid', '>=7.0', '<9.0.0'
30
30
  gem.add_development_dependency 'rubocop', '~> 0.92'
31
31
  gem.add_development_dependency 'rubocop-rspec', '~> 1.43'
32
32
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'mongoid-embedded-errors'
5
- require 'database_cleaner'
5
+ require 'database_cleaner-mongoid'
6
6
 
7
7
  current_path = File.dirname(__FILE__)
8
8
  SPEC_MODELS_PATH = File.join(current_path, 'support/**/*.rb').freeze
@@ -25,14 +25,6 @@ RSpec.configure do |config|
25
25
  end
26
26
  config.disable_monkey_patching!
27
27
 
28
- config.before(:suite) do
29
- DatabaseCleaner.strategy = :truncation
30
- end
31
-
32
- config.around do |example|
33
- DatabaseCleaner.cleaning { example.run }
34
- end
35
-
36
28
  config.before do
37
29
  # Need to manually reload spec models for mutant to work as expected
38
30
  if ENV['MUTANT']
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ DatabaseCleaner.strategy = :deletion
5
+ config.around do |example|
6
+ DatabaseCleaner.cleaning do
7
+ example.run
8
+ end
9
+ end
10
+
11
+ config.before(:all) do
12
+ DatabaseCleaner.start
13
+ end
14
+
15
+ config.after(:all) do
16
+ DatabaseCleaner.clean
17
+ end
18
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-embedded-errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Bates
8
8
  - Kristijan Novoselić
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-29 00:00:00.000000000 Z
12
+ date: 2022-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongoid
@@ -17,20 +17,20 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '4.0'
20
+ version: '7.0'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: 8.0.0
23
+ version: 9.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '4.0'
30
+ version: '7.0'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: 8.0.0
33
+ version: 9.0.0
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rubocop
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,7 @@ files:
88
88
  - gemfiles/mongoid_5.gemfile
89
89
  - gemfiles/mongoid_6.gemfile
90
90
  - gemfiles/mongoid_7.gemfile
91
+ - gemfiles/mongoid_8.gemfile
91
92
  - lib/mongoid-embedded-errors.rb
92
93
  - lib/mongoid/embedded_errors.rb
93
94
  - lib/mongoid/embedded_errors/embedded_in.rb
@@ -95,6 +96,7 @@ files:
95
96
  - mongoid-embedded-errors.gemspec
96
97
  - spec/lib/mongoid/embedded_errors_spec.rb
97
98
  - spec/spec_helper.rb
99
+ - spec/support/database_cleaner.rb
98
100
  - spec/support/models/annotation.rb
99
101
  - spec/support/models/article.rb
100
102
  - spec/support/models/page.rb
@@ -104,7 +106,7 @@ homepage: https://github.com/glooko/mongoid-embedded-errors
104
106
  licenses:
105
107
  - MIT
106
108
  metadata: {}
107
- post_install_message:
109
+ post_install_message:
108
110
  rdoc_options: []
109
111
  require_paths:
110
112
  - lib
@@ -119,13 +121,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
121
  - !ruby/object:Gem::Version
120
122
  version: '0'
121
123
  requirements: []
122
- rubygems_version: 3.1.4
123
- signing_key:
124
+ rubygems_version: 3.1.6
125
+ signing_key:
124
126
  specification_version: 4
125
127
  summary: Easily bubble up errors from embedded documents in Mongoid.
126
128
  test_files:
127
129
  - spec/lib/mongoid/embedded_errors_spec.rb
128
130
  - spec/spec_helper.rb
131
+ - spec/support/database_cleaner.rb
129
132
  - spec/support/models/annotation.rb
130
133
  - spec/support/models/article.rb
131
134
  - spec/support/models/page.rb