Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ActiveModel::Dirty#changes should return a HashWithIndifferentAccess [#…
…4157 state:resolved] Keep the Rails style of inject Signed-off-by: José Valim <jose.valim@gmail.com>
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
require "cases/helper" | |||
|
|||
class DirtyTest < ActiveModel::TestCase | |||
class DirtyModel | |||
include ActiveModel::Dirty | |||
define_attribute_methods [:name] | |||
|
|||
def initialize | |||
@name = nil | |||
end | |||
|
|||
def name | |||
@name | |||
end | |||
|
|||
def name=(val) | |||
name_will_change! | |||
@name = val | |||
end | |||
end | |||
|
|||
test "changes accessible through both strings and symbols" do | |||
model = DirtyModel.new | |||
model.name = "David" | |||
assert !model.changes[:name].nil? | |||
assert !model.changes['name'].nil? | |||
end | |||
|
|||
end |