spree_auth_devise 4.0.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of spree_auth_devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.circleci/config.yml +41 -0
- data/.gitignore +1 -0
- data/.travis.yml +33 -37
- data/Appraisals +3 -14
- data/Gemfile +1 -1
- data/README.md +3 -12
- data/Rakefile +9 -3
- data/app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb +20 -0
- data/app/controllers/spree/api/v2/storefront/passwords_controller.rb +35 -0
- data/app/controllers/spree/user_confirmations_controller.rb +38 -0
- data/app/controllers/spree/user_passwords_controller.rb +9 -1
- data/app/controllers/spree/user_registrations_controller.rb +34 -1
- data/app/controllers/spree/user_sessions_controller.rb +23 -1
- data/app/mailers/spree/user_mailer.rb +11 -4
- data/app/models/spree/user.rb +42 -0
- data/app/services/spree/account/create.rb +19 -0
- data/app/services/spree/account/update.rb +17 -0
- data/app/views/spree/user_mailer/confirmation_instructions.html.erb +20 -0
- data/app/views/spree/user_mailer/confirmation_instructions.text.erb +8 -5
- data/app/views/spree/user_mailer/reset_password_instructions.html.erb +20 -0
- data/app/views/spree/user_mailer/reset_password_instructions.text.erb +7 -5
- data/app/views/spree/user_passwords/edit.html.erb +20 -17
- data/app/views/spree/user_passwords/new.html.erb +17 -15
- data/app/views/spree/user_registrations/new.html.erb +12 -17
- data/app/views/spree/user_sessions/new.html.erb +11 -12
- data/config/locales/de.yml +16 -0
- data/config/locales/en.yml +21 -6
- data/config/locales/zh-TW.yml +58 -0
- data/config/routes.rb +12 -3
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -2
- data/gemfiles/{spree_3_2.gemfile → spree_4_1.gemfile} +1 -1
- data/lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb +41 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +3 -2
- data/lib/controllers/frontend/spree/users_controller.rb +4 -4
- data/lib/generators/spree/auth/install/install_generator.rb +0 -4
- data/lib/spree/auth/engine.rb +14 -1
- data/lib/spree/testing_support/auth_helpers.rb +36 -0
- data/lib/spree/testing_support/checkout_helpers.rb +24 -0
- data/lib/spree_auth_devise.rb +0 -1
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +1 -1
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +1 -1
- data/spec/controllers/spree/admin/orders_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/user_sessions_controller_spec.rb +1 -1
- data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +63 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +12 -13
- data/spec/controllers/spree/products_controller_spec.rb +1 -1
- data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -4
- data/spec/controllers/spree/user_registrations_controller_spec.rb +8 -8
- data/spec/controllers/spree/user_sessions_controller_spec.rb +17 -17
- data/spec/controllers/spree/users_controller_spec.rb +4 -4
- data/spec/features/account_spec.rb +10 -8
- data/spec/features/admin/password_reset_spec.rb +2 -4
- data/spec/features/admin/sign_in_spec.rb +13 -9
- data/spec/features/admin/sign_out_spec.rb +1 -1
- data/spec/features/admin_permissions_spec.rb +1 -1
- data/spec/features/change_email_spec.rb +1 -7
- data/spec/features/checkout_spec.rb +40 -65
- data/spec/features/confirmation_spec.rb +4 -6
- data/spec/features/order_spec.rb +9 -15
- data/spec/features/password_reset_spec.rb +2 -4
- data/spec/features/sign_in_spec.rb +21 -17
- data/spec/features/sign_out_spec.rb +14 -23
- data/spec/features/sign_up_spec.rb +6 -4
- data/spec/mailers/user_mailer_spec.rb +4 -4
- data/spec/models/user_spec.rb +10 -8
- data/spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb +48 -0
- data/spec/requests/spree/api/v2/storefront/account_spec.rb +101 -0
- data/spec/spec_helper.rb +7 -22
- data/spree_auth_devise.gemspec +14 -27
- metadata +35 -337
- data/app/overrides/auth_shared_login_bar.rb +0 -6
- data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +0 -4
- data/app/views/spree/shared/_login.html.erb +0 -18
- data/app/views/spree/shared/_user_form.html.erb +0 -17
- data/gemfiles/spree_3_5.gemfile +0 -8
- data/gemfiles/spree_3_7.gemfile +0 -9
- data/gemfiles/spree_4_0.gemfile +0 -8
- data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +0 -1
- data/lib/assets/javascripts/spree/frontend/account.js +0 -8
- data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +0 -2
- data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +0 -3
- data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +0 -3
- data/lib/controllers/frontend/spree/store_controller_decorator.rb +0 -7
- data/lib/views/frontend/spree/checkout/_new_user.html.erb +0 -20
- data/lib/views/frontend/spree/checkout/registration.html.erb +0 -25
- data/lib/views/frontend/spree/shared/_link_to_account.html.erb +0 -6
- data/lib/views/frontend/spree/users/edit.html.erb +0 -17
- data/lib/views/frontend/spree/users/show.html.erb +0 -48
- data/spec/support/add_to_cart.rb +0 -15
- data/spec/support/authentication_helpers.rb +0 -14
- data/spec/support/cache_helpers.rb +0 -5
- data/spec/support/capybara.rb +0 -16
- data/spec/support/database_cleaner.rb +0 -17
- data/spec/support/factory_girl.rb +0 -5
- data/spec/support/spree.rb +0 -10
data/config/routes.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Spree::Core::Engine.add_routes do
|
2
2
|
devise_for :spree_user,
|
3
|
-
class_name:
|
3
|
+
class_name: Spree.user_class.to_s,
|
4
4
|
controllers: { sessions: 'spree/user_sessions',
|
5
5
|
registrations: 'spree/user_registrations',
|
6
6
|
passwords: 'spree/user_passwords',
|
@@ -27,12 +27,11 @@ Spree::Core::Engine.add_routes do
|
|
27
27
|
get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
|
28
28
|
put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration
|
29
29
|
|
30
|
-
get '/account_link' => 'store#account_link'
|
31
30
|
resource :account, controller: 'users'
|
32
31
|
|
33
32
|
namespace :admin, path: Spree.admin_path do
|
34
33
|
devise_for :spree_user,
|
35
|
-
class_name:
|
34
|
+
class_name: Spree.user_class.to_s,
|
36
35
|
controllers: { sessions: 'spree/admin/user_sessions',
|
37
36
|
passwords: 'spree/admin/user_passwords' },
|
38
37
|
skip: [:unlocks, :omniauth_callbacks, :registrations],
|
@@ -45,4 +44,14 @@ Spree::Core::Engine.add_routes do
|
|
45
44
|
get '/logout' => 'user_sessions#destroy', :as => :logout
|
46
45
|
end
|
47
46
|
end
|
47
|
+
|
48
|
+
namespace :api, defaults: { format: 'json' } do
|
49
|
+
namespace :v2 do
|
50
|
+
namespace :storefront do
|
51
|
+
resource :account, controller: :account, only: %i[show create update]
|
52
|
+
resources :account_confirmations, only: %i[show]
|
53
|
+
resources :passwords, controller: :passwords, only: %i[create update]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
48
57
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AddResetPasswordSentAtToSpreeUsers < SpreeExtension::Migration[4.2]
|
2
2
|
def change
|
3
|
-
Spree
|
4
|
-
unless Spree
|
3
|
+
Spree.user_class.reset_column_information
|
4
|
+
unless Spree.user_class.column_names.include?("reset_password_sent_at")
|
5
5
|
add_column :spree_users, :reset_password_sent_at, :datetime
|
6
6
|
end
|
7
7
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Spree
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
module Storefront
|
5
|
+
module AccountControllerDecorator
|
6
|
+
def self.prepended(base)
|
7
|
+
base.skip_before_action :require_spree_current_user, only: [:create]
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
result = Spree::Account::Create.call(user_params: spree_user_params)
|
12
|
+
|
13
|
+
render_payload(result)
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
result = Spree::Account::Update.call(user: spree_current_user, user_params: spree_user_params)
|
18
|
+
|
19
|
+
render_payload(result)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def render_payload(result)
|
25
|
+
if result.success?
|
26
|
+
render_serialized_payload { serialize_resource(result.value) }
|
27
|
+
else
|
28
|
+
render_error_payload(result.error)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def spree_user_params
|
33
|
+
params.require(:user).permit(Spree::PermittedAttributes.user_attributes)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
::Spree::Api::V2::Storefront::AccountController.prepend(Spree::Api::V2::Storefront::AccountControllerDecorator)
|
@@ -6,7 +6,8 @@ module Spree::CheckoutControllerDecorator
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def registration
|
9
|
-
@user = Spree
|
9
|
+
@user = Spree.user_class.new
|
10
|
+
@title = Spree.t(:registration)
|
10
11
|
end
|
11
12
|
|
12
13
|
def update_registration
|
@@ -14,7 +15,7 @@ module Spree::CheckoutControllerDecorator
|
|
14
15
|
redirect_to spree.checkout_state_path(:address)
|
15
16
|
else
|
16
17
|
flash[:error] = t(:email_is_invalid, scope: [:errors, :messages])
|
17
|
-
@user = Spree
|
18
|
+
@user = Spree.user_class.new
|
18
19
|
render 'registration'
|
19
20
|
end
|
20
21
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Spree::UsersController < Spree::StoreController
|
2
|
-
|
2
|
+
before_action :set_current_order, except: :show
|
3
3
|
prepend_before_action :load_object, only: [:show, :edit, :update]
|
4
4
|
prepend_before_action :authorize_actions, only: :new
|
5
5
|
|
@@ -10,7 +10,7 @@ class Spree::UsersController < Spree::StoreController
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
-
@user = Spree
|
13
|
+
@user = Spree.user_class.new(user_params)
|
14
14
|
if @user.save
|
15
15
|
|
16
16
|
if current_order
|
@@ -27,7 +27,7 @@ class Spree::UsersController < Spree::StoreController
|
|
27
27
|
if @user.update(user_params)
|
28
28
|
if params[:user][:password].present?
|
29
29
|
# this logic needed b/c devise wants to log us out after password changes
|
30
|
-
Spree
|
30
|
+
Spree.user_class.reset_password_by_token(params[:user])
|
31
31
|
if Spree::Auth::Config[:signout_after_password_change]
|
32
32
|
sign_in(@user, event: :authentication)
|
33
33
|
else
|
@@ -52,7 +52,7 @@ class Spree::UsersController < Spree::StoreController
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def authorize_actions
|
55
|
-
authorize! params[:action].to_sym, Spree
|
55
|
+
authorize! params[:action].to_sym, Spree.user_class.new
|
56
56
|
end
|
57
57
|
|
58
58
|
def accurate_title
|
@@ -10,10 +10,6 @@ module Spree
|
|
10
10
|
paths.flatten
|
11
11
|
end
|
12
12
|
|
13
|
-
def add_javascripts
|
14
|
-
append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_auth\n"
|
15
|
-
end
|
16
|
-
|
17
13
|
def generate_devise_key
|
18
14
|
return if ENV['CI']
|
19
15
|
template 'config/initializers/devise.rb', 'config/initializers/devise.rb'
|
data/lib/spree/auth/engine.rb
CHANGED
@@ -42,7 +42,12 @@ module Spree
|
|
42
42
|
'lib/assets/javascripts/spree/frontend/spree_auth.js',
|
43
43
|
'lib/assets/javascripts/spree/frontend/spree_auth.css'
|
44
44
|
]
|
45
|
-
Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend
|
45
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/frontend/**/*_decorator*.rb")) do |c|
|
46
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
if Spree::Auth::Engine.api_available?
|
50
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../controllers/api/**/*_decorator*.rb")) do |c|
|
46
51
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
47
52
|
end
|
48
53
|
end
|
@@ -61,6 +66,10 @@ module Spree
|
|
61
66
|
@@frontend_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Frontend::Engine')
|
62
67
|
end
|
63
68
|
|
69
|
+
def self.api_available?
|
70
|
+
@@api_available ||= ::Rails::Engine.subclasses.map(&:instance).map{ |e| e.class.to_s }.include?('Spree::Api::Engine')
|
71
|
+
end
|
72
|
+
|
64
73
|
if backend_available?
|
65
74
|
paths["app/controllers"] << "lib/controllers/backend"
|
66
75
|
paths["app/views"] << "lib/views/backend"
|
@@ -71,6 +80,10 @@ module Spree
|
|
71
80
|
paths["app/views"] << "lib/views/frontend"
|
72
81
|
end
|
73
82
|
|
83
|
+
if api_available?
|
84
|
+
paths["app/controllers"] << "lib/controllers/api"
|
85
|
+
end
|
86
|
+
|
74
87
|
config.to_prepare &method(:activate).to_proc
|
75
88
|
end
|
76
89
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Spree
|
2
|
+
module TestingSupport
|
3
|
+
module AuthHelpers
|
4
|
+
def log_in(email:, password:, remember_me: true)
|
5
|
+
visit spree.login_path
|
6
|
+
|
7
|
+
fill_in 'Email', with: email
|
8
|
+
fill_in 'Password', with: password
|
9
|
+
|
10
|
+
# Regression test for #1257
|
11
|
+
first('label', text: 'Remember me').click if remember_me
|
12
|
+
click_button 'Log in'
|
13
|
+
|
14
|
+
expect(page).to have_content 'Logged in successfully'
|
15
|
+
end
|
16
|
+
|
17
|
+
def log_out
|
18
|
+
show_user_menu
|
19
|
+
click_link 'LOG OUT'
|
20
|
+
|
21
|
+
expect(page).to have_content 'Signed out successfully'
|
22
|
+
end
|
23
|
+
|
24
|
+
def show_user_menu
|
25
|
+
find("button[aria-label='Show user menu']").click
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_user_account
|
29
|
+
within '#nav-bar' do
|
30
|
+
show_user_menu
|
31
|
+
click_link 'MY ACCOUNT'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spree
|
2
|
+
module TestingSupport
|
3
|
+
module CheckoutHelpers
|
4
|
+
def fill_in_address
|
5
|
+
address = 'order_bill_address_attributes'
|
6
|
+
fill_in "#{address}_firstname", with: 'Ryan'
|
7
|
+
fill_in "#{address}_lastname", with: 'Bigg'
|
8
|
+
fill_in "#{address}_address1", with: '143 Swan Street'
|
9
|
+
fill_in "#{address}_city", with: 'Richmond'
|
10
|
+
select country.name, from: "#{address}_country_id"
|
11
|
+
select state.name, from: "#{address}_state_id"
|
12
|
+
fill_in "#{address}_zipcode", with: '12345'
|
13
|
+
fill_in "#{address}_phone", with: '(555) 555-5555'
|
14
|
+
end
|
15
|
+
|
16
|
+
def fill_in_credit_card_info(invalid: false)
|
17
|
+
fill_in 'name_on_card', with: 'Spree Commerce'
|
18
|
+
fill_in 'card_number', with: invalid ? '123' : '4111 1111 1111 1111'
|
19
|
+
fill_in 'card_expiry', with: '12 / 24'
|
20
|
+
fill_in 'card_code', with: '123'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/spree_auth_devise.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
7
7
|
|
8
|
-
<%= form_for Spree
|
8
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.reset_password_path do |f| %>
|
9
9
|
<p>
|
10
10
|
<%= f.label :email, Spree.t(:email) %><br />
|
11
11
|
<%= f.email_field :email %>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<div data-hook="login" class="card border-0">
|
6
6
|
<div class="card-body">
|
7
|
-
<%= form_for Spree
|
7
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_create_new_session_path do |f| %>
|
8
8
|
<div id="password-credentials">
|
9
9
|
<div class="form-group text-center">
|
10
10
|
<%= f.label :email, Spree.t(:email) %>
|
@@ -2,7 +2,7 @@ RSpec.describe Spree::Admin::UserSessionsController, type: :controller do
|
|
2
2
|
before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
|
3
3
|
|
4
4
|
describe '#authorization_failure' do
|
5
|
-
subject {
|
5
|
+
subject { get :authorization_failure }
|
6
6
|
|
7
7
|
context 'user signed in' do
|
8
8
|
before { allow(controller).to receive(:spree_current_user) { build_stubbed(:user) } }
|
@@ -0,0 +1,63 @@
|
|
1
|
+
RSpec.describe Spree::Api::V2::Storefront::PasswordsController, type: :controller do
|
2
|
+
let(:user) { create(:user) }
|
3
|
+
let(:password) { 'new_password' }
|
4
|
+
let(:store) { create(:store) }
|
5
|
+
|
6
|
+
describe 'POST create' do
|
7
|
+
before { post :create, params: params }
|
8
|
+
|
9
|
+
context 'when the user email has not been specified' do
|
10
|
+
let(:params) { { user: { email: '' } } }
|
11
|
+
it 'responds with not found status' do
|
12
|
+
expect(response.code).to eq('404')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when the user email not found' do
|
17
|
+
let(:params) { { user: { email: 'dummy_email@example.com' } } }
|
18
|
+
it 'responds with not found status' do
|
19
|
+
expect(response.code).to eq('404')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when the user email has been specified' do
|
24
|
+
let(:params) { { user: { email: user.email } } }
|
25
|
+
it_behaves_like 'returns 200 HTTP status'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'PATCH update' do
|
30
|
+
before { patch :update, params: params }
|
31
|
+
|
32
|
+
context 'when updating password with blank password' do
|
33
|
+
let(:params) {
|
34
|
+
{
|
35
|
+
id: user.send_reset_password_instructions(Spree::Store.current),
|
36
|
+
user: {
|
37
|
+
password: '',
|
38
|
+
password_confirmation: ''
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
it 'responds with error' do
|
44
|
+
expect(response.code).to eq('422')
|
45
|
+
expect(JSON.parse(response.body)['error']).to eq("Password can't be blank")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when updating password with specified password' do
|
50
|
+
let(:params) {
|
51
|
+
{
|
52
|
+
id: user.send_reset_password_instructions(Spree::Store.current),
|
53
|
+
user: {
|
54
|
+
password: password,
|
55
|
+
password_confirmation: password
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
it_behaves_like 'returns 200 HTTP status'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -19,14 +19,14 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
19
19
|
before { allow(controller).to receive(:spree_current_user) { user } }
|
20
20
|
|
21
21
|
it 'proceeds to the first checkout step' do
|
22
|
-
|
22
|
+
get :edit, params: { state: 'address' }
|
23
23
|
expect(response).to render_template :edit
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'when authenticated as guest' do
|
28
28
|
it 'redirects to registration step' do
|
29
|
-
|
29
|
+
get :edit, params: { state: 'address' }
|
30
30
|
expect(response).to redirect_to spree.checkout_registration_path
|
31
31
|
end
|
32
32
|
end
|
@@ -42,14 +42,14 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
42
42
|
before { allow(controller).to receive(:spree_current_user) { user } }
|
43
43
|
|
44
44
|
it 'proceeds to the first checkout step' do
|
45
|
-
|
45
|
+
get :edit, params: { state: 'address' }
|
46
46
|
expect(response).to render_template :edit
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'when authenticated as guest' do
|
51
51
|
it 'proceeds to the first checkout step' do
|
52
|
-
|
52
|
+
get :edit, params: { state: 'address' }
|
53
53
|
expect(response).to render_template :edit
|
54
54
|
end
|
55
55
|
end
|
@@ -81,9 +81,8 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
81
81
|
else
|
82
82
|
request.cookie_jar.signed[:guest_token] = 'ABC'
|
83
83
|
end
|
84
|
-
|
84
|
+
post :update, params: { state: 'confirm' }
|
85
85
|
expect(response).to redirect_to spree.order_path(order)
|
86
|
-
expect(flash.notice).to eq Spree.t(:order_processed_successfully)
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
@@ -99,7 +98,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
99
98
|
end
|
100
99
|
|
101
100
|
it 'redirects to the standard order view' do
|
102
|
-
|
101
|
+
post :update, params: { state: 'confirm' }
|
103
102
|
expect(response).to redirect_to spree.order_path(order)
|
104
103
|
end
|
105
104
|
end
|
@@ -110,7 +109,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
110
109
|
it 'does not check registration' do
|
111
110
|
allow(controller).to receive(:check_authorization)
|
112
111
|
expect(controller).not_to receive(:check_registration)
|
113
|
-
|
112
|
+
get :registration
|
114
113
|
end
|
115
114
|
|
116
115
|
it 'checks if the user is authorized for :edit' do
|
@@ -120,7 +119,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
120
119
|
else
|
121
120
|
request.cookie_jar.signed[:guest_token] = token
|
122
121
|
end
|
123
|
-
|
122
|
+
get :registration, params: {}
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
@@ -131,12 +130,12 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
131
130
|
controller.stub :check_authorization
|
132
131
|
order.stub update: true
|
133
132
|
controller.should_not_receive :check_registration
|
134
|
-
|
133
|
+
put :update_registration, params: { order: {} }
|
135
134
|
end
|
136
135
|
|
137
136
|
it 'renders the registration view if unable to save' do
|
138
137
|
allow(controller).to receive(:check_authorization)
|
139
|
-
|
138
|
+
put :update_registration, params: { order: { email: 'invalid' } }
|
140
139
|
expect(flash[:error]).to eq I18n.t(:email_is_invalid, scope: [:errors, :messages])
|
141
140
|
expect(response).to render_template :registration
|
142
141
|
end
|
@@ -144,7 +143,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
144
143
|
it 'redirects to the checkout_path after saving' do
|
145
144
|
allow(order).to receive(:update) { true }
|
146
145
|
allow(controller).to receive(:check_authorization)
|
147
|
-
|
146
|
+
put :update_registration, params: { order: { email: 'jobs@spreecommerce.com' } }
|
148
147
|
expect(response).to redirect_to spree.checkout_state_path(:address)
|
149
148
|
end
|
150
149
|
|
@@ -156,7 +155,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
156
155
|
end
|
157
156
|
allow(order).to receive(:update) { true }
|
158
157
|
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
159
|
-
|
158
|
+
put :update_registration, params: { order: { email: 'jobs@spreecommerce.com' } }
|
160
159
|
end
|
161
160
|
end
|
162
161
|
end
|