active_interaction 5.1.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c740eef14e1c0bca42f4bbb5b3718c879bc3af038f40953a60a53007611916e5
4
- data.tar.gz: b0a3738aa38869c7be559d72f23e958d0f9e66c0f490652bd8a92e1ef449e48e
3
+ metadata.gz: 1205bfc3c95589bd74fdb6395e09573c01210a95bf5d6644b70fef11cacea914
4
+ data.tar.gz: 2494a61529d645f6dcfaef940e4d54e404bda94eb78eabbac605dcc14221e422
5
5
  SHA512:
6
- metadata.gz: f998483eb21ec13a43dcf3c7b6805f7865b3dd7b4d8fbc9846263338d676c41c7991a602dd3a82e13a9b93a027cbeccd5648a87fef688964124935d38d9ef6c4
7
- data.tar.gz: 4669a1e76a427af4a62415f242bfdc3fa45f7a63c5a43de704b7849639841f365e83168b5c1db68ab067ca2104f8f7ec580baa487e5caa6035196607033c79f8
6
+ metadata.gz: 6037171bd7f2ddc2af0204e2af5fdf0140725678698e7c4fa27875f16446c7c8be0b69aa83da30626bf9fe96ae00a5f76ffc92274cfd9654abad355e611df7ed
7
+ data.tar.gz: fac17df5266c5a72809fbc32ab3e84d840b35fe59cb2d483511b27c46beaec197b5a5e669d740ef023bf064df82a8ac8d5cbcd94bba60b3c5e0ba72969b385c2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [5.1.1][] (2022-09-01)
2
+
3
+ ## Fixed
4
+
5
+ - [#539][] - Fixed a caching error in default values.
6
+
1
7
  # [5.1.0][] (2022-07-28)
2
8
 
3
9
  ## Added
@@ -1112,6 +1118,7 @@ Example.run
1112
1118
 
1113
1119
  - Initial release.
1114
1120
 
1121
+ [5.1.1]: https://github.com/AaronLasseigne/active_interaction/compare/v5.1.0...v5.1.1
1115
1122
  [5.1.0]: https://github.com/AaronLasseigne/active_interaction/compare/v5.0.0...v5.1.0
1116
1123
  [5.0.0]: https://github.com/AaronLasseigne/active_interaction/compare/v4.1.0...v5.0.0
1117
1124
  [4.1.0]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.6...v4.1.0
@@ -1339,3 +1346,4 @@ Example.run
1339
1346
  [#503]: https://github.com/AaronLasseigne/active_interaction/issues/503
1340
1347
  [#536]: https://github.com/AaronLasseigne/active_interaction/issues/536
1341
1348
  [#537]: https://github.com/AaronLasseigne/active_interaction/issues/537
1349
+ [#539]: https://github.com/AaronLasseigne/active_interaction/issues/539
@@ -112,24 +112,21 @@ module ActiveInteraction
112
112
  # @raise [NoDefaultError] If the default is missing.
113
113
  # @raise [InvalidDefaultError] If the default is invalid.
114
114
  def default(context = nil)
115
- return @default if defined?(@default)
116
-
117
115
  raise NoDefaultError, name unless default?
118
116
 
119
117
  value = raw_default(context)
120
118
  raise InvalidDefaultError, "#{name}: #{value.inspect}" if value.is_a?(GroupedInput)
121
119
 
122
- @default =
123
- if value.nil?
124
- nil
125
- else
126
- default = process(value, context)
127
- if default.errors.any? && default.errors.first.is_a?(Filter::Error)
128
- raise InvalidDefaultError, "#{name}: #{value.inspect}"
129
- end
130
-
131
- default.value
120
+ if value.nil?
121
+ nil
122
+ else
123
+ default = process(value, context)
124
+ if default.errors.any? && default.errors.first.is_a?(Filter::Error)
125
+ raise InvalidDefaultError, "#{name}: #{value.inspect}"
132
126
  end
127
+
128
+ default.value
129
+ end
133
130
  end
134
131
 
135
132
  # Get the description.
@@ -4,5 +4,5 @@ module ActiveInteraction
4
4
  # The version number.
5
5
  #
6
6
  # @return [Gem::Version]
7
- VERSION = Gem::Version.new('5.1.0')
7
+ VERSION = Gem::Version.new('5.1.1')
8
8
  end
@@ -36,4 +36,25 @@ describe ActiveInteraction::Filter, :filter do
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ describe '#default' do
41
+ subject(:filter) { ActiveInteraction::IntegerFilter.new(:test, default: default) }
42
+
43
+ context 'when it is a value' do
44
+ let(:default) { 1 }
45
+
46
+ it 'returns the default' do
47
+ expect(filter.default).to be 1
48
+ end
49
+ end
50
+
51
+ context 'when it is a proc' do
52
+ let(:default) { -> { i + 1 } }
53
+
54
+ it 'returns the default' do
55
+ expect(filter.default(double(i: 0))).to be 1 # rubocop:disable RSpec/VerifiedDoubles
56
+ expect(filter.default(double(i: 1))).to be 2 # rubocop:disable RSpec/VerifiedDoubles
57
+ end
58
+ end
59
+ end
39
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_interaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lasseigne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-07-28 00:00:00.000000000 Z
12
+ date: 2022-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel