assignable_values 0.17.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/.github/workflows/test.yml +2 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile +1 -1
- 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 +2 -2
- data/Gemfile.6.1.pg.lock +5 -5
- data/Gemfile.7.0.pg +3 -3
- data/Gemfile.7.0.pg.lock +16 -16
- data/Gemfile.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/.github/workflows/test.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0
|
1
|
+
3.2.0
|
data/CHANGELOG.md
CHANGED
@@ -12,6 +12,20 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
12
12
|
|
13
13
|
-
|
14
14
|
|
15
|
+
|
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.
|
22
|
+
|
23
|
+
## 0.18.0 - 2023-01-24
|
24
|
+
|
25
|
+
### Compatible changes
|
26
|
+
|
27
|
+
- Add support for Ruby 3.2
|
28
|
+
|
15
29
|
## 0.17.0 - 2022-07-27
|
16
30
|
|
17
31
|
### Compatible changes
|
data/Gemfile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Gemfile.7.0.pg
|
data/Gemfile.5.0.lock
CHANGED
data/Gemfile.5.1.lock
CHANGED
data/Gemfile.5.1.pg.lock
CHANGED
data/Gemfile.6.1.pg
CHANGED
@@ -3,14 +3,14 @@ source 'https://rubygems.org'
|
|
3
3
|
# Runtime dependencies
|
4
4
|
gem 'activerecord', '~>6.1.3'
|
5
5
|
gem 'i18n'
|
6
|
-
gem 'pg', '1.
|
6
|
+
gem 'pg', '~> 1.3.5'
|
7
7
|
|
8
8
|
# Development dependencies
|
9
9
|
gem 'rake'
|
10
10
|
gem 'database_cleaner'
|
11
11
|
gem 'rspec'
|
12
12
|
gem 'rspec_candy'
|
13
|
-
gem 'gemika'
|
13
|
+
gem 'gemika', '~> 0.8.0'
|
14
14
|
|
15
15
|
# Gem under test
|
16
16
|
gem 'assignable_values', :path => '.'
|
data/Gemfile.6.1.pg.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.18.1)
|
5
5
|
activerecord (>= 2.3)
|
6
6
|
|
7
7
|
GEM
|
@@ -21,11 +21,11 @@ GEM
|
|
21
21
|
concurrent-ruby (1.1.5)
|
22
22
|
database_cleaner (1.7.0)
|
23
23
|
diff-lcs (1.3)
|
24
|
-
gemika (0.
|
24
|
+
gemika (0.8.0)
|
25
25
|
i18n (1.6.0)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
27
|
minitest (5.14.4)
|
28
|
-
pg (1.
|
28
|
+
pg (1.3.5)
|
29
29
|
rake (12.3.2)
|
30
30
|
rspec (3.8.0)
|
31
31
|
rspec-core (~> 3.8.0)
|
@@ -56,9 +56,9 @@ DEPENDENCIES
|
|
56
56
|
activerecord (~> 6.1.3)
|
57
57
|
assignable_values!
|
58
58
|
database_cleaner
|
59
|
-
gemika
|
59
|
+
gemika (~> 0.8.0)
|
60
60
|
i18n
|
61
|
-
pg (
|
61
|
+
pg (~> 1.3.5)
|
62
62
|
rake
|
63
63
|
rspec
|
64
64
|
rspec_candy
|
data/Gemfile.7.0.pg
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Runtime dependencies
|
4
|
-
gem 'activerecord', '~>7.0.
|
4
|
+
gem 'activerecord', '~>7.0.1'
|
5
5
|
gem 'i18n'
|
6
|
-
gem 'pg', '1.
|
6
|
+
gem 'pg', '~> 1.3.5'
|
7
7
|
|
8
8
|
# Development dependencies
|
9
9
|
gem 'rake'
|
10
10
|
gem 'database_cleaner'
|
11
11
|
gem 'rspec'
|
12
12
|
gem 'rspec_candy'
|
13
|
-
gem 'gemika'
|
13
|
+
gem 'gemika', '~> 0.8.0'
|
14
14
|
|
15
15
|
# Gem under test
|
16
16
|
gem 'assignable_values', :path => '.'
|
data/Gemfile.7.0.pg.lock
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
assignable_values (0.
|
4
|
+
assignable_values (0.18.1)
|
5
5
|
activerecord (>= 2.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (7.0.
|
11
|
-
activesupport (= 7.0.
|
12
|
-
activerecord (7.0.
|
13
|
-
activemodel (= 7.0.
|
14
|
-
activesupport (= 7.0.
|
15
|
-
activesupport (7.0.
|
10
|
+
activemodel (7.0.4.1)
|
11
|
+
activesupport (= 7.0.4.1)
|
12
|
+
activerecord (7.0.4.1)
|
13
|
+
activemodel (= 7.0.4.1)
|
14
|
+
activesupport (= 7.0.4.1)
|
15
|
+
activesupport (7.0.4.1)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
19
19
|
tzinfo (~> 2.0)
|
20
|
-
concurrent-ruby (1.
|
20
|
+
concurrent-ruby (1.2.0)
|
21
21
|
database_cleaner (1.7.0)
|
22
22
|
diff-lcs (1.3)
|
23
|
-
gemika (0.
|
24
|
-
i18n (1.
|
23
|
+
gemika (0.8.0)
|
24
|
+
i18n (1.12.0)
|
25
25
|
concurrent-ruby (~> 1.0)
|
26
|
-
minitest (5.
|
27
|
-
pg (1.
|
26
|
+
minitest (5.17.0)
|
27
|
+
pg (1.3.5)
|
28
28
|
rake (12.3.2)
|
29
29
|
rspec (3.8.0)
|
30
30
|
rspec-core (~> 3.8.0)
|
@@ -44,19 +44,19 @@ GEM
|
|
44
44
|
sneaky-save
|
45
45
|
sneaky-save (0.1.3)
|
46
46
|
activerecord (>= 3.2.0)
|
47
|
-
tzinfo (2.0.
|
47
|
+
tzinfo (2.0.5)
|
48
48
|
concurrent-ruby (~> 1.0)
|
49
49
|
|
50
50
|
PLATFORMS
|
51
51
|
ruby
|
52
52
|
|
53
53
|
DEPENDENCIES
|
54
|
-
activerecord (~> 7.0.
|
54
|
+
activerecord (~> 7.0.1)
|
55
55
|
assignable_values!
|
56
56
|
database_cleaner
|
57
|
-
gemika
|
57
|
+
gemika (~> 0.8.0)
|
58
58
|
i18n
|
59
|
-
pg (
|
59
|
+
pg (~> 1.3.5)
|
60
60
|
rake
|
61
61
|
rspec
|
62
62
|
rspec_candy
|
data/Gemfile.lock
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Gemfile.7.0.pg.lock
|
@@ -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.
|
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:
|
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.
|
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
|