activerecord_null_object 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -7
- data/CHANGELOG.md +6 -0
- data/Rakefile +0 -6
- data/activerecord_null_object.gemspec +10 -6
- data/gemfiles/rails52.gemfile +8 -0
- data/gemfiles/rails6.gemfile +8 -0
- data/lib/activerecord_null_object.rb +2 -1
- data/lib/activerecord_null_object/null_object.rb +13 -6
- data/lib/activerecord_null_object/version.rb +3 -0
- data/spec/null_object_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -22
- data/spec/support/coverage_loader.rb +4 -0
- metadata +81 -63
- data/gemfiles/rails3.gemfile +0 -8
- data/gemfiles/rails4.gemfile +0 -8
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9958c234344c27c417e608e7f3506396aac1b0bc1a3ecb6e3369ebcfdb3e5fc5
|
4
|
+
data.tar.gz: 295ae26bb441c3d35a4594b7449ec49e43af26c60d268f6784e09d29110085ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '093de8273997264e1c46e431199511121320374f243691477b869a3214b4905dc84e8f65490a361619094cf6e8750ed42fccd3532c4ff00e8cf77d50dbc4ea8d'
|
7
|
+
data.tar.gz: 8c63330c24586da62fd4ef6e3d546de3d14cd92f1913eac39206212c2de1086afae359e0f4ca304a3867b7a6b8ff6588487fd9e4b0f1bc903f8e4bf91906b337
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.3
|
data/.travis.yml
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
script:
|
3
|
+
- 2.5
|
4
|
+
- 2.6
|
5
|
+
- 2.7
|
6
|
+
script: bundle exec rake spec
|
7
7
|
gemfile:
|
8
|
-
- gemfiles/
|
9
|
-
- gemfiles/
|
8
|
+
- gemfiles/rails52.gemfile
|
9
|
+
- gemfiles/rails6.gemfile
|
10
10
|
notifications:
|
11
11
|
email:
|
12
12
|
- support@travellink.com.au
|
13
|
-
|
13
|
+
sudo: false
|
14
|
+
cache: bundler
|
15
|
+
before_install:
|
16
|
+
- gem update --system
|
17
|
+
- gem install bundler
|
data/CHANGELOG.md
ADDED
data/Rakefile
CHANGED
@@ -10,9 +10,3 @@ RSpec::Core::RakeTask.new do |t|
|
|
10
10
|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
11
11
|
# Put spec opts in a file named .rspec in root
|
12
12
|
end
|
13
|
-
|
14
|
-
desc "Generate SimpleCov test coverage and open in your browser"
|
15
|
-
task :coverage do
|
16
|
-
ENV['COVERAGE'] = 'true'
|
17
|
-
Rake::Task['spec'].invoke
|
18
|
-
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('lib/activerecord_null_object/version', __dir__)
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
4
6
|
spec.name = "activerecord_null_object"
|
5
|
-
spec.version =
|
7
|
+
spec.version = ActiveRecordNullObject::VERSION
|
6
8
|
spec.authors = ["Scott Woods", "Alessandro Berardi"]
|
7
9
|
spec.email = ["support@travellink.com.au"]
|
8
10
|
spec.description = %q{Implements the Null Object Pattern for nil values in ActiveRecord associations.}
|
@@ -16,13 +18,15 @@ Gem::Specification.new do |spec|
|
|
16
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
19
|
spec.require_paths = ["lib"]
|
18
20
|
|
19
|
-
spec.add_runtime_dependency "activesupport", ">=
|
20
|
-
spec.add_runtime_dependency "activerecord", ">=
|
21
|
-
spec.add_development_dependency "bundler", "~>
|
21
|
+
spec.add_runtime_dependency "activesupport", ">= 5.0", "< 7"
|
22
|
+
spec.add_runtime_dependency "activerecord", ">= 5.0", "< 7"
|
23
|
+
spec.add_development_dependency "bundler", "~> 2"
|
22
24
|
spec.add_development_dependency "rake"
|
23
25
|
spec.add_development_dependency "rspec"
|
24
26
|
spec.add_development_dependency "rspec-its"
|
25
|
-
spec.add_development_dependency "
|
27
|
+
spec.add_development_dependency "coverage-kit"
|
28
|
+
spec.add_development_dependency "simplecov-rcov"
|
26
29
|
spec.add_development_dependency "coveralls"
|
27
30
|
spec.add_development_dependency 'sqlite3'
|
31
|
+
spec.add_development_dependency 'travis'
|
28
32
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
|
3
|
+
require 'activerecord_null_object/version'
|
3
4
|
require 'activerecord_null_object/null_object'
|
4
5
|
require 'activerecord_null_object/null_object_support'
|
5
6
|
|
6
|
-
ActiveRecord::Base.send :include, ActiveRecordNullObject::NullObjectSupport
|
7
|
+
ActiveRecord::Base.send :include, ActiveRecordNullObject::NullObjectSupport
|
@@ -8,22 +8,29 @@ module ActiveRecordNullObject
|
|
8
8
|
validate :unsavable
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
def id
|
11
|
+
def id
|
13
12
|
nil
|
14
13
|
end
|
15
|
-
|
14
|
+
|
16
15
|
def nil?
|
17
16
|
true
|
18
17
|
end
|
19
|
-
|
18
|
+
|
20
19
|
def empty?
|
21
20
|
true
|
22
21
|
end
|
23
22
|
|
23
|
+
def blank?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def present?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
24
31
|
def unsavable
|
25
32
|
errors.add(:base, "is a null object and can't be saved")
|
26
33
|
end
|
27
|
-
|
34
|
+
|
28
35
|
end
|
29
|
-
end
|
36
|
+
end
|
data/spec/null_object_spec.rb
CHANGED
@@ -50,11 +50,11 @@ describe NullAuthor do
|
|
50
50
|
|
51
51
|
context "when updating attributes" do
|
52
52
|
it "should return false" do
|
53
|
-
expect(null_author.
|
53
|
+
expect(null_author.update({})).to be false
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should not create a new record" do
|
57
|
-
expect { null_author.
|
57
|
+
expect { null_author.update({}) }.to_not change { NullAuthor.count }
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should add an error" do
|
data/spec/spec_helper.rb
CHANGED
@@ -7,28 +7,7 @@ require 'rspec/its'
|
|
7
7
|
|
8
8
|
I18n.enforce_available_locales = true if I18n.respond_to? :enforce_available_locales=
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
if ENV['COVERAGE']
|
13
|
-
require 'simplecov'
|
14
|
-
require 'coveralls'
|
15
|
-
Coveralls.wear!
|
16
|
-
|
17
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
18
|
-
SimpleCov.start do
|
19
|
-
add_filter '/vendor/'
|
20
|
-
add_filter '/spec/'
|
21
|
-
add_group 'lib', 'lib'
|
22
|
-
end
|
23
|
-
SimpleCov.at_exit do
|
24
|
-
SimpleCov.result.format!
|
25
|
-
percent = SimpleCov.result.covered_percent
|
26
|
-
unless percent >= MINIMUM_COVERAGE
|
27
|
-
puts "Coverage must be above #{MINIMUM_COVERAGE}%. It is #{"%.2f" % percent}%"
|
28
|
-
Kernel.exit(1)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
10
|
+
require 'support/coverage_loader'
|
32
11
|
|
33
12
|
require 'activerecord_null_object'
|
34
13
|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_null_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Scott Woods
|
@@ -10,150 +9,172 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2019-12-31 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
20
|
+
version: '5.0'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '7'
|
23
24
|
type: :runtime
|
24
25
|
prerelease: false
|
25
26
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '5.0'
|
31
|
+
- - "<"
|
29
32
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
33
|
+
version: '7'
|
31
34
|
- !ruby/object:Gem::Dependency
|
32
35
|
name: activerecord
|
33
36
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
37
|
requirements:
|
36
|
-
- -
|
38
|
+
- - ">="
|
37
39
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
40
|
+
version: '5.0'
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '7'
|
39
44
|
type: :runtime
|
40
45
|
prerelease: false
|
41
46
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
47
|
requirements:
|
44
|
-
- -
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.0'
|
51
|
+
- - "<"
|
45
52
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
53
|
+
version: '7'
|
47
54
|
- !ruby/object:Gem::Dependency
|
48
55
|
name: bundler
|
49
56
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
57
|
requirements:
|
52
|
-
- - ~>
|
58
|
+
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
60
|
+
version: '2'
|
55
61
|
type: :development
|
56
62
|
prerelease: false
|
57
63
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
64
|
requirements:
|
60
|
-
- - ~>
|
65
|
+
- - "~>"
|
61
66
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
67
|
+
version: '2'
|
63
68
|
- !ruby/object:Gem::Dependency
|
64
69
|
name: rake
|
65
70
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
71
|
requirements:
|
68
|
-
- -
|
72
|
+
- - ">="
|
69
73
|
- !ruby/object:Gem::Version
|
70
74
|
version: '0'
|
71
75
|
type: :development
|
72
76
|
prerelease: false
|
73
77
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
78
|
requirements:
|
76
|
-
- -
|
79
|
+
- - ">="
|
77
80
|
- !ruby/object:Gem::Version
|
78
81
|
version: '0'
|
79
82
|
- !ruby/object:Gem::Dependency
|
80
83
|
name: rspec
|
81
84
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
85
|
requirements:
|
84
|
-
- -
|
86
|
+
- - ">="
|
85
87
|
- !ruby/object:Gem::Version
|
86
88
|
version: '0'
|
87
89
|
type: :development
|
88
90
|
prerelease: false
|
89
91
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
92
|
requirements:
|
92
|
-
- -
|
93
|
+
- - ">="
|
93
94
|
- !ruby/object:Gem::Version
|
94
95
|
version: '0'
|
95
96
|
- !ruby/object:Gem::Dependency
|
96
97
|
name: rspec-its
|
97
98
|
requirement: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: coverage-kit
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
version: '0'
|
103
117
|
type: :development
|
104
118
|
prerelease: false
|
105
119
|
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
120
|
requirements:
|
108
|
-
- -
|
121
|
+
- - ">="
|
109
122
|
- !ruby/object:Gem::Version
|
110
123
|
version: '0'
|
111
124
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: simplecov
|
125
|
+
name: simplecov-rcov
|
113
126
|
requirement: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
127
|
requirements:
|
116
|
-
- -
|
128
|
+
- - ">="
|
117
129
|
- !ruby/object:Gem::Version
|
118
130
|
version: '0'
|
119
131
|
type: :development
|
120
132
|
prerelease: false
|
121
133
|
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
134
|
requirements:
|
124
|
-
- -
|
135
|
+
- - ">="
|
125
136
|
- !ruby/object:Gem::Version
|
126
137
|
version: '0'
|
127
138
|
- !ruby/object:Gem::Dependency
|
128
139
|
name: coveralls
|
129
140
|
requirement: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
141
|
requirements:
|
132
|
-
- -
|
142
|
+
- - ">="
|
133
143
|
- !ruby/object:Gem::Version
|
134
144
|
version: '0'
|
135
145
|
type: :development
|
136
146
|
prerelease: false
|
137
147
|
version_requirements: !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
148
|
requirements:
|
140
|
-
- -
|
149
|
+
- - ">="
|
141
150
|
- !ruby/object:Gem::Version
|
142
151
|
version: '0'
|
143
152
|
- !ruby/object:Gem::Dependency
|
144
153
|
name: sqlite3
|
145
154
|
requirement: !ruby/object:Gem::Requirement
|
146
|
-
none: false
|
147
155
|
requirements:
|
148
|
-
- -
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
type: :development
|
160
|
+
prerelease: false
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
- !ruby/object:Gem::Dependency
|
167
|
+
name: travis
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
149
171
|
- !ruby/object:Gem::Version
|
150
172
|
version: '0'
|
151
173
|
type: :development
|
152
174
|
prerelease: false
|
153
175
|
version_requirements: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
176
|
requirements:
|
156
|
-
- -
|
177
|
+
- - ">="
|
157
178
|
- !ruby/object:Gem::Version
|
158
179
|
version: '0'
|
159
180
|
description: Implements the Null Object Pattern for nil values in ActiveRecord associations.
|
@@ -163,55 +184,51 @@ executables: []
|
|
163
184
|
extensions: []
|
164
185
|
extra_rdoc_files: []
|
165
186
|
files:
|
166
|
-
- .gitignore
|
167
|
-
- .
|
187
|
+
- ".gitignore"
|
188
|
+
- ".ruby-version"
|
189
|
+
- ".travis.yml"
|
190
|
+
- CHANGELOG.md
|
168
191
|
- Gemfile
|
169
192
|
- MIT-LICENSE
|
170
193
|
- README.md
|
171
194
|
- Rakefile
|
172
195
|
- VERSION
|
173
196
|
- activerecord_null_object.gemspec
|
174
|
-
- gemfiles/
|
175
|
-
- gemfiles/
|
197
|
+
- gemfiles/rails52.gemfile
|
198
|
+
- gemfiles/rails6.gemfile
|
176
199
|
- lib/activerecord_null_object.rb
|
177
200
|
- lib/activerecord_null_object/null_object.rb
|
178
201
|
- lib/activerecord_null_object/null_object_support.rb
|
202
|
+
- lib/activerecord_null_object/version.rb
|
179
203
|
- spec/belongs_to_spec.rb
|
180
204
|
- spec/has_one_spec.rb
|
181
205
|
- spec/null_object_spec.rb
|
182
206
|
- spec/schema.rb
|
183
207
|
- spec/spec.opts
|
184
208
|
- spec/spec_helper.rb
|
209
|
+
- spec/support/coverage_loader.rb
|
185
210
|
homepage: http://github.com/sealink/activerecord_null_object
|
186
211
|
licenses:
|
187
212
|
- MIT
|
213
|
+
metadata: {}
|
188
214
|
post_install_message:
|
189
215
|
rdoc_options: []
|
190
216
|
require_paths:
|
191
217
|
- lib
|
192
218
|
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
-
none: false
|
194
219
|
requirements:
|
195
|
-
- -
|
220
|
+
- - ">="
|
196
221
|
- !ruby/object:Gem::Version
|
197
222
|
version: '0'
|
198
|
-
segments:
|
199
|
-
- 0
|
200
|
-
hash: 1262034008497264332
|
201
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
|
-
none: false
|
203
224
|
requirements:
|
204
|
-
- -
|
225
|
+
- - ">="
|
205
226
|
- !ruby/object:Gem::Version
|
206
227
|
version: '0'
|
207
|
-
segments:
|
208
|
-
- 0
|
209
|
-
hash: 1262034008497264332
|
210
228
|
requirements: []
|
211
|
-
|
212
|
-
rubygems_version: 1.8.25
|
229
|
+
rubygems_version: 3.0.3
|
213
230
|
signing_key:
|
214
|
-
specification_version:
|
231
|
+
specification_version: 4
|
215
232
|
summary: Implements the Null Object Pattern for nil values in ActiveRecord associations.
|
216
233
|
test_files:
|
217
234
|
- spec/belongs_to_spec.rb
|
@@ -220,3 +237,4 @@ test_files:
|
|
220
237
|
- spec/schema.rb
|
221
238
|
- spec/spec.opts
|
222
239
|
- spec/spec_helper.rb
|
240
|
+
- spec/support/coverage_loader.rb
|
data/gemfiles/rails3.gemfile
DELETED