Skip to content

Commit

Permalink
Fix implementation to map aliased to original attribute names
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvh committed Apr 26, 2021
1 parent 626d575 commit 0e32ee4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 0 additions & 6 deletions test/machine_with_aliased_attribute_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,5 @@ def test_should_check_custom_attribute_for_predicate
@record.vehicle_status = 'parked'
assert @record.status?(:parked)
end

def test_should_initialize_with_original_attribute_names
record = @model.new(:vehicle_status => 'bogus')
refute record.status?(:parked)
assert record.status?(:bogus)
end
end

20 changes: 20 additions & 0 deletions test/machine_with_initialized_aliased_attribute_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require_relative 'test_helper'

class MachineWithInitializedAliasedAttributeTest < BaseTestCase
def setup
@model = new_model do
alias_attribute :custom_status, :state
end

@machine = StateMachines::Machine.new(@model, :initial => :parked, :attribute => :state)
@machine.state :started

@record = @model.new(:custom_status => :started)
end

def test_should_match_original_attribute_value
refute @record.state?(:parked)
assert @record.state?(:started)
end
end

0 comments on commit 0e32ee4

Please sign in to comment.