|
2 | 2 | require 'test_components' |
3 | 3 | require 'rspec-steps' |
4 | 4 |
|
5 | | -describe "polymorphic relationships", js: true, skip: 'wip' do |
| 5 | +describe "polymorphic relationships", js: true, skip: true do |
6 | 6 |
|
7 | 7 | before(:all) do |
8 | 8 | require 'pusher' |
@@ -175,10 +175,10 @@ def compare_to_server(model, expression, expected_result, load=true) |
175 | 175 | expect(server_side).to eq(expected_result) |
176 | 176 | if load |
177 | 177 | expect_promise("Hyperstack::Model.load { #{model.class}.find(#{model.id}).#{expression} }") |
178 | | - .to eq(expected_result) |
| 178 | + .to contain_exactly(*expected_result) |
179 | 179 | else |
180 | 180 | wait_for_ajax |
181 | | - expect_evaluate_ruby("#{model.class}.find(#{model.id}).#{expression}").to eq(expected_result) |
| 181 | + expect_evaluate_ruby("#{model.class}.find(#{model.id}).#{expression}").to contain_exactly(*expected_result) |
182 | 182 | end |
183 | 183 | end |
184 | 184 |
|
@@ -234,21 +234,26 @@ def compare_to_server(model, expression, expected_result, load=true) |
234 | 234 |
|
235 | 235 | it 'changing belongs to relationship on client' do |
236 | 236 | # not working yet |
237 | | - compare_to_server @picture11, 'imageable.name', 'imageable1' |
238 | | - compare_to_server @picture21, 'imageable.name', 'imageable2' |
239 | | - evaluate_promise do |
| 237 | + # compare_to_server @picture11, 'imageable.name', 'imageable1' |
| 238 | + # compare_to_server @picture21, 'imageable.name', 'imageable2' |
| 239 | + compare_to_server @imageable1, 'pictures.collect(&:name)', ['picture11', 'picture12'] |
| 240 | + compare_to_server @imageable2, 'pictures.collect(&:name)', ['picture21', 'picture22'] |
| 241 | + |
| 242 | + evaluate_ruby do |
240 | 243 | p = Picture.find(1) |
241 | 244 | p.imageable = Product.find(1) |
242 | 245 | p.save |
243 | 246 | end |
| 247 | + binding.pry |
244 | 248 | compare_to_server @imageable1, 'pictures.collect(&:name)', ['picture12'], false |
245 | | - compare_to_server @imageable2, 'pictures.collect(&:name)', ['picture21', 'picture22', 'picture11'], false |
| 249 | + compare_to_server @imageable2, 'pictures.collect(&:name)', ['picture11', 'picture21', 'picture22'], false |
246 | 250 | end |
247 | 251 |
|
248 | 252 | it 'changing belongs to relationship on server' do |
249 | 253 | # just debugging here... when id doesn't change we don't realize that data is changing |
250 | 254 | compare_to_server @imageable1, 'pictures.collect(&:name)', ['picture11', 'picture12'] |
251 | 255 | compare_to_server @imageable2, 'pictures.collect(&:name)', ['picture21', 'picture22'] |
| 256 | + |
252 | 257 | wait_for_ajax |
253 | 258 | p = Picture.find_by_name('picture11') |
254 | 259 | p.imageable = @imageable2 |
|
0 commit comments