2016-10-13 18:26:08 +02:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe Users::PasswordsController, type: :controller do
|
|
|
|
before do
|
|
|
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
|
|
|
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(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
|
|
|
|
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
|
2016-12-07 17:35:45 +01:00
|
|
|
let(:administrateur) { create(:administrateur, email: 'unique@plop.com', password: 'password') }
|
2016-10-13 18:26:08 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
@token = user.send(:set_reset_password_token)
|
|
|
|
gestionnaire # make sure it's created
|
2016-12-07 17:35:45 +01:00
|
|
|
administrateur # make sure it's created
|
2016-10-13 18:26:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "also signs gestionnaire in" do
|
2016-11-15 05:54:27 +01:00
|
|
|
put :update, params: {user: {
|
|
|
|
reset_password_token: @token,
|
|
|
|
password: "supersecret",
|
|
|
|
password_confirmation: "supersecret",
|
|
|
|
}}
|
2016-10-13 18:26:08 +02:00
|
|
|
expect(subject.current_user).to eq(user)
|
|
|
|
expect(subject.current_gestionnaire).to eq(gestionnaire)
|
|
|
|
end
|
2016-12-07 17:35:45 +01:00
|
|
|
|
|
|
|
it "also signs administrateur in" do
|
|
|
|
put :update, params: {user: {
|
|
|
|
reset_password_token: @token,
|
|
|
|
password: "supersecret",
|
|
|
|
password_confirmation: "supersecret",
|
|
|
|
}}
|
|
|
|
expect(subject.current_user).to eq(user)
|
|
|
|
expect(subject.current_administrateur).to eq(administrateur)
|
|
|
|
end
|
2016-10-13 18:26:08 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|