File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,9 @@ def has_attribute_before_type_cast?(name)
86
86
def read_attribute ( name )
87
87
field = fields [ name . to_s ]
88
88
raw = read_raw_attribute ( name )
89
- field ? field . demongoize ( raw ) : raw
89
+ value = field ? field . demongoize ( raw ) : raw
90
+ attribute_will_change! ( name . to_s ) if value . resizable?
91
+ value
90
92
end
91
93
alias :[] :read_attribute
92
94
Original file line number Diff line number Diff line change 2684
2684
end
2685
2685
end
2686
2686
end
2687
+
2688
+ context "when modifiying a hash referenced with the [] notation" do
2689
+ let ( :church ) { Church . create! ( location : { x : 1 } ) }
2690
+
2691
+ before do
2692
+ church [ :location ] . merge! ( y : 2 )
2693
+ church . save!
2694
+ church . reload
2695
+ end
2696
+
2697
+ it "persists the updated hash" do
2698
+ church . location . should == { "x" => 1 , "y" => 2 }
2699
+ end
2700
+ end
2687
2701
end
You can’t perform that action at this time.
0 commit comments