lundi 9 septembre 2019

Why Session does not reset after changing auth salt in devise in test enviornment?

I want to write rspec for a feature in which when I change the authenticable_salt it resets the devise session. Here is a reference. It is working fine in the development enviornment but when I am trying to write a controller test it does not change the session.

I have overridden the Devise#authenticable_salt in app/model/user.rb

  def authenticatable_salt
   "#{super}#{email}"
  end

My rspec code looks like

it 'logs out user when email is changed' do
  sign_in_with_host(@user)
  expect(controller.current_user).to eq(@user)
  get :index
  @user.update_attribute(:email, 'somethingelse@mail.com')
  get :index
  expect(controller.current_user).to be_nil
end

In the above code you can see I have changed the salt by updating the email but the session before and updating the attribute is same in test env but when I check in the development server as soon as I update the email it resets the session.

NOTE: Please note that I am using rails3.2 version and devise 3.5.10.

Aucun commentaire:

Enregistrer un commentaire