> Looking around -- someone had a problem that the new object was not
> created or saved. One of the tests in products_controller_test.rb has
> no problem creating a new product.
>
> What am I missing?
try this.....
this may work
test "product_administartion_by_admin" do
category = Category.create(:name => 'Parts')
quentin = new_session_as(:quentin)
quentin.add_product
end
private
module ProductTestDSL
attr_writer :name
def add_product
params ={:product => {
:title => 'Clip',
:category_id => category.id,
:sku => 54321,
:desctription => 'some text',
:price => 8.71}}
post "/product/create", params
assert_response :redirect
follow_redirect!
assert_response :success
assert_template "/product/show"
return Product.find_by_title(parameters[:product][:title])
end
end
def new_session_as(name)
open_session do |session|
session.extend(ProductTestDSL)
session.name = name
yield session if block_given?
end
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---