assignable_values 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.5.0.lock +1 -1
- data/Gemfile.5.1.lock +1 -1
- data/Gemfile.5.1.pg.lock +1 -1
- data/Gemfile.6.1.pg.lock +1 -1
- data/Gemfile.7.0.pg.lock +1 -1
- data/lib/assignable_values/active_record/restriction/base.rb +20 -1
- data/lib/assignable_values/errors.rb +1 -0
- data/lib/assignable_values/version.rb +1 -1
- data/spec/assignable_values/active_record_spec.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 933681c08828de5d892b6d4a200a6376b0de7b700c55bc824124f1b0114501fc
|
4
|
+
data.tar.gz: 1e1fa1a8bb6999ca7da4bf1d91d9ed1163e4770904c0f8eeb8c63b3f6c207575
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be6eb8de9809e1398ea1e4e13256a2118acc319a306ec144c9b89723c4ed2c677a83c98898844f0a899c4144f9b85de8e9a9d9ea0110d5b70c5e366862db82e1
|
7
|
+
data.tar.gz: 38dc638bc04ae0bcb3317e3886f22aacb2c784e9909a316e2d734795f4da40d7faaee6e931451daa42ac40975350eb5e27e6c9c192104238e20872a270da6972
|
data/CHANGELOG.md
CHANGED
@@ -14,6 +14,11 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
+
## 0.18.1 - 2023-09-06
|
18
|
+
|
19
|
+
### Compatible changes
|
20
|
+
|
21
|
+
- Calling `assignable_values_for` with unsupported options will raise an error.
|
17
22
|
|
18
23
|
## 0.18.0 - 2023-01-24
|
19
24
|
|
data/Gemfile.5.0.lock
CHANGED
data/Gemfile.5.1.lock
CHANGED
data/Gemfile.5.1.pg.lock
CHANGED
data/Gemfile.6.1.pg.lock
CHANGED
data/Gemfile.7.0.pg.lock
CHANGED
@@ -5,11 +5,24 @@ module AssignableValues
|
|
5
5
|
|
6
6
|
attr_reader :model, :property, :options, :values, :default, :secondary_default
|
7
7
|
|
8
|
+
SUPPORTED_OPTIONS = [
|
9
|
+
:allow_blank,
|
10
|
+
:decorate,
|
11
|
+
:default,
|
12
|
+
:include_old_value,
|
13
|
+
:message,
|
14
|
+
:multiple,
|
15
|
+
:secondary_default,
|
16
|
+
:through,
|
17
|
+
].freeze
|
18
|
+
private_constant :SUPPORTED_OPTIONS
|
19
|
+
|
8
20
|
def initialize(model, property, options, &values)
|
9
21
|
@model = model
|
10
22
|
@property = property
|
11
23
|
@options = options
|
12
24
|
@values = values
|
25
|
+
validate_supported_options!
|
13
26
|
ensure_values_given
|
14
27
|
setup_default
|
15
28
|
define_assignable_values_method
|
@@ -274,8 +287,14 @@ module AssignableValues
|
|
274
287
|
@values or @options[:through] or raise NoValuesGiven, 'You must supply the list of assignable values by either a block or :through option'
|
275
288
|
end
|
276
289
|
|
290
|
+
def validate_supported_options!
|
291
|
+
unsupported_options = @options.keys - SUPPORTED_OPTIONS
|
292
|
+
if unsupported_options.any?
|
293
|
+
raise UnsupportedOption,
|
294
|
+
"The following options are not supported: #{unsupported_options.map { |o| ":#{o}" }.join(', ')}"
|
295
|
+
end
|
296
|
+
end
|
277
297
|
end
|
278
298
|
end
|
279
299
|
end
|
280
300
|
end
|
281
|
-
|
@@ -21,6 +21,14 @@ describe AssignableValues::ActiveRecord do
|
|
21
21
|
end.to raise_error(AssignableValues::NoValuesGiven)
|
22
22
|
end
|
23
23
|
|
24
|
+
it 'should raise an error when called with unsupported options' do
|
25
|
+
expect do
|
26
|
+
Song.disposable_copy do
|
27
|
+
assignable_values_for :genre, unsupported_option: 42
|
28
|
+
end
|
29
|
+
end.to raise_error(AssignableValues::UnsupportedOption, 'The following options are not supported: :unsupported_option')
|
30
|
+
end
|
31
|
+
|
24
32
|
context 'when validating virtual attributes' do
|
25
33
|
|
26
34
|
before :each do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assignable_values
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.4.
|
93
|
+
rubygems_version: 3.4.14
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Restrict the values assignable to ActiveRecord attributes or associations
|