Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails functional test with Devise authentication
    primarykey
    data
    text
    <p>I'm searching for a solution for a weird problem. I have a controller, that needs authentication (with the devise gem). I added the Devise TestHelpers but i can't get it working.</p> <pre><code>require 'test_helper' class KeysControllerTest &lt; ActionController::TestCase include Devise::TestHelpers fixtures :keys def setup @user = User.create!( :email =&gt; 'testuser@demomailtest.com', :password =&gt; 'MyTestingPassword', :password_confirmation =&gt; 'MyTestingPassword' ) sign_in @user @key = keys(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:keys) end test "should get new" do get :new assert_response :success end test "should create key" do assert_difference('Key.count') do post :create, :key =&gt; @key.attributes end assert_redirected_to key_path(assigns(:key)) end test "should destroy key" do assert_difference('Key.count', -1) do delete :destroy, :id =&gt; @key.to_param end assert_redirected_to keys_path end </code></pre> <p>end</p> <p>And i get the following output in my "rake test" window:</p> <pre><code>29) Failure: test_should_create_key(KeysControllerTest) [/test/functional/keys_controller_test.rb:29]: "Key.count" didn't change by 1. &lt;3&gt; expected but was &lt;2&gt;. 30) Failure: test_should_destroy_key(KeysControllerTest) [/test/functional/keys_controller_test.rb:37]: "Key.count" didn't change by -1. &lt;1&gt; expected but was &lt;2&gt;. 31) Failure: test_should_get_index(KeysControllerTest) [/test/functional/keys_controller_test.rb:19]: Expected response to be a &lt;:success&gt;, but was &lt;302&gt; 32) Failure: test_should_get_new(KeysControllerTest) [/test/functional/keys_controller_test.rb:25]: Expected response to be a &lt;:success&gt;, but was &lt;302&gt; </code></pre> <p>Can someone tell my, why devise doesn't authenticate? I'm using the exact same procedure for an AdminController and it works perfect. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload