Skip to content

Instantly share code, notes, and snippets.

@tansengming
Created January 25, 2012 01:33
Show Gist options
  • Select an option

  • Save tansengming/1674026 to your computer and use it in GitHub Desktop.

Select an option

Save tansengming/1674026 to your computer and use it in GitHub Desktop.
Put this file into the spec/support dir and then include it into any controller spec that requires support for Devise
module SecureEndpointHelper
extend ActiveSupport::Concern
included do
include Devise::TestHelpers
before do
request.env["devise.mapping"] = Devise.mappings[:user]
setup_controller_for_warden
end
end
end
# in controller spec
# describe UsersController do
# include SecureEndpointHelper
# let(:user) { create(:user) }
# before { sign_in(:user, user) }
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment