Created
August 17, 2011 12:23
-
-
Save lolmaus/1151430 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test_should_update_product(ProductsControllerTest) [/var/vhosts/ld.lolmaus.ru/test/functional/products_controller_test.rb:43]:
Expected block to return true value.