Skip to content

Commit

Permalink
unittests for Globus password reset aces#1391
Browse files Browse the repository at this point in the history
  • Loading branch information
MontrealSergiy committed May 14, 2024
1 parent 123566e commit 47ec6a8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion BrainPortal/spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,22 @@
expect(assigns[:user].password).not_to eq(user.password)
end

context "when the account must use Globus identification only only" do

it "should display a message" do
allow(mock_user).to receive(:account_locked?).and_return(true)
allow(User).to receive_message_chain(:where, :first).and_return(mock_user)
post :send_password, params: {:login => user.login, :email => user.email}
expect(flash[:error]).to match(/Globus/i)
end

end

context "when the account is locked" do

it "should display a message" do
allow(mock_user).to receive(:account_locked?).and_return(true)
allow(mock_user).to receive(:meta).and_return({ "allowed_globus_provider_names" => "" })
allow(User).to receive_message_chain(:where, :first).and_return(mock_user)
post :send_password, params: {:login => user.login, :email => user.email}
expect(flash[:error]).to match(/locked/i)
Expand All @@ -251,7 +263,11 @@
context "when reset fails" do

it "should display flash message about problem" do
mock_user = mock_model(User, :save => false, :account_locked? => false).as_null_object
mock_user = mock_model(User,
:save => false,
:account_locked? => false,
:meta => { "allowed_globus_provider_names" => "" }
).as_null_object
allow(User).to receive_message_chain(:where, :first).and_return(mock_user)
post :send_password
expect(flash[:error]).to match(/^Unable to reset password/)
Expand Down

0 comments on commit 47ec6a8

Please sign in to comment.