Hi Lucas,
Thanks a lot for your answers.
I've read this one, but it seems not to cover minitest. Or maybe I'm
doing something wrong: I'm writing an integration test when this
documentation mentios controller tests only.
I want to test if a user can log into the application using devise
authentication. Should I use something different from an integration
test?
I tried many things [1], but I still can't do it.
> and
>
https://github.com/plataformatec/devise/wiki/How-To:-Sign-in-from-a-controller
I'm not sure I asked correctly, but I trying to test if a page is show
for a user that is signed in. If its not, then another page should be
rendered
> 2): you can use <%= Devise.bcrypt User, 'password' %> in your fixtures, so
> the password will be encrypted with the proper streches and the pepper if
> necessary.
That is exactly the line I was looking for! :D
[1] These are the "many" things I tried:
- I tried including the line
8<----------------------------------------------
include Devise::TestHelpers
---------------------------------------------->8
into the following files (one at time):
8<----------------------------------------------
test/test_helper.rb
test/integration/users_access_test.rb
---------------------------------------------->8
- I also tried adding those 2 lines inside my setup method:
8<----------------------------------------------
@request.env["devise.mapping"] = Devise.mappings[:admin]
sign_in @user
---------------------------------------------->8
Then I discovered that @request was nil. And I do not seem able to
create one request by:
8<----------------------------------------------
@request = ActionDispatch::TestRequest.new
(what should I include into helpers to make it work?)
---------------------------------------------->8
- I also tried adding:
8<----------------------------------------------
class ActionController::TestCase
include Devise::TestHelpers
end
---------------------------------------------->8
to my test/test_helper.rb file
But no success at all :(