Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Don't depend on database ordering for asset tests

test_should_edit_asset and test_should_update_asset were depending on
database-specific ordering of the newly added assets. Although these
tests worked with MySQL, they failed with PostgreSQL because an
unordered find does not necessarily return the first of the three
uploaded assets.

Instead, Asset.find was changed to Asset.find_by_filename to
specifically return the desired asset file. Asset.find_by_filename is
used instead of Asset.find(:order => :id) so that there is no dependence
on the order in which the three versions of the asset file are added.
  • Loading branch information...
1 parent 8d73a2a commit dd86ad9c22a3e6cc5eb97591997472d6b348b443 @davec davec committed with emk
Showing with 6 additions and 4 deletions.
  1. +6 −4 test/functional/admin/assets_controller_upload_test.rb
10 test/functional/admin/assets_controller_upload_test.rb
@@ -39,15 +39,17 @@ def test_should_sort_assets
def test_should_edit_asset
login_as :quentin
- process_upload ['logo.png']
- get :edit, :id => Asset.find(:first).id
+ upload_file = 'logo.png'
+ process_upload [upload_file]
+ get :edit, :id => Asset.find_by_filename(upload_file).id
assert_response :success
def test_should_update_asset
login_as :quentin
- process_upload ['logo.png']
- post :update, :id => Asset.find(:first).id, :asset => { :title => 'foo bar' }
+ upload_file = 'logo.png'
+ process_upload [upload_file]
+ post :update, :id => Asset.find_by_filename(upload_file).id, :asset => { :title => 'foo bar' }
assert_redirected_to assets_path
assert_valid assigns(:asset)
assert_equal 'foo bar', assigns(:asset).title

0 comments on commit dd86ad9

Please sign in to comment.
Something went wrong with that request. Please try again.