12
12
t . raw :binary_data , limit : 1024
13
13
end
14
14
end
15
- @binary_data = "\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 " * 100
15
+ @binary_data = ( "\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 " * 100 ) . freeze
16
16
@binary_data2 = "\1 \2 \3 \4 \5 \6 \7 \8 \9 \0 " * 100
17
17
end
18
18
@@ -38,6 +38,7 @@ class ::TestEmployee < ActiveRecord::Base
38
38
last_name : "Last" ,
39
39
binary_data : @binary_data
40
40
)
41
+ expect ( @employee . binary_data ) . to eq ( @binary_data )
41
42
@employee . reload
42
43
expect ( @employee . binary_data ) . to eq ( @binary_data )
43
44
end
@@ -51,6 +52,7 @@ class ::TestEmployee < ActiveRecord::Base
51
52
expect ( @employee . binary_data ) . to be_nil
52
53
@employee . binary_data = @binary_data
53
54
@employee . save!
55
+ expect ( @employee . binary_data ) . to eq ( @binary_data )
54
56
@employee . reload
55
57
expect ( @employee . binary_data ) . to eq ( @binary_data )
56
58
end
@@ -77,6 +79,7 @@ class ::TestEmployee < ActiveRecord::Base
77
79
@employee . reload
78
80
@employee . binary_data = @binary_data2
79
81
@employee . save!
82
+ expect ( @employee . binary_data ) . to eq ( @binary_data2 )
80
83
@employee . reload
81
84
expect ( @employee . binary_data ) . to eq ( @binary_data2 )
82
85
end
@@ -116,13 +119,14 @@ class ::TestEmployee < ActiveRecord::Base
116
119
@employee . reload
117
120
@employee . binary_data = @binary_data
118
121
@employee . save!
122
+ expect ( @employee . binary_data ) . to eq ( @binary_data )
119
123
@employee . reload
120
124
expect ( @employee . binary_data ) . to eq ( @binary_data )
121
125
end
122
126
123
127
it "should allow equality on select" do
124
128
TestEmployee . delete_all
125
- TestEmployee . create! (
129
+ employee = TestEmployee . create! (
126
130
first_name : "First" ,
127
131
last_name : "Last" ,
128
132
binary_data : @binary_data ,
@@ -132,6 +136,20 @@ class ::TestEmployee < ActiveRecord::Base
132
136
last_name : "Last1" ,
133
137
binary_data : @binary_data2 ,
134
138
)
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 ] )
136
154
end
137
155
end
0 commit comments