Commit 90c996e42ee74b57d2d805ec6799c6501b780b3b
1 parent
d482447c
Exists in
master
and in
29 other branches
[performance] Fixing broken tests
Showing
4 changed files
with
16 additions
and
11 deletions
Show diff stats
app/models/article.rb
... | ... | @@ -192,7 +192,7 @@ class Article < ActiveRecord::Base |
192 | 192 | scoped_methods.last[:find] && |
193 | 193 | scoped_methods.last[:find][:joins] && |
194 | 194 | scoped_methods.last[:find][:joins].index('profiles') ) |
195 | - result.includes(:profile) | |
195 | + result = result.includes(:profile) | |
196 | 196 | end |
197 | 197 | |
198 | 198 | pagination ? result.paginate({:page => 1, :per_page => limit}) : result | ... | ... |
test/functional/profile_design_controller_test.rb
... | ... | @@ -322,11 +322,14 @@ class ProfileDesignControllerTest < ActionController::TestCase |
322 | 322 | should 'be able to save FeedReaderBlock configurations' do |
323 | 323 | @box1.blocks << FeedReaderBlock.new(:address => 'feed address') |
324 | 324 | holder.blocks(true) |
325 | + block = @box1.blocks.last | |
325 | 326 | |
326 | - post :save, :profile => 'designtestuser', :id => @box1.blocks[-1].id, :block => {:address => 'new feed address', :limit => '20'} | |
327 | + post :save, :profile => 'designtestuser', :id => block.id, :block => {:address => 'new feed address', :limit => '20'} | |
327 | 328 | |
328 | - assert_equal 'new feed address', @box1.blocks[-1].address | |
329 | - assert_equal 20, @box1.blocks[-1].limit | |
329 | + block.reload | |
330 | + | |
331 | + assert_equal 'new feed address', block.address | |
332 | + assert_equal 20, block.limit | |
330 | 333 | end |
331 | 334 | |
332 | 335 | should 'require login' do | ... | ... |
test/unit/boxes_helper_test.rb
... | ... | @@ -46,7 +46,8 @@ class BoxesHelperTest < ActiveSupport::TestCase |
46 | 46 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] |
47 | 47 | b.display = 'never'; b.save! |
48 | 48 | box = b.box |
49 | - box.expects(:blocks).returns([b]) | |
49 | + box.blocks = [b] | |
50 | + box.save! | |
50 | 51 | expects(:display_block).with(b, '') |
51 | 52 | expects(:request).returns(request) |
52 | 53 | stubs(:block_target).returns('') |
... | ... | @@ -64,7 +65,8 @@ class BoxesHelperTest < ActiveSupport::TestCase |
64 | 65 | b = p.blocks.select{|bk| !bk.kind_of?(MainBlock) }[0] |
65 | 66 | b.display = 'never'; b.save! |
66 | 67 | box = b.box |
67 | - box.expects(:blocks).returns([b]) | |
68 | + box.blocks = [b] | |
69 | + box.save! | |
68 | 70 | expects(:display_block).with(b, '').never |
69 | 71 | expects(:request).returns(request) |
70 | 72 | stubs(:block_target).returns('') |
... | ... | @@ -106,9 +108,7 @@ class BoxesHelperTest < ActiveSupport::TestCase |
106 | 108 | |
107 | 109 | should 'fill context with the article, request_path and locale' do |
108 | 110 | request = mock() |
109 | - box = mock() | |
110 | - | |
111 | - box.expects(:blocks).returns([]) | |
111 | + box = Box.create!(:owner => fast_create(Profile)) | |
112 | 112 | request.expects(:path).returns('/') |
113 | 113 | expects(:request).returns(request) |
114 | 114 | expects(:locale).returns('en') | ... | ... |
test/unit/enterprise_test.rb
... | ... | @@ -482,9 +482,11 @@ class EnterpriseTest < ActiveSupport::TestCase |
482 | 482 | |
483 | 483 | should 'reindex products with full category name after save' do |
484 | 484 | product = mock |
485 | + products = mock | |
485 | 486 | product.expects(:category_full_name) |
486 | - Enterprise.any_instance.stubs(:products).returns([product]) | |
487 | - Enterprise.expects(:solr_batch_add).with(includes(product)) | |
487 | + products.stubs(:includes).returns([product]) | |
488 | + Enterprise.any_instance.stubs(:products).returns(products) | |
489 | + Enterprise.expects(:solr_batch_add).with([products]) | |
488 | 490 | ent = fast_create(Enterprise) |
489 | 491 | ent.save! |
490 | 492 | end | ... | ... |