Created
October 24, 2011 21:00
-
-
Save enthal/1310280 to your computer and use it in GitHub Desktop.
simple rails rspec testing that devise before_filter :authenticate_user! covers controller actions
This file contains 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 PeopleController < ApplicationController | |
before_filter :authenticate_user!, :except => [:index, :show] | |
... | |
end |
This file contains 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
describe PeopleController do | |
include Devise::TestHelpers | |
... | |
describe "disallow member-only actions when not logged in (guest/unprivileged)" do | |
let(:person) { Factory.create(:person) } | |
after { response.should redirect_to new_user_session_path } | |
it { get :new } | |
it { get :edit, :id => person } | |
it { post :create, :person => FactoryGirl.attributes_for(:person) } | |
it { put :update, :id => person, :person => {'these' => 'params'} } | |
it { delete :destroy, :id => person } | |
it { post :create_thing, :id => person, :what => 'stuff' } | |
end | |
end |
Iporras You need something like:
before :each do
@request.env["devise.mapping"] = Devise.mappings[:user]
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey man I tried to do this with Devise 1.5.2 and I got this: ArgumentError:uncaught throw :warden