-
-
Save lporras/1468361 to your computer and use it in GitHub Desktop.
simple rails rsepc 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much for this gist. Helped me a lot and saved my time :)