spree/spree — Issue #1181: spec fails
Author: mainameiz
Created: 2012-02-23 01:42:17+00:00
State: open

Spec `auth/spec/controllers/admin/admin_users_controller_spec.rb` fails on my machine
Tested with `1.9.3` and `1.9.3-falcon`
Output: `http://paste.pocoo.org/show/555298/`

Seems like `Spree::Admin::UsersController` in`auth/app/controllers/spree/admin/admin_users_controller_decorator.rb` does not inherit rescure_from CanCan::AccessDenied block from `Spree::BaseController` in `auth/app/controllers/spree/base_controller_decorator.rb`

When I have added

```ruby
Spree::Admin::UsersController.class_eval do
rescue_from Spree::User::DestroyWithOrdersError, :with => :user_destroy_with_orders_error

rescue_from CanCan::AccessDenied do |exception|
return unauthorized
end
end
```
everything is ok:

```
....

Finished in 0.37875 seconds
4 examples, 0 failures
```

It may be helpful:

```ruby
Spree::Admin::UsersController.class_eval do
rescue_from Spree::User::DestroyWithOrdersError, :with => :user_destroy_with_orders_error

rescue_from CanCan::AccessDenied do |exception|
pp self.rescue_handlers.inspect # <---- new line
return unauthorized
end
end
```

resulted:

```
."[[\"ActiveRecord::RecordNotFound\", :resource_not_found], [\"Spree::User::DestroyWithOrdersError\", :user_destroy_with_orders_error], [\"CanCan::AccessDenied\", #]]"
."[[\"ActiveRecord::RecordNotFound\", :resource_not_found], [\"Spree::User::DestroyWithOrdersError\", :user_destroy_with_orders_error], [\"CanCan::AccessDenied\", #]]"
."[[\"ActiveRecord::RecordNotFound\", :resource_not_found], [\"Spree::User::DestroyWithOrdersError\", :user_destroy_with_orders_error], [\"CanCan::AccessDenied\", #]]"
.

Finished in 0.35804 seconds
4 examples, 0 failures
```