demarches-normaliennes/spec/controllers/gestionnaires/passwords_controller_spec.rb

44 lines
1.4 KiB
Ruby
Raw Normal View History

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
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
let(:administrateur) { create(:administrateur, email: 'unique@plop.com', password: 'password') }
before do
@token = gestionnaire.send(:set_reset_password_token)
user # make sure it's created
administrateur # make sure it's created
end
it "also signs user in" do
put :update, params: {gestionnaire: {
reset_password_token: @token,
password: "supersecret",
2018-01-15 19:02:12 +01:00
password_confirmation: "supersecret"
}}
expect(subject.current_gestionnaire).to eq(gestionnaire)
expect(subject.current_user).to eq(user)
end
it "also signs administrateur in" do
2018-01-15 19:02:12 +01:00
put :update, params: {
gestionnaire: {
reset_password_token: @token,
password: "supersecret",
password_confirmation: "supersecret"
}
}
expect(subject.current_administrateur).to eq(administrateur)
expect(subject.current_user).to eq(user)
end
end
end
end