Skip to content

Commit

Permalink
Add virtual_attribute_name to active record reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
chaadow committed Mar 23, 2023
1 parent b879fa5 commit 7ed073e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/dummy/app/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class Order < ApplicationRecord
has_one_state_machine :admin_status, state_machine_klass: 'AdminStatusOrderStateMachine',
transition_klass: 'AdminStatusOrderTransition'
has_one_state_machine :custom_status, state_machine_klass: 'AdminStatusOrderStateMachine',
transition_klass: 'AdminStatusOrderTransition', transition_name: :transitions
transition_klass: 'AdminStatusOrderTransition', transition_name: :transitions, virtual_attribute_name: 'my_attribute'
end
1 change: 1 addition & 0 deletions test/statesman/multi_state/reflection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ReflectionTest < ActiveSupport::TestCase

reflection = Order.reflect_on_state_machine(:custom_status)
assert_equal :transitions, reflection.options[:transition_name]
assert_equal 'my_attribute', reflection.options[:virtual_attribute_name]
end

test 'reflection on a singular state machine with the same name as a state machine on another model' do
Expand Down

0 comments on commit 7ed073e

Please sign in to comment.