Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing callback function with devise integration #18

Closed
ckornaros opened this issue Mar 6, 2015 · 5 comments
Closed

Missing callback function with devise integration #18

ckornaros opened this issue Mar 6, 2015 · 5 comments

Comments

@ckornaros
Copy link

Hi,
I use your helper with devise for my test :

module FeatureHelpers
def logged_as(user)
page.set_rack_session('warden.user.user.key' => User.serialize_into_session(user).unshift("User"))
end
end

It works good but I notice that set_rack_session dosen't call the device callback function => "after_sign_in_path_for"
More information here : https://github.com/plataformatec/devise/wiki/How-To%3A-Redirect-to-a-specific-page-on-successful-sign-in-and-sign-out

Do you think you can fix this ?

By the way thank you for your good work :)

@ayanko
Copy link
Member

ayanko commented Mar 6, 2015

Hello.

And It shouldn't.

logged_as helper (as it name says) gives you ability to start your scenarios omitting boring authentication steps and thus speed up your scenarios a bit.

Write usual scenario if you want to test what happens with user on sign in . E.g

feature 'Login' do
  scenario 'User logs in to' do
    visit '/users/sign_in'
    fill_in :email, with: 'a@b.com'
    fill_in :password, with: 'secret'
    click_button 'Log in'
    expect(page).to have_content('After login...')
  end
end

Another tip: use rspec-example_steps for writing read-able acceptance scenarios.

.

@ckornaros
Copy link
Author

Hi,

I didn't agree when you say that it shouldn't, because what happend in "after_sign_in_path_for" can change expected values that you have to check after the login.

i.e. I'm a user (not logged in) and I have a cart with items. When I'm log in, I need that devise assign the cart to me. That's possible with "after_sign_in_path_for" and it will change the expected content of the page.

Maybe you have a work around for case like this ?

@ayanko
Copy link
Member

ayanko commented Mar 11, 2015

No. You are wrong. It's not an argument. Rack session access is and will be agnostic from any authentication gem. The goal is to provide read/write access to application session. Nothing more. No special magic for devise, authlogic or any gem.

The logged_as means state. It does not say how did you log in and what happens after that.
You are just logged in.

If you need to check special behavior after user is signed in - write corresponding scenarios (see above).
When you want to test scenarios for already logged in user use logged_as helper.

Thats all folks.

@karlingen
Copy link
Contributor

I totally agree with you @ayanko.

@ckornaros if you want after_sign_in_path_for to be triggered then you should be using the regular method for logging in (filling in login form).

@ayanko
Copy link
Member

ayanko commented Aug 24, 2015

Closed as invalid.

@ayanko ayanko closed this as completed Aug 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants