-
-
Save arbaouimehdi/d1d423e1532cb8dddba0c368ce2dc9e6 to your computer and use it in GitHub Desktop.
Devise testing controllers - minitest / rails4
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 SecretController < ApplicationController | |
before_filter :authenticate_user! | |
def show | |
end | |
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
require 'test_helper' | |
class SecretControllerTest < ActionController::TestCase | |
include Devise::TestHelpers | |
test "logged in should get show" do | |
sign_in users(:one) | |
get :show | |
assert_response :success | |
end | |
test "not authenticated should get redirect" do | |
get :show | |
assert_response :redirect | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment