spree/spree — Issue #1230: Updating a Product from the Admin Panel, on success, will redirect to the Product Detail view instead of the Admin Product Detail view
Author: domtancredi
Created: 2012-03-05 02:03:45+00:00
State: open

If you try to run the edit/products_spec.rb with the latest "edge" code, you might find it pass for the first test, and fail for the second:

Try:
bundle exec rspec spec/requests/admin/products/edit/products_spec.rb

The error is this:
Failures:

1) Product Details editing a product should handle permalink changes
Failure/Error: fill_in "product_permalink", :with => ''
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'product_permalink' found
# (eval):2:in `fill_in'
# ./spec/requests/admin/products/edit/products_spec.rb:44:in `block (3 levels) in '

Finished in 2.74 seconds
2 examples, 1 failure

I found this is because if you click "Update" on from the admin panel on a Product, it will redirect you to the Product Detail page.
i.e. from here:
http://localhost:3000/admin/products/ruby-baseball-jersey/edit
to here:
http://localhost:3000/products/ruby-baseball-jersey

If you update the product_rb. to have this, it will re-direct back to the product details page in the admin panel and the tests successfully pass:
fill_in "product_permalink", :with => 'random-permalink-value'
click_button "Update"
page.should have_content("successfully updated!")

visit spree.admin_path
click_link 'Products'
within('table.index tr:nth-child(2)') { click_link 'Edit' }
click_link 'Product Details'

fill_in "product_permalink", :with => ''
click_button "Update"
within('#product_permalink_field') { page.should have_content("can't be blank") }

But instead of modifying the test to make it work, it probably highlights this issue:

"Updating a Product from the Admin Panel, on success, will redirect to the Product Detail view instead of the Admin Product Detail view"

I'm working on setting up another test and thought I'd just mention this in case anyone could fix it. If I finish the localization bug test and fix / pull request, I can circle back to this one.