@@ -38,6 +38,7 @@ class ::TestEmployee < ActiveRecord::Base
3838 last_name : "Last" ,
3939 binary_data : @binary_data
4040 )
41+ expect ( @employee . binary_data ) . to eq ( @binary_data )
4142 @employee . reload
4243 expect ( @employee . binary_data ) . to eq ( @binary_data )
4344 end
@@ -51,6 +52,7 @@ class ::TestEmployee < ActiveRecord::Base
5152 expect ( @employee . binary_data ) . to be_nil
5253 @employee . binary_data = @binary_data
5354 @employee . save!
55+ expect ( @employee . binary_data ) . to eq ( @binary_data )
5456 @employee . reload
5557 expect ( @employee . binary_data ) . to eq ( @binary_data )
5658 end
@@ -77,6 +79,7 @@ class ::TestEmployee < ActiveRecord::Base
7779 @employee . reload
7880 @employee . binary_data = @binary_data2
7981 @employee . save!
82+ expect ( @employee . binary_data ) . to eq ( @binary_data2 )
8083 @employee . reload
8184 expect ( @employee . binary_data ) . to eq ( @binary_data2 )
8285 end
@@ -116,13 +119,14 @@ class ::TestEmployee < ActiveRecord::Base
116119 @employee . reload
117120 @employee . binary_data = @binary_data
118121 @employee . save!
122+ expect ( @employee . binary_data ) . to eq ( @binary_data )
119123 @employee . reload
120124 expect ( @employee . binary_data ) . to eq ( @binary_data )
121125 end
122126
123127 it "should allow equality on select" do
124128 TestEmployee . delete_all
125- TestEmployee . create! (
129+ employee = TestEmployee . create! (
126130 first_name : "First" ,
127131 last_name : "Last" ,
128132 binary_data : @binary_data ,
@@ -132,6 +136,20 @@ class ::TestEmployee < ActiveRecord::Base
132136 last_name : "Last1" ,
133137 binary_data : @binary_data2 ,
134138 )
135- expect ( TestEmployee . where ( binary_data : @binary_data ) ) . to have_attributes ( count : 1 )
139+ expect ( TestEmployee . where ( binary_data : @binary_data ) . to_a ) . to eq ( [ employee ] )
140+ end
141+
142+ it "should allow equality on select with NULL value" do
143+ TestEmployee . delete_all
144+ employee = TestEmployee . create! (
145+ first_name : "First" ,
146+ last_name : "Last" ,
147+ )
148+ TestEmployee . create! (
149+ first_name : "First1" ,
150+ last_name : "Last1" ,
151+ binary_data : @binary_data2 ,
152+ )
153+ expect ( TestEmployee . where ( binary_data : nil ) . to_a ) . to eq ( [ employee ] )
136154 end
137155end
0 commit comments