Skip to content

Instantly share code, notes, and snippets.

@lolmaus
Created August 17, 2011 12:23
Show Gist options
  • Save lolmaus/1151430 to your computer and use it in GitHub Desktop.
Save lolmaus/1151430 to your computer and use it in GitHub Desktop.
class Product < ActiveRecord::Base
validates :title,
presence: true,
uniqueness: true
validates :price,
numericality: { greater_than_or_equal_to: 0.01 }
validates :image_url,
format: { with: %r{\.(gif|jpg|jpeg|png)$}i,
message: 'must be a URL for GIF, JPG or PNG image.', },
allow_blank: true
end
class ProductsControllerTest < ActionController::TestCase
setup do
@product = products(:one)
@update = { title: 'Lorem Ipsum',
description: 'Wibbles are fun!',
price: 19.95 }
end
# ...
test "should update product" do
put :update, :id => @product.to_param, :product => @update
assert_redirected_to product_path(assigns(:product))
end
# ...
end
@lolmaus
Copy link
Author

lolmaus commented Aug 17, 2011

test_should_update_product(ProductsControllerTest) [/var/vhosts/ld.lolmaus.ru/test/functional/products_controller_test.rb:43]:
Expected block to return true value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment