2016-10-13 18:26:08 +02:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe Gestionnaires::PasswordsController, type: :controller do
|
|
|
|
before do
|
|
|
|
@request.env["devise.mapping"] = Devise.mappings[:gestionnaire]
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "update" do
|
2016-10-18 15:49:04 +02:00
|
|
|
context "unified login" do
|
2016-10-13 18:26:08 +02:00
|
|
|
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
|
|
|
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
|
|
|
|
|
|
|
before do
|
2016-10-18 15:49:04 +02:00
|
|
|
allow(Features).to receive(:unified_login).and_return(true)
|
2016-10-13 18:26:08 +02:00
|
|
|
@token = gestionnaire.send(:set_reset_password_token)
|
|
|
|
user # make sure it's created
|
|
|
|
end
|
|
|
|
|
|
|
|
it "also signs user in" do
|
2016-11-15 04:29:05 +01:00
|
|
|
put :update, params: {gestionnaire: {
|
2016-10-13 18:26:08 +02:00
|
|
|
reset_password_token: @token,
|
|
|
|
password: "supersecret",
|
|
|
|
password_confirmation: "supersecret",
|
2016-11-15 04:29:05 +01:00
|
|
|
}}
|
2016-10-13 18:26:08 +02:00
|
|
|
expect(subject.current_gestionnaire).to eq(gestionnaire)
|
|
|
|
expect(subject.current_user).to eq(user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|