-
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathuser_passwords_controller_spec.rb
More file actions
45 lines (39 loc) · 1.48 KB
/
user_passwords_controller_spec.rb
File metadata and controls
45 lines (39 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
RSpec.describe Spree::UserPasswordsController, type: :controller do
let(:token) { 'some_token' }
before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
describe 'GET edit' do
context 'when the user token has not been specified' do
it 'redirects to the new session path' do
get :edit
expect(response).to redirect_to(
'http://test.host/login'
)
end
it 'flashes an error' do
get :edit
expect(flash[:alert]).to include(
"You can't access this page without coming from a password reset " \
'email'
)
end
end
context 'when the user token has been specified' do
it 'does something' do
get :edit, params: { reset_password_token: token }
expect(response.code).to eq('200')
end
end
end
context '#update' do
context 'when updating password with blank password' do
it 'shows error flash message, sets spree_user with token and re-displays password edit form' do
put :update, params: { spree_user: { password: '', password_confirmation: '', reset_password_token: token } }
expect(assigns(:spree_user).is_a?(Spree::User)).to eq true
expect(assigns(:spree_user).reset_password_token).to eq token
expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :user_passwords, :spree_user])
expect(response).to render_template :edit
end
end
end
end