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

43 lines
1.5 KiB
Ruby
Raw Normal View History

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
let(:user) { create(:user, email: 'unique@plop.com', password: 'password') }
let(:gestionnaire) { create(:gestionnaire, email: 'unique@plop.com', password: 'password') }
let(:administrateur) { create(:administrateur, 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)
@token = user.send(:set_reset_password_token)
gestionnaire # make sure it's created
administrateur # make sure it's created
end
it "also signs gestionnaire 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_gestionnaire).to eq(gestionnaire)
end
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
end
end
end