1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/spec/unit
Daniel Nolan 5d22f691fe Fix ClassInvoker instantiating class twice
* I'm in the process of updating a rails app from rails 5.2 to rails 7.
  Currently the app is using AASM version 4.12.3. When I update to AASM
  version 5.x we start getting a failing spec in our app. The
  implementation uses the `after:` dsl and passes it a class.

  ``` ruby
   event :run_payment_create do
      transitions to: :active, after: Payment::GoCardless::Subscription::Charge
    end
  ```

  The spec in our app expects that class to receive new 1 time with the args
  passed from after, but the spec is failing saying that `Payment::GoCardless::Subscription::Charge`
  received `.new` with the expected args twice.
  I started debugging with `bundle open aasm` and pry and I found that the
  `ClassInvoker` has a `instance` method that memoizes the instance
  returned from the `retrieve_instance` method, but the `instance`
  method was only being used by `log_source_location` and `log_method_info`
  methods while `invoke_subject` was calling `retrieve_instance` directly
  resulting in `retrieve_instance` being called twice.
* Update `invoke_subject` method to use `instance.call` so that the
  instance will be memoized and subsequent calls to `instance` won't try
  to instantiate the class a second time.
2023-01-26 11:54:11 +08:00
..
invokers Fix ClassInvoker instantiating class twice 2023-01-26 11:54:11 +08:00
persistence add specs 2021-03-25 14:06:04 +05:30
abstract_class_spec.rb Fix no_direct_assignment config for abstract base class 2019-04-21 17:46:52 +05:30
api_spec.rb Remove ruby 2.3 support and fix human_state to use display option 2020-08-11 19:48:07 +05:30
basic_two_state_machines_example_spec.rb add basic examples with two state machines 2015-07-20 20:55:47 +12:00
callback_multiple_spec.rb Fix callback argument for :before_success & :success callback. 2019-05-20 17:56:52 +05:30
callbacks_spec.rb Cast string to symbol in fire/fire!, and fix deceptive error class and message (#788) 2022-07-27 15:28:17 +05:30
complex_example_spec.rb Cast string to symbol in fire/fire!, and fix deceptive error class and message (#788) 2022-07-27 15:28:17 +05:30
complex_multiple_example_spec.rb Add to AASM fire(event) and fire!(event) methods 2017-08-10 12:10:22 +05:30
edge_cases_spec.rb handle edge cases when a state machine is accessed which doesn't exist 2015-08-05 22:00:22 +12:00
event_multiple_spec.rb Remove the need to set to_state as nil in specs 2017-07-27 13:11:50 +05:30
event_naming_spec.rb allow :send as event name #257 2016-01-08 16:08:43 +13:00
event_spec.rb Cast string to symbol in fire/fire!, and fix deceptive error class and message (#788) 2022-07-27 15:28:17 +05:30
event_with_keyword_arguments_spec.rb Fixed an error in Ruby 3 when specifying a method that takes keyword arguments, such as event's before hook. (#777) 2022-04-14 23:31:56 +05:30
exception_spec.rb Remove trailing space from error message 2017-08-16 13:47:24 +03:00
guard_arguments_check_spec.rb Test for aasm guard arguments (#485) 2017-08-04 17:49:22 +05:30
guard_multiple_spec.rb more tests 2015-06-26 19:46:58 +12:00
guard_spec.rb Add specs to verify may_*? methods for ActiveRecord 2017-04-30 02:25:35 +05:30
guard_with_params_multiple_spec.rb Fix [#388] guard parameter for permissible states 2016-08-01 18:25:12 +05:30
guard_with_params_spec.rb Ensure nil arg is forwarded to callbacks 2016-10-05 14:23:08 +05:30
guard_without_from_specified_spec.rb Fix guard checking when from is not provided (#456) 2017-04-27 15:52:54 +05:30
initial_state_multiple_spec.rb more tests 2015-06-26 19:46:58 +12:00
initial_state_spec.rb let class names reflect its purpose (in tests) 2015-05-15 22:50:29 +12:00
inspection_multiple_spec.rb Fix tests for Localizer (#689) 2020-08-05 20:27:12 +05:30
inspection_spec.rb Fix tests for Localizer (#689) 2020-08-05 20:27:12 +05:30
invoker_spec.rb chore(invokers): Refactor callback invokers, add class-callbacks support 2018-06-19 21:11:56 +03:00
localizer_spec.rb Adds spec for #human_event_name to accept event object 2021-03-26 17:50:20 +05:30
memory_leak_spec.rb Support for object proxies for RubyMotion ! 2016-03-19 03:41:04 +01:00
multiple_transitions_that_differ_only_by_guard_spec.rb Add test to verify the correct transition's callbacks actually run 2016-10-12 13:56:00 -07:00
namespaced_multiple_example_spec.rb Add aliases for event methods 2017-06-15 20:10:44 +05:30
new_dsl_spec.rb Update specs to use 'expect' syntax using transpec. Loosed gemspec to allow rspec versions greater than 2.14.x 2014-01-11 08:10:59 -08:00
override_warning_spec.rb reduce warning output when running specs 2017-02-10 22:00:03 +11:00
readme_spec.rb allow multiple states to be defined on one line 2015-12-02 02:38:56 -07:00
reloading_spec.rb improve test description 2015-07-01 21:35:18 +12:00
rspec_matcher_spec.rb handle InvalidTransition in transition_from matcher 2019-11-08 17:21:04 +05:30
simple_custom_example_spec.rb incorporate feedback using AASM configuration options 2016-02-05 15:32:34 -05:00
simple_example_spec.rb Feature: Add permitted_transitions to group permitted event with state (#664) 2020-02-08 18:19:30 +05:30
simple_multiple_example_spec.rb Add binding event (#438) 2017-02-28 15:25:06 +05:30
state_spec.rb Fix tests for Localizer (#689) 2020-08-05 20:27:12 +05:30
states_on_one_line_example_spec.rb allow multiple states to be defined on one line 2015-12-02 02:38:56 -07:00
subclassing_multiple_spec.rb Deep clone state machine during inheritance (with tests) (#429) 2017-03-08 12:28:27 +05:30
subclassing_spec.rb Deep clone state machine during inheritance (with tests) (#429) 2017-03-08 12:28:27 +05:30
timestamps_spec.rb fix: timestamp will work with named machine 2021-04-23 14:29:09 +05:30
transition_spec.rb Remove trailing space from error message 2017-08-16 13:47:24 +03:00