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
|
2018-01-25 10:50:06 +01:00
|
|
|
let(:user) { create(:user, email: 'unique@plop.com', password: 'mot de passe complexe') }
|
|
|
|
let(:administrateur) { create(:administrateur, email: 'unique@plop.com', password: 'mot de passe complexe') }
|
2016-10-13 18:26:08 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
@token = user.send(:set_reset_password_token)
|
2016-12-07 17:35:45 +01:00
|
|
|
administrateur # make sure it's created
|
2016-10-13 18:26:08 +02:00
|
|
|
end
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
it "also signs instructeur in" do
|
2018-01-15 19:02:12 +01:00
|
|
|
put :update, params: {
|
|
|
|
user: {
|
|
|
|
reset_password_token: @token,
|
2018-01-25 10:50:06 +01:00
|
|
|
password: "mot de passe super secret",
|
2018-10-01 14:06:08 +02:00
|
|
|
password_confirmation: "mot de passe super secret"
|
2018-01-15 19:02:12 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-13 18:26:08 +02:00
|
|
|
expect(subject.current_user).to eq(user)
|
2019-08-06 11:02:54 +02:00
|
|
|
expect(subject.current_instructeur.email).to eq(administrateur.email)
|
2016-10-13 18:26:08 +02:00
|
|
|
end
|
2016-12-07 17:35:45 +01:00
|
|
|
|
|
|
|
it "also signs administrateur in" do
|
2018-01-15 19:02:12 +01:00
|
|
|
put :update, params: {
|
|
|
|
user: {
|
|
|
|
reset_password_token: @token,
|
2018-01-25 10:50:06 +01:00
|
|
|
password: "mot de passe super secret",
|
2018-10-01 14:06:08 +02:00
|
|
|
password_confirmation: "mot de passe super secret"
|
2018-01-15 19:02:12 +01:00
|
|
|
}
|
|
|
|
}
|
2016-12-07 17:35:45 +01:00
|
|
|
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
|