mongoid-suicide 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ruby.yml +22 -0
- data/.rubocop.yml +16 -0
- data/.ruby-version +1 -0
- data/Gemfile +7 -2
- data/LICENSE.txt +1 -1
- data/README.md +4 -14
- data/lib/mongoid/suicide/version.rb +3 -1
- data/lib/mongoid/suicide.rb +29 -23
- data/lib/mongoid-suicide.rb +3 -1
- data/mongoid-suicide.gemspec +14 -13
- data/mongoid-suicide.png +0 -0
- data/spec/app/models/person.rb +3 -1
- data/spec/mongoid_suicide_spec.rb +106 -116
- data/spec/spec_helper.rb +6 -4
- metadata +18 -46
- data/.travis.yml +0 -12
- data/Rakefile +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0de82582e718f5ba52268b35d7ae6814d21394cf4a4f1ab89b00c9a45fddbd86
|
4
|
+
data.tar.gz: b381bca8cdf0bc0737558a7435dbe2fc33600938cfcedc1a0e1c3272b31615a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d38119b04995842165181787886e950843adeaf0285d5636291521937965e1b2008a8572642377a5a7a162bb6c18298aa7abe5133075071f5d0da894093ba56c
|
7
|
+
data.tar.gz: 4f7a3ce4e8b637510b9579e6fb7e42fee970dcba30e8724999db7f380bb68a95f63fa151a57d4f272a90a5f2fb3f1382089bc6665f77f09e311715278a6b07c4
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "daily"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [2.7, 3.0, 3.1, 3.2, head, jruby, jruby-head]
|
11
|
+
os: [ubuntu-latest, macos-latest]
|
12
|
+
runs-on: ${{ matrix.os }}
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@master
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
- name: Install dependencies
|
20
|
+
run: bundle install
|
21
|
+
- name: Run test
|
22
|
+
run: rspec
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 2.7
|
4
|
+
Layout/LineLength:
|
5
|
+
Max: 120
|
6
|
+
Metrics/MethodLength:
|
7
|
+
Enabled: false
|
8
|
+
Metrics/ModuleLength:
|
9
|
+
Enabled: false
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Enabled: false
|
12
|
+
Metrics/AbcSize:
|
13
|
+
Enabled: false
|
14
|
+
Naming/FileName:
|
15
|
+
Exclude:
|
16
|
+
- 'lib/mongoid-suicide.rb'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/Gemfile
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in mongoid-suicide.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
|
-
gem 'rake'
|
7
8
|
gem 'mongoid'
|
8
9
|
|
10
|
+
group :development do
|
11
|
+
gem 'rubocop', require: false
|
12
|
+
end
|
13
|
+
|
9
14
|
group :test do
|
10
|
-
gem 'rspec'
|
15
|
+
gem 'rspec'
|
11
16
|
end
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
|
1
|
+
![Mongoid::Suicide Logo](https://raw.github.com/mamantoha/mongoid-suicide/master/mongoid-suicide.png)
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![Gem Version]
|
5
|
-
[![Code Climate][codeclimate_badge]][codeclimate]
|
3
|
+
[![Ruby](https://github.com/mamantoha/mongoid-suicide/actions/workflows/ruby.yml/badge.svg)](https://github.com/mamantoha/mongoid-suicide/actions/workflows/ruby.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/mongoid-suicide.svg)](https://badge.fury.io/rb/mongoid-suicide)
|
6
5
|
|
7
6
|
Provides methods to remove fields from Mongoid models
|
8
7
|
|
@@ -61,13 +60,4 @@ p.username
|
|
61
60
|
|
62
61
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
63
62
|
|
64
|
-
Copyright (c) 2015-
|
65
|
-
|
66
|
-
[travis_badge]: http://img.shields.io/travis/mamantoha/mongoid-suicide.svg?style=flat
|
67
|
-
[travis]: https://travis-ci.org/mamantoha/mongoid-suicide
|
68
|
-
|
69
|
-
[rubygems_badge]: http://img.shields.io/gem/v/mongoid-suicide.svg?style=flat
|
70
|
-
[rubygems]: http://rubygems.org/gems/mongoid-suicide
|
71
|
-
|
72
|
-
[codeclimate_badge]: http://img.shields.io/codeclimate/github/mamantoha/mongoid-suicide.svg?style=flat
|
73
|
-
[codeclimate]: https://codeclimate.com/github/mamantoha/mongoid-suicide
|
63
|
+
Copyright (c) 2015-2023 by Anton Maminov
|
data/lib/mongoid/suicide.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mongoid'
|
2
|
-
require
|
4
|
+
require 'mongoid/suicide/version'
|
3
5
|
|
6
|
+
# :nodoc:
|
4
7
|
module Mongoid
|
5
|
-
|
6
8
|
# This module allows remove fields.
|
7
9
|
module Suicide
|
8
10
|
extend ActiveSupport::Concern
|
9
11
|
|
12
|
+
# :nodoc:
|
10
13
|
module ClassMethods
|
11
14
|
# Removes the field from the Document.
|
12
15
|
# A getter and setter will be removed.
|
@@ -19,22 +22,23 @@ module Mongoid
|
|
19
22
|
# @return [ Field ] The removed field
|
20
23
|
def remove_field(name)
|
21
24
|
name = name.to_s
|
22
|
-
if fields[name]
|
23
|
-
aliased = fields[name].options[:as]
|
24
25
|
|
25
|
-
|
26
|
-
remove_accessors(name, aliased) if aliased
|
27
|
-
remove_dirty_methods(name, name)
|
28
|
-
remove_dirty_methods(name, aliased) if aliased
|
26
|
+
return unless fields[name]
|
29
27
|
|
30
|
-
|
28
|
+
aliased = fields[name].options[:as]
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
remove_accessors(name, name)
|
31
|
+
remove_accessors(name, aliased) if aliased
|
32
|
+
remove_dirty_methods(name)
|
33
|
+
remove_dirty_methods(aliased) if aliased
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
remove_defaults(name)
|
36
|
+
|
37
|
+
remove_field_in_descendants(name)
|
38
|
+
remove_validations_for(name)
|
39
|
+
|
40
|
+
aliased_fields.delete(aliased.to_s) if aliased
|
41
|
+
fields.delete(name)
|
38
42
|
end
|
39
43
|
|
40
44
|
# Remove the field accessors.
|
@@ -60,11 +64,11 @@ module Mongoid
|
|
60
64
|
remove_field_setter(meth)
|
61
65
|
remove_field_check(meth)
|
62
66
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
return unless field.options[:localize]
|
68
|
+
|
69
|
+
remove_translations_getter(meth)
|
70
|
+
remove_translations_setter(meth)
|
71
|
+
localized_fields.delete(name)
|
68
72
|
end
|
69
73
|
|
70
74
|
# Removes the dirty change methods.
|
@@ -81,7 +85,7 @@ module Mongoid
|
|
81
85
|
#
|
82
86
|
# @param [ Symbol ] name The attribute name.
|
83
87
|
# @param [ String ] meth The name of the accessor.
|
84
|
-
def remove_dirty_methods(
|
88
|
+
def remove_dirty_methods(meth)
|
85
89
|
remove_dirty_change_accessor(meth)
|
86
90
|
remove_dirty_change_check(meth)
|
87
91
|
remove_dirty_change_flag(meth)
|
@@ -108,7 +112,7 @@ module Mongoid
|
|
108
112
|
name = name.to_sym
|
109
113
|
a_name = [name]
|
110
114
|
|
111
|
-
_validators.reject!{ |key, _| key == name }
|
115
|
+
_validators.reject! { |key, _| key == name }
|
112
116
|
remove_validate_callbacks a_name
|
113
117
|
end
|
114
118
|
|
@@ -120,12 +124,14 @@ module Mongoid
|
|
120
124
|
# @param [ Array<Symbol> ] a_name The attribute name.
|
121
125
|
def remove_validate_callbacks(a_name)
|
122
126
|
chain = _validate_callbacks.dup.reject do |callback|
|
123
|
-
f = callback.
|
127
|
+
f = callback.filter
|
124
128
|
f.respond_to?(:attributes) && f.attributes == a_name
|
125
129
|
end
|
130
|
+
|
126
131
|
reset_callbacks(:validate)
|
132
|
+
|
127
133
|
chain.each do |callback|
|
128
|
-
set_callback 'validate', callback.
|
134
|
+
set_callback 'validate', callback.filter
|
129
135
|
end
|
130
136
|
end
|
131
137
|
|
data/lib/mongoid-suicide.rb
CHANGED
data/mongoid-suicide.gemspec
CHANGED
@@ -1,23 +1,24 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'mongoid/suicide/version'
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
8
|
+
spec.name = 'mongoid-suicide'
|
7
9
|
spec.version = Mongoid::Suicide::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
-
spec.summary =
|
11
|
-
spec.description =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
10
|
+
spec.authors = ['Anton Maminov']
|
11
|
+
spec.email = ['anton.linux@gmail.com']
|
12
|
+
spec.summary = 'Hacks to support Mongoid remove field'
|
13
|
+
spec.description = 'Hacks to support Mongoid remove field. Including associations and validations'
|
14
|
+
spec.homepage = 'https://github.com/mamantoha/mongoid-suicide'
|
15
|
+
spec.license = 'MIT'
|
14
16
|
|
15
17
|
spec.files = `git ls-files -z`.split("\x0")
|
16
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
-
spec.
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
+
spec.require_paths = ['lib']
|
19
20
|
|
20
|
-
spec.
|
21
|
-
spec.
|
22
|
-
spec.
|
21
|
+
spec.required_ruby_version = '>= 2.7.0'
|
22
|
+
spec.add_dependency 'mongoid', ['> 4.0', '< 9.0']
|
23
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
23
24
|
end
|
data/mongoid-suicide.png
ADDED
Binary file
|
data/spec/app/models/person.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Mongoid::Suicide do
|
4
|
-
describe
|
5
|
-
context
|
6
|
-
|
6
|
+
describe '#remove_field' do
|
7
|
+
context 'remove accessors' do
|
7
8
|
before do
|
8
9
|
Person.field(:remove_testing, type: String)
|
9
10
|
end
|
@@ -16,37 +17,36 @@ describe Mongoid::Suicide do
|
|
16
17
|
Person.remove_field(:remove_testing)
|
17
18
|
end
|
18
19
|
|
19
|
-
it
|
20
|
-
expect
|
20
|
+
it 'removes field getter' do
|
21
|
+
expect do
|
21
22
|
person.remove_testing
|
22
|
-
|
23
|
+
end.to raise_error(NoMethodError)
|
23
24
|
end
|
24
25
|
|
25
|
-
it
|
26
|
-
expect
|
26
|
+
it 'removes field setter' do
|
27
|
+
expect do
|
27
28
|
person.remove_testing = 'test'
|
28
|
-
|
29
|
+
end.to raise_error(NoMethodError)
|
29
30
|
end
|
30
31
|
|
31
|
-
it
|
32
|
-
expect
|
32
|
+
it 'removes field _before_type_cast getter' do
|
33
|
+
expect do
|
33
34
|
person.remove_testing_before_type_cast
|
34
|
-
|
35
|
+
end.to raise_error(NoMethodError)
|
35
36
|
end
|
36
37
|
|
37
|
-
it
|
38
|
-
expect
|
38
|
+
it 'removes field check method' do
|
39
|
+
expect do
|
39
40
|
person.remove_testing?
|
40
|
-
|
41
|
+
end.to raise_error(NoMethodError)
|
41
42
|
end
|
42
43
|
|
43
|
-
it
|
44
|
-
expect(Person.fields).to_not include(
|
44
|
+
it 'removes field from fields' do
|
45
|
+
expect(Person.fields).to_not include('remove_testing')
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
context
|
49
|
-
|
49
|
+
context 'remove accessors for aliasing field' do
|
50
50
|
before do
|
51
51
|
Person.field(:remove_testing, type: String, as: :rt)
|
52
52
|
end
|
@@ -59,38 +59,36 @@ describe Mongoid::Suicide do
|
|
59
59
|
Person.remove_field(:remove_testing)
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
expect
|
62
|
+
it 'removes field getter' do
|
63
|
+
expect do
|
64
64
|
person.rt
|
65
|
-
|
65
|
+
end.to raise_error(NoMethodError)
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
expect
|
68
|
+
it 'removes field setter' do
|
69
|
+
expect do
|
70
70
|
person.rt = 'test'
|
71
|
-
|
71
|
+
end.to raise_error(NoMethodError)
|
72
72
|
end
|
73
73
|
|
74
|
-
it
|
75
|
-
expect
|
74
|
+
it 'removes field _before_type_cast getter' do
|
75
|
+
expect do
|
76
76
|
person.rt_before_type_cast
|
77
|
-
|
77
|
+
end.to raise_error(NoMethodError)
|
78
78
|
end
|
79
79
|
|
80
|
-
it
|
81
|
-
expect
|
80
|
+
it 'removes field check method' do
|
81
|
+
expect do
|
82
82
|
person.rt?
|
83
|
-
|
83
|
+
end.to raise_error(NoMethodError)
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
87
|
-
expect(Person.aliased_fields).to_not include(
|
86
|
+
it 'removes field from aliased_fields' do
|
87
|
+
expect(Person.aliased_fields).to_not include('rt')
|
88
88
|
end
|
89
|
-
|
90
89
|
end
|
91
90
|
|
92
|
-
context
|
93
|
-
|
91
|
+
context 'remove translations' do
|
94
92
|
before do
|
95
93
|
Person.field(:remove_testing, type: String, localize: true)
|
96
94
|
end
|
@@ -103,38 +101,36 @@ describe Mongoid::Suicide do
|
|
103
101
|
Person.remove_field(:remove_testing)
|
104
102
|
end
|
105
103
|
|
106
|
-
it
|
107
|
-
expect
|
104
|
+
it 'removes field translation getter' do
|
105
|
+
expect do
|
108
106
|
person.remove_testing_translations
|
109
|
-
|
107
|
+
end.to raise_error(NoMethodError)
|
110
108
|
end
|
111
109
|
|
112
|
-
it
|
113
|
-
expect
|
110
|
+
it 'removes field translation setter' do
|
111
|
+
expect do
|
114
112
|
person.remove_testing_translations = { de: 'test' }
|
115
|
-
|
113
|
+
end.to raise_error(NoMethodError)
|
116
114
|
end
|
117
115
|
|
118
|
-
it
|
119
|
-
expect
|
116
|
+
it 'removes field translation getter alias' do
|
117
|
+
expect do
|
120
118
|
person.remove_testing_t
|
121
|
-
|
119
|
+
end.to raise_error(NoMethodError)
|
122
120
|
end
|
123
121
|
|
124
|
-
it
|
125
|
-
expect
|
122
|
+
it 'removes field translation setter alias' do
|
123
|
+
expect do
|
126
124
|
person.remove_testing_t = { de: 'test' }
|
127
|
-
|
125
|
+
end.to raise_error(NoMethodError)
|
128
126
|
end
|
129
127
|
|
130
|
-
it
|
128
|
+
it 'localized_fields should not have removed field' do
|
131
129
|
expect(person.localized_fields).to_not include('remove_testing')
|
132
130
|
end
|
133
|
-
|
134
131
|
end
|
135
132
|
|
136
|
-
context
|
137
|
-
|
133
|
+
context 'remove translations for aliasing field' do
|
138
134
|
before do
|
139
135
|
Person.field(:remove_testing, type: String, localize: true, as: :rt)
|
140
136
|
end
|
@@ -147,34 +143,32 @@ describe Mongoid::Suicide do
|
|
147
143
|
Person.remove_field(:remove_testing)
|
148
144
|
end
|
149
145
|
|
150
|
-
it
|
151
|
-
expect
|
146
|
+
it 'removes field translation getter' do
|
147
|
+
expect do
|
152
148
|
person.rt_translations
|
153
|
-
|
149
|
+
end.to raise_error(NoMethodError)
|
154
150
|
end
|
155
151
|
|
156
|
-
it
|
157
|
-
expect
|
152
|
+
it 'removes field translation setter' do
|
153
|
+
expect do
|
158
154
|
person.rt_translations = { de: 'test' }
|
159
|
-
|
155
|
+
end.to raise_error(NoMethodError)
|
160
156
|
end
|
161
157
|
|
162
|
-
it
|
163
|
-
expect
|
158
|
+
it 'removes field translation getter alias' do
|
159
|
+
expect do
|
164
160
|
person.rt_t
|
165
|
-
|
161
|
+
end.to raise_error(NoMethodError)
|
166
162
|
end
|
167
163
|
|
168
|
-
it
|
169
|
-
expect
|
164
|
+
it 'removes field translation setter alias' do
|
165
|
+
expect do
|
170
166
|
person.rt_t = { de: 'test' }
|
171
|
-
|
167
|
+
end.to raise_error(NoMethodError)
|
172
168
|
end
|
173
|
-
|
174
169
|
end
|
175
170
|
|
176
|
-
context
|
177
|
-
|
171
|
+
context 'remove dirty change methods' do
|
178
172
|
before do
|
179
173
|
Person.field(:remove_testing, type: String)
|
180
174
|
end
|
@@ -187,52 +181,50 @@ describe Mongoid::Suicide do
|
|
187
181
|
Person.remove_field(:remove_testing)
|
188
182
|
end
|
189
183
|
|
190
|
-
it
|
191
|
-
expect
|
184
|
+
it 'removes the dirty change accessor' do
|
185
|
+
expect do
|
192
186
|
person.remove_testing_change
|
193
|
-
|
187
|
+
end.to raise_error(NoMethodError)
|
194
188
|
end
|
195
189
|
|
196
|
-
it
|
197
|
-
expect
|
190
|
+
it 'removes the dirty change check' do
|
191
|
+
expect do
|
198
192
|
person.remove_testing_changed?
|
199
|
-
|
193
|
+
end.to raise_error(NoMethodError)
|
200
194
|
end
|
201
195
|
|
202
|
-
it
|
203
|
-
expect
|
196
|
+
it 'removes the dirty change flag' do
|
197
|
+
expect do
|
204
198
|
person.remove_testing_will_change!
|
205
|
-
|
199
|
+
end.to raise_error(NoMethodError)
|
206
200
|
end
|
207
201
|
|
208
|
-
it
|
209
|
-
expect
|
202
|
+
it 'removes the dirty default change check' do
|
203
|
+
expect do
|
210
204
|
person.remove_testing_changed_from_default?
|
211
|
-
|
205
|
+
end.to raise_error(NoMethodError)
|
212
206
|
end
|
213
207
|
|
214
|
-
it
|
215
|
-
expect
|
208
|
+
it 'removes the dirty change previous value accessor' do
|
209
|
+
expect do
|
216
210
|
person.remove_testing_was
|
217
|
-
|
211
|
+
end.to raise_error(NoMethodError)
|
218
212
|
end
|
219
213
|
|
220
|
-
it
|
221
|
-
expect
|
214
|
+
it 'removes the dirty change reset' do
|
215
|
+
expect do
|
222
216
|
person.reset_remove_testing!
|
223
|
-
|
217
|
+
end.to raise_error(NoMethodError)
|
224
218
|
end
|
225
219
|
|
226
|
-
it
|
227
|
-
expect
|
220
|
+
it 'removes the dirty change reset to default' do
|
221
|
+
expect do
|
228
222
|
person.reset_remove_testing_to_default!
|
229
|
-
|
223
|
+
end.to raise_error(NoMethodError)
|
230
224
|
end
|
231
|
-
|
232
225
|
end
|
233
226
|
|
234
|
-
context
|
235
|
-
|
227
|
+
context 'remove dirty change methods for aliasing field' do
|
236
228
|
before do
|
237
229
|
Person.field(:remove_testing, type: String, as: :rt)
|
238
230
|
end
|
@@ -245,51 +237,50 @@ describe Mongoid::Suicide do
|
|
245
237
|
Person.remove_field(:remove_testing)
|
246
238
|
end
|
247
239
|
|
248
|
-
it
|
249
|
-
expect
|
240
|
+
it 'removes the dirty change accessor' do
|
241
|
+
expect do
|
250
242
|
person.rt_change
|
251
|
-
|
243
|
+
end.to raise_error(NoMethodError)
|
252
244
|
end
|
253
245
|
|
254
|
-
it
|
255
|
-
expect
|
246
|
+
it 'removes the dirty change check' do
|
247
|
+
expect do
|
256
248
|
person.rt_changed?
|
257
|
-
|
249
|
+
end.to raise_error(NoMethodError)
|
258
250
|
end
|
259
251
|
|
260
|
-
it
|
261
|
-
expect
|
252
|
+
it 'removes the dirty change flag' do
|
253
|
+
expect do
|
262
254
|
person.rt_will_change!
|
263
|
-
|
255
|
+
end.to raise_error(NoMethodError)
|
264
256
|
end
|
265
257
|
|
266
|
-
it
|
267
|
-
expect
|
258
|
+
it 'removes the dirty default change check' do
|
259
|
+
expect do
|
268
260
|
person.rt_changed_from_default?
|
269
|
-
|
261
|
+
end.to raise_error(NoMethodError)
|
270
262
|
end
|
271
263
|
|
272
|
-
it
|
273
|
-
expect
|
264
|
+
it 'removes the dirty change previous value accessor' do
|
265
|
+
expect do
|
274
266
|
person.rt_was
|
275
|
-
|
267
|
+
end.to raise_error(NoMethodError)
|
276
268
|
end
|
277
269
|
|
278
|
-
it
|
279
|
-
expect
|
270
|
+
it 'removes the dirty change reset' do
|
271
|
+
expect do
|
280
272
|
person.reset_rt!
|
281
|
-
|
273
|
+
end.to raise_error(NoMethodError)
|
282
274
|
end
|
283
275
|
|
284
|
-
it
|
285
|
-
expect
|
276
|
+
it 'removes the dirty change reset to default' do
|
277
|
+
expect do
|
286
278
|
person.reset_rt_to_default!
|
287
|
-
|
279
|
+
end.to raise_error(NoMethodError)
|
288
280
|
end
|
289
|
-
|
290
281
|
end
|
291
282
|
|
292
|
-
context
|
283
|
+
context 'remove validators' do
|
293
284
|
before do
|
294
285
|
Person.field(:remove_testing, type: String)
|
295
286
|
Person.validates(:remove_testing, uniqueness: true)
|
@@ -299,10 +290,9 @@ describe Mongoid::Suicide do
|
|
299
290
|
Person.remove_field(:remove_testing)
|
300
291
|
end
|
301
292
|
|
302
|
-
it
|
293
|
+
it 'validators should not have removed field' do
|
303
294
|
expect(Person._validators).to_not include(:remove_testing)
|
304
295
|
end
|
305
296
|
end
|
306
297
|
end
|
307
|
-
|
308
298
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
5
|
|
4
|
-
MODELS = File.join(File.dirname(__FILE__),
|
6
|
+
MODELS = File.join(File.dirname(__FILE__), 'app/models')
|
5
7
|
$LOAD_PATH.unshift(MODELS)
|
6
8
|
|
7
9
|
require 'mongoid'
|
@@ -12,7 +14,7 @@ require 'rspec'
|
|
12
14
|
# Mongoid.logger.level = Logger::DEBUG
|
13
15
|
|
14
16
|
# Autoload every model for the test suite that sits in spec/app/models.
|
15
|
-
Dir[
|
16
|
-
name = File.basename(file,
|
17
|
+
Dir[File.join(MODELS, '*.rb')].sort.each do |file|
|
18
|
+
name = File.basename(file, '.rb')
|
17
19
|
autoload name.camelize.to_sym, name
|
18
20
|
end
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-suicide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Maminov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.7'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.7'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
13
|
- !ruby/object:Gem::Dependency
|
42
14
|
name: mongoid
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,8 +19,8 @@ dependencies:
|
|
47
19
|
version: '4.0'
|
48
20
|
- - "<"
|
49
21
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
51
|
-
type: :
|
22
|
+
version: '9.0'
|
23
|
+
type: :runtime
|
52
24
|
prerelease: false
|
53
25
|
version_requirements: !ruby/object:Gem::Requirement
|
54
26
|
requirements:
|
@@ -57,7 +29,7 @@ dependencies:
|
|
57
29
|
version: '4.0'
|
58
30
|
- - "<"
|
59
31
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
32
|
+
version: '9.0'
|
61
33
|
description: Hacks to support Mongoid remove field. Including associations and validations
|
62
34
|
email:
|
63
35
|
- anton.linux@gmail.com
|
@@ -65,25 +37,29 @@ executables: []
|
|
65
37
|
extensions: []
|
66
38
|
extra_rdoc_files: []
|
67
39
|
files:
|
40
|
+
- ".github/dependabot.yml"
|
41
|
+
- ".github/workflows/ruby.yml"
|
68
42
|
- ".gitignore"
|
69
43
|
- ".rspec"
|
70
|
-
- ".
|
44
|
+
- ".rubocop.yml"
|
45
|
+
- ".ruby-version"
|
71
46
|
- Gemfile
|
72
47
|
- LICENSE.txt
|
73
48
|
- README.md
|
74
|
-
- Rakefile
|
75
49
|
- lib/mongoid-suicide.rb
|
76
50
|
- lib/mongoid/suicide.rb
|
77
51
|
- lib/mongoid/suicide/version.rb
|
78
52
|
- mongoid-suicide.gemspec
|
53
|
+
- mongoid-suicide.png
|
79
54
|
- spec/app/models/person.rb
|
80
55
|
- spec/mongoid_suicide_spec.rb
|
81
56
|
- spec/spec_helper.rb
|
82
57
|
homepage: https://github.com/mamantoha/mongoid-suicide
|
83
58
|
licenses:
|
84
59
|
- MIT
|
85
|
-
metadata:
|
86
|
-
|
60
|
+
metadata:
|
61
|
+
rubygems_mfa_required: 'true'
|
62
|
+
post_install_message:
|
87
63
|
rdoc_options: []
|
88
64
|
require_paths:
|
89
65
|
- lib
|
@@ -91,19 +67,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
67
|
requirements:
|
92
68
|
- - ">="
|
93
69
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
70
|
+
version: 2.7.0
|
95
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
72
|
requirements:
|
97
73
|
- - ">="
|
98
74
|
- !ruby/object:Gem::Version
|
99
75
|
version: '0'
|
100
76
|
requirements: []
|
101
|
-
|
102
|
-
|
103
|
-
signing_key:
|
77
|
+
rubygems_version: 3.4.14
|
78
|
+
signing_key:
|
104
79
|
specification_version: 4
|
105
80
|
summary: Hacks to support Mongoid remove field
|
106
|
-
test_files:
|
107
|
-
- spec/app/models/person.rb
|
108
|
-
- spec/mongoid_suicide_spec.rb
|
109
|
-
- spec/spec_helper.rb
|
81
|
+
test_files: []
|
data/.travis.yml
DELETED
data/Rakefile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
require "bundler"
|
4
|
-
Bundler.setup
|
5
|
-
|
6
|
-
require "rake"
|
7
|
-
require "rspec/core/rake_task"
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
10
|
-
require "mongoid/suicide/version"
|
11
|
-
|
12
|
-
task :gem => :build
|
13
|
-
task :build do
|
14
|
-
system "gem build mongoid-suicide.gemspec"
|
15
|
-
end
|
16
|
-
|
17
|
-
task :install => :build do
|
18
|
-
system "gem install mongoid-suicide-#{Mongoid::VERSION}.gem"
|
19
|
-
end
|
20
|
-
|
21
|
-
task :release => :build do
|
22
|
-
system "git tag -a v#{Mongoid::Suicide::VERSION} -m 'Tagging #{Mongoid::Suicide::VERSION}'"
|
23
|
-
system "git push --tags"
|
24
|
-
system "gem push mongoid-#{Mongoid::Suicide::VERSION}.gem"
|
25
|
-
system "rm mongoid-#{Mongoid::Suicide::VERSION}.gem"
|
26
|
-
end
|
27
|
-
|
28
|
-
RSpec::Core::RakeTask.new("spec") do |spec|
|
29
|
-
spec.pattern = "spec/**/*_spec.rb"
|
30
|
-
end
|
31
|
-
|
32
|
-
RSpec::Core::RakeTask.new('spec:progress') do |spec|
|
33
|
-
spec.rspec_opts = %w(--format progress)
|
34
|
-
spec.pattern = "spec/**/*_spec.rb"
|
35
|
-
end
|
36
|
-
|
37
|
-
task :default => :spec
|