active_interaction 3.8.1 → 3.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0548218152b9de3c7b9d3138ba8e6d18404da27e0ffb7e2ed95195f066dd681b'
4
- data.tar.gz: 917d2fe9a9c99b468aa2ad80e861e27e20f0f6caf8fdbe2698ce29f7e7ec2864
3
+ metadata.gz: ab5fbe89ea464ba3cbd680d4b444aff591500d843602bd0f94059de42c680739
4
+ data.tar.gz: cb6f3f963b5614a6eab29e611369917d9a4252948aa42e6ab9107d730745fda7
5
5
  SHA512:
6
- metadata.gz: bdd646f710eb2f8d49ba74224e17b9b4d0b4595708ee9dba6bad53dd59652ec69fb4e2f3ebcb538f949197103d5a011d1319e4a57cc9d7c96ebe21578b9b8b42
7
- data.tar.gz: b0853777a9cd4be10de3f6de7980ba52fa8448a57203f9c531df84c5c55bfbd675860b52dc320b996e0110c5d1353e21f868a900d742828cc8b5d0b0abb72cac
6
+ metadata.gz: 34b4222d51134f6a704d21a79d1c44e71d6edb4471156188564973a89fdfef68d156575dc0ec777d6b18ef6420e775ca61e9034fd44427c7cc4a66afb6bbad1a
7
+ data.tar.gz: 912a034a88b9c0fa10a78b83a5c8b0ceae6b3040a7c81e7550c11af16bbe60e639251e67df58c41b19b297eefcafe9a6101ae92dacaee382fec2ff1ac0fa7827
@@ -1,3 +1,9 @@
1
+ # [3.8.2][] (2020-04-22)
2
+
3
+ ## Fixed
4
+
5
+ - [479][] Composed interactions that throw errors now show a complete backtrace instead of ending at the `run!` of the outermost interaction.
6
+
1
7
  # [3.8.1][] (2020-04-04)
2
8
 
3
9
  ## Fixed
@@ -765,6 +771,7 @@ Example.run
765
771
 
766
772
  - Initial release.
767
773
 
774
+ [3.8.2]: https://github.com/AaronLasseigne/active_interaction/compare/v3.8.1...v3.8.2
768
775
  [3.8.1]: https://github.com/AaronLasseigne/active_interaction/compare/v3.8.0...v3.8.1
769
776
  [3.8.0]: https://github.com/AaronLasseigne/active_interaction/compare/v3.7.1...v3.8.0
770
777
  [3.7.1]: https://github.com/AaronLasseigne/active_interaction/compare/v3.7.0...v3.7.1
@@ -963,3 +970,4 @@ Example.run
963
970
  [#457]: https://github.com/AaronLasseigne/active_interaction/issues/457
964
971
  [#477]: https://github.com/AaronLasseigne/active_interaction/issues/477
965
972
  [#476]: https://github.com/AaronLasseigne/active_interaction/issues/476
973
+ [#479]: https://github.com/AaronLasseigne/active_interaction/issues/479
@@ -10,4 +10,4 @@
10
10
 
11
11
  Running the tests using `rake` (with no args) will also check for style issues in the code. Ideally all submissions would pass these checks. If the code style is causing issues (particularly the method or class size) we can work with you to correct it. Don't let it stop you from contributing.
12
12
 
13
- [fork]: https://github.com/orgsync/active_interaction/fork
13
+ [fork]: https://github.com/AaronLasseigne/active_interaction/fork
@@ -71,24 +71,18 @@ module ActiveInteraction
71
71
 
72
72
  # @return (see #result=)
73
73
  # @return [nil]
74
- def run # rubocop:disable MethodLength
75
- self.result =
76
- if valid?
77
- run_callbacks(:execute) do
78
- result_or_errors =
79
- begin
80
- execute
81
- rescue Interrupt => interrupt
82
- interrupt.errors
83
- end
84
-
85
- if result_or_errors.is_a?(ActiveInteraction::Errors)
86
- errors.merge!(result_or_errors)
87
- else
88
- result_or_errors
89
- end
74
+ def run
75
+ return self.result = nil unless valid?
76
+
77
+ run_callbacks(:execute) do
78
+ self.result =
79
+ begin
80
+ execute
81
+ rescue Interrupt => interrupt
82
+ errors.backtrace = interrupt.errors.backtrace || interrupt.backtrace
83
+ errors.merge!(interrupt.errors)
90
84
  end
91
- end
85
+ end
92
86
  end
93
87
 
94
88
  # @return [Object]
@@ -101,6 +95,7 @@ module ActiveInteraction
101
95
 
102
96
  e = InvalidInteractionError.new(errors.full_messages.join(', '))
103
97
  e.interaction = self
98
+ e.set_backtrace(errors.backtrace) if errors.backtrace
104
99
  raise e
105
100
  end
106
101
 
@@ -92,6 +92,8 @@ module ActiveInteraction
92
92
 
93
93
  # An extension that provides the ability to merge other errors into itself.
94
94
  class Errors < ActiveModel::Errors
95
+ attr_accessor :backtrace
96
+
95
97
  # Merge other errors into this one.
96
98
  #
97
99
  # @param other [Errors]
@@ -6,5 +6,5 @@ module ActiveInteraction
6
6
  # The version number.
7
7
  #
8
8
  # @return [Gem::Version]
9
- VERSION = Gem::Version.new('3.8.1')
9
+ VERSION = Gem::Version.new('3.8.2')
10
10
  end
@@ -24,6 +24,12 @@ InterruptInteraction = Class.new(TestInteraction) do
24
24
  class: Object,
25
25
  default: nil
26
26
 
27
+ # NOTE: the relative position between this method
28
+ # and the compose line should be preserved.
29
+ def self.composition_location
30
+ "#{__FILE__}:#{__LINE__ + 4}:in `execute'"
31
+ end
32
+
27
33
  def execute
28
34
  compose(AddInteraction, x: x, y: z)
29
35
  end
@@ -371,6 +377,15 @@ describe ActiveInteraction::Base do
371
377
  expect(outcome.errors.details)
372
378
  .to eql(x: [{ error: :missing }], base: [{ error: 'Y is required' }])
373
379
  end
380
+
381
+ it 'has the correct backtrace' do
382
+ begin
383
+ described_class.run!(inputs)
384
+ rescue ActiveInteraction::InvalidInteractionError => e
385
+ expect(e.backtrace)
386
+ .to include(InterruptInteraction.composition_location)
387
+ end
388
+ end
374
389
  end
375
390
  end
376
391
 
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: 3.8.1
4
+ version: 3.8.2
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: 2020-04-04 00:00:00.000000000 Z
12
+ date: 2020-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel