spree_auth_devise 4.0.1 → 4.1.0.rc1

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.

Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +41 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +3 -16
  5. data/Appraisals +3 -14
  6. data/Gemfile +1 -1
  7. data/app/controllers/spree/user_confirmations_controller.rb +2 -0
  8. data/app/controllers/spree/user_passwords_controller.rb +2 -0
  9. data/app/controllers/spree/user_registrations_controller.rb +9 -0
  10. data/app/controllers/spree/user_sessions_controller.rb +23 -1
  11. data/app/views/spree/user_passwords/edit.html.erb +20 -17
  12. data/app/views/spree/user_passwords/new.html.erb +18 -15
  13. data/app/views/spree/user_registrations/new.html.erb +12 -17
  14. data/app/views/spree/user_sessions/new.html.erb +11 -12
  15. data/config/routes.rb +0 -1
  16. data/gemfiles/{spree_3_5.gemfile → spree_4_1.gemfile} +1 -1
  17. data/lib/controllers/frontend/spree/users_controller.rb +2 -7
  18. data/lib/generators/spree/auth/install/install_generator.rb +0 -4
  19. data/lib/spree/testing_support/auth_helpers.rb +36 -0
  20. data/lib/spree/testing_support/checkout_helpers.rb +24 -0
  21. data/spec/controllers/spree/admin/orders_controller_spec.rb +1 -1
  22. data/spec/controllers/spree/admin/user_sessions_controller_spec.rb +1 -1
  23. data/spec/controllers/spree/checkout_controller_spec.rb +12 -13
  24. data/spec/controllers/spree/products_controller_spec.rb +1 -1
  25. data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -4
  26. data/spec/controllers/spree/user_registrations_controller_spec.rb +7 -7
  27. data/spec/controllers/spree/user_sessions_controller_spec.rb +17 -17
  28. data/spec/controllers/spree/users_controller_spec.rb +4 -4
  29. data/spec/features/account_spec.rb +10 -8
  30. data/spec/features/admin/password_reset_spec.rb +2 -4
  31. data/spec/features/admin/sign_in_spec.rb +5 -7
  32. data/spec/features/admin/sign_out_spec.rb +1 -1
  33. data/spec/features/admin_permissions_spec.rb +1 -1
  34. data/spec/features/change_email_spec.rb +1 -7
  35. data/spec/features/checkout_spec.rb +38 -63
  36. data/spec/features/confirmation_spec.rb +1 -3
  37. data/spec/features/order_spec.rb +9 -15
  38. data/spec/features/password_reset_spec.rb +2 -4
  39. data/spec/features/sign_in_spec.rb +7 -9
  40. data/spec/features/sign_out_spec.rb +16 -23
  41. data/spec/features/sign_up_spec.rb +4 -2
  42. data/spec/mailers/user_mailer_spec.rb +1 -1
  43. data/spec/spec_helper.rb +16 -0
  44. data/spec/support/add_to_cart.rb +11 -4
  45. data/spec/support/authentication_helpers.rb +1 -1
  46. data/spec/support/capybara.rb +15 -8
  47. data/spree_auth_devise.gemspec +13 -9
  48. metadata +100 -74
  49. data/app/overrides/auth_shared_login_bar.rb +0 -6
  50. data/app/views/spree/shared/_login.html.erb +0 -18
  51. data/app/views/spree/shared/_user_form.html.erb +0 -17
  52. data/gemfiles/spree_3_2.gemfile +0 -8
  53. data/gemfiles/spree_3_7.gemfile +0 -9
  54. data/gemfiles/spree_4_0.gemfile +0 -8
  55. data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +0 -1
  56. data/lib/assets/javascripts/spree/frontend/account.js +0 -8
  57. data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +0 -2
  58. data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +0 -3
  59. data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +0 -3
  60. data/lib/controllers/frontend/spree/store_controller_decorator.rb +0 -7
  61. data/lib/views/frontend/spree/checkout/_new_user.html.erb +0 -20
  62. data/lib/views/frontend/spree/checkout/registration.html.erb +0 -25
  63. data/lib/views/frontend/spree/shared/_link_to_account.html.erb +0 -6
  64. data/lib/views/frontend/spree/users/edit.html.erb +0 -17
  65. data/lib/views/frontend/spree/users/show.html.erb +0 -48
  66. data/spec/requests/spree/frontend/user_update_spec.rb +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a4c46da7628319c592ae1a9675173fd8add8ca34dbb6fd7d5ffdb92345207c2
4
- data.tar.gz: e6d9d38bc3e2fa09ff21fc024193160d04f2ba89c4439d8703b6a19f058a6fcd
3
+ metadata.gz: 11fab6b968334f977554a9a95b6a80e37047b42add498201ea0db74ca0701a6a
4
+ data.tar.gz: cab55c1d0e6344a72c5e11ee8621f43fce3787d99e412515bf9f8059a1727e7c
5
5
  SHA512:
6
- metadata.gz: 7f0c22c01027c613ab423d73af40ce43f02d4a14e26c76865ecd5a381943c2049366c52f2386697c4fa6a394c15d10b91da06b47d563a6f0081e897e948f77a5
7
- data.tar.gz: 235a7977bb12281f9c3a0f00c0b99b59f7ee63d609b34e413ab530b1e2fde43384bc82e0dce91b784abf8f3518ae72a61d022916ceaa110394466e1aff854f39
6
+ metadata.gz: 83bfc852ef5ac9cd03c19f6a9f8bcbdd17aac744d565102777f4ef1b2910f53d80b6663eee3d7f1dce2dc6f66f0e553270f366086f8e303963f995b72b9d8598
7
+ data.tar.gz: 66b5fe7c4364a068ee0b2169713480afb3b0064cc3c883f0ddbf6ee6086cd9b5caac2058b2c5c2cab9da82230a6441659df89ce071bc973a2278fd50a73e5341
@@ -0,0 +1,41 @@
1
+ version: 2
2
+
3
+ jobs:
4
+ update_staging_repository:
5
+ docker:
6
+ - image: circleci/ruby:2.6.3
7
+ steps:
8
+ - add_ssh_keys:
9
+ fingerprints:
10
+ - 54:50:5e:4e:80:6d:2e:26:43:c6:99:bd:39:b2:71:dc
11
+ - run: mkdir -p ~/.ssh
12
+ - run: ssh-keyscan -H github.com >> ~/.ssh/known_hosts
13
+ - run: ssh-add -D
14
+ - run: ssh-add ~/.ssh/id_rsa_54505e4e806d2e2643c699bd39b271dc
15
+ - run: git clone -b master git@github.com:spark-solutions/spree-designs.git
16
+ - run: gem install bundler -v 1.17.3
17
+ - run:
18
+ command: bundle update spree_auth_devise
19
+ working_directory: ~/project/spree-designs
20
+ - run:
21
+ command: |
22
+ git config user.name 'AutoDeploy'
23
+ git config user.email 'autodeploy@sparksolutions.co'
24
+ working_directory: ~/project/spree-designs
25
+ - run:
26
+ command: |
27
+ git add -A
28
+ git commit -m "Auto-commit v#${CIRCLE_BUILD_NUM}"
29
+ working_directory: ~/project/spree-designs
30
+ - run:
31
+ command: git push origin master
32
+ working_directory: ~/project/spree-designs
33
+
34
+ workflows:
35
+ version: 2
36
+ update_staging_repository:
37
+ jobs:
38
+ - update_staging_repository:
39
+ filters:
40
+ branches:
41
+ only: master
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ public/spree
20
20
  .ruby-gemset
21
21
  gemfiles/*.gemfile.lock
22
22
  *.gem
23
+ .bundle
data/.travis.yml CHANGED
@@ -17,31 +17,18 @@ language: ruby
17
17
 
18
18
  rvm:
19
19
  - 2.5.1
20
- - 2.4.4
21
- - 2.3.8
20
+ # - 2.6.5
22
21
 
23
22
  gemfile:
24
- - gemfiles/spree_3_5.gemfile
25
- - gemfiles/spree_3_7.gemfile
26
- - gemfiles/spree_4_0.gemfile
23
+ - gemfiles/spree_4_1.gemfile
27
24
  - gemfiles/spree_master.gemfile
28
25
 
29
26
  matrix:
30
27
  allow_failures:
31
28
  - gemfile: gemfiles/spree_master.gemfile
32
- exclude:
33
- - rvm: 2.3.8
34
- gemfile: gemfiles/spree_4_0.gemfile
35
- - rvm: 2.4.4
36
- gemfile: gemfiles/spree_4_0.gemfile
37
- - rvm: 2.3.8
38
- gemfile: gemfiles/spree_master.gemfile
39
- - rvm: 2.4.4
40
- gemfile: gemfiles/spree_master.gemfile
41
- - rvm: 2.5.1
42
- gemfile: gemfiles/spree_3_5.gemfile
43
29
 
44
30
  before_install:
31
+ - gem update bundler
45
32
  - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
46
33
  - wget -N https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip -P ~/
47
34
  - unzip ~/chromedriver_linux64.zip -d ~/
data/Appraisals CHANGED
@@ -1,20 +1,9 @@
1
- appraise 'spree-3-5' do
2
- gem 'spree', '~> 3.5.0'
3
- gem 'rails-controller-testing'
4
- end
5
-
6
- appraise 'spree-3-7' do
7
- gem 'sass-rails'
8
- gem 'spree', '~> 3.7.0'
9
- gem 'rails-controller-testing'
10
- end
11
-
12
- appraise 'spree-4-0' do
13
- gem 'spree', '~> 4.0.0.rc2'
1
+ appraise 'spree-4-1' do
14
2
  gem 'rails-controller-testing'
3
+ gem 'spree', github: 'spree/spree', branch: 'master'
15
4
  end
16
5
 
17
6
  appraise 'spree-master' do
18
- gem 'spree', github: 'spree/spree', branch: 'master'
19
7
  gem 'rails-controller-testing'
8
+ gem 'spree', github: 'spree/spree', branch: 'master'
20
9
  end
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "rails-controller-testing"
3
+ gem 'rails-controller-testing'
4
4
  gem 'spree', github: 'spree/spree', branch: 'master'
5
5
 
6
6
  gemspec
@@ -6,6 +6,8 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
+ before_action :set_current_order
10
+
9
11
  protected
10
12
 
11
13
  def after_confirmation_path_for(resource_name, resource)
@@ -10,6 +10,8 @@ class Spree::UserPasswordsController < Devise::PasswordsController
10
10
  include SpreeI18n::ControllerLocaleHelper
11
11
  end
12
12
 
13
+ before_action :set_current_order
14
+
13
15
  # Overridden due to bug in Devise.
14
16
  # respond_with resource, :location => new_session_path(resource_name)
15
17
  # is generating bad url /session/new.user
@@ -11,6 +11,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
11
11
  end
12
12
 
13
13
  before_action :check_permissions, only: [:edit, :update]
14
+ before_action :set_current_order
14
15
  skip_before_action :require_no_authentication
15
16
 
16
17
  # GET /resource/sign_up
@@ -75,9 +76,17 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
75
76
  'devise.user_registrations'
76
77
  end
77
78
 
79
+ def after_sign_up_path_for(resource)
80
+ after_sign_in_redirect(resource) if is_navigational_format?
81
+ end
82
+
78
83
  private
79
84
 
80
85
  def spree_user_params
81
86
  params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
82
87
  end
88
+
89
+ def after_sign_in_redirect(resource_or_scope)
90
+ stored_location_for(resource_or_scope) || account_path
91
+ end
83
92
  end
@@ -10,6 +10,8 @@ class Spree::UserSessionsController < Devise::SessionsController
10
10
  include SpreeI18n::ControllerLocaleHelper
11
11
  end
12
12
 
13
+ before_action :set_current_order
14
+
13
15
  def create
14
16
  authenticate_spree_user!
15
17
 
@@ -17,7 +19,7 @@ class Spree::UserSessionsController < Devise::SessionsController
17
19
  respond_to do |format|
18
20
  format.html {
19
21
  flash[:success] = Spree.t(:logged_in_succesfully)
20
- redirect_back_or_default(after_sign_in_path_for(spree_current_user))
22
+ redirect_back_or_default(after_sign_in_redirect(spree_current_user))
21
23
  }
22
24
  format.js {
23
25
  render json: { user: spree_current_user,
@@ -54,4 +56,24 @@ class Spree::UserSessionsController < Devise::SessionsController
54
56
  redirect_to(session["spree_user_return_to"] || default)
55
57
  session["spree_user_return_to"] = nil
56
58
  end
59
+
60
+ def after_sign_in_redirect(resource_or_scope)
61
+ stored_location_for(resource_or_scope) || account_path
62
+ end
63
+
64
+ def respond_to_on_destroy
65
+ # We actually need to hardcode this as Rails default responder doesn't
66
+ # support returning empty response on GET request
67
+ respond_to do |format|
68
+ format.all { head :no_content }
69
+ format.any(*navigational_formats) { redirect_to after_sign_out_redirect(resource_name) }
70
+ end
71
+ end
72
+
73
+ def after_sign_out_redirect(resource_or_scope)
74
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
75
+ router_name = Devise.mappings[scope].router_name
76
+ context = router_name ? send(router_name) : self
77
+ context.respond_to?(:login_path) ? context.login_path : "/"
78
+ end
57
79
  end
@@ -1,22 +1,25 @@
1
1
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
2
- <div class="col-lg-6 offset-lg-3">
3
- <div class="card mb-3">
4
- <div class="card-header">
5
- <h3 class="card-title mb-0 h6"><%= Spree.t(:change_your_password) %></h3>
6
- </div>
7
- <div class="card-body">
8
- <%= form_for @spree_user, :as => :spree_user, :url => spree.update_password_path, :method => :put do |f| %>
9
- <div class="form-group">
10
- <%= f.label :password, Spree.t(:password) %>
11
- <%= f.password_field :password, :class => "form-control" %>
12
- </div>
13
- <div class="form-group">
14
- <%= f.label :password_confirmation, Spree.t(:confirm_password) %>
15
- <%= f.password_field :password_confirmation, :class => "form-control" %>
2
+
3
+ <div class="container user-passwords">
4
+ <div class="row">
5
+ <div class="col-lg-6 offset-lg-3">
6
+ <div class="card mb-3 user-passwords-no-border">
7
+ <h3 class="spree-mb-large spree-mt-large spree-header"><%= Spree.t(:change_your_password) %></h3>
8
+ <div class="card-body">
9
+ <%= form_for @spree_user, as: :spree_user, url: spree.update_password_path, method: :put do |f| %>
10
+ <div class="form-group">
11
+ <%= f.label :password, Spree.t(:password), class: 'spree-flat-label' %>
12
+ <%= f.password_field :password, class: "spree-flat-input" %>
13
+ </div>
14
+ <div class="form-group">
15
+ <%= f.label :password_confirmation, Spree.t(:confirm_password), class: 'spree-flat-label' %>
16
+ <%= f.password_field :password_confirmation, class: "spree-flat-input" %>
17
+ </div>
18
+ <%= f.hidden_field :reset_password_token %>
19
+ <%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block spree-btn mt-2' %>
20
+ <% end %>
16
21
  </div>
17
- <%= f.hidden_field :reset_password_token %>
18
- <%= f.submit Spree.t(:update), :class => 'btn btn-lg btn-success btn-block' %>
19
- <% end %>
22
+ </div>
20
23
  </div>
21
24
  </div>
22
25
  </div>
@@ -1,21 +1,24 @@
1
1
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
2
- <div class="col-lg-6 offset-lg-3" id="forgot-password">
3
- <div class="card mb-3">
4
- <div class="card-header">
5
- <h3 class="card-title mb-0 h6"><%= Spree.t(:forgot_password) %></h3>
6
- </div>
7
- <div class="card-body">
8
- <p><%= Spree.t(:instructions_to_reset_password) %></p>
9
2
 
10
- <%= form_for Spree::User.new, :as => :spree_user, :url => spree.reset_password_path do |f| %>
11
- <div class="form-group">
12
- <%= f.label :email, Spree.t(:email) %>
13
- <%= f.email_field :email, :class => "form-control" %>
14
- </div>
15
- <div>
16
- <%= f.submit Spree.t(:reset_password), :class => 'btn btn-lg btn-success btn-block' %>
3
+ <div class="container user-passwords">
4
+ <div class="row">
5
+ <div class="col-lg-6 offset-lg-3" id="forgot-password">
6
+ <div class="card mb-3 user-passwords-no-border">
7
+ <h3 class="spree-mb-large spree-mt-large spree-header"><%= Spree.t(:forgot_password) %></h3>
8
+ <div class="card-body">
9
+ <p><%= Spree.t(:instructions_to_reset_password) %></p>
10
+
11
+ <%= form_for Spree::User.new, as: :spree_user, url: spree.reset_password_path do |f| %>
12
+ <div class="form-group">
13
+ <%= f.label :email, Spree.t(:email), class: 'spree-flat-label' %>
14
+ <%= f.email_field :email, class: "spree-flat-input" %>
15
+ </div>
16
+ <div>
17
+ <%= f.submit Spree.t(:reset_password), class: 'btn btn-primary btn-block spree-btn mt-2' %>
18
+ </div>
19
+ <% end %>
17
20
  </div>
18
- <% end %>
21
+ </div>
19
22
  </div>
20
23
  </div>
21
24
  </div>
@@ -1,22 +1,17 @@
1
1
  <% @body_id = 'signup' %>
2
- <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
2
+ <%= render partial: 'spree/shared/error_messages', locals: { target: @user } %>
3
3
  <div class="col-lg-6 offset-lg-3">
4
- <div class="card mb-3">
5
- <div class="card-header">
6
- <h3 class="card-title mb-0 h6"><%= Spree.t(:new_customer) %></h3>
7
- </div>
8
- <div id="new-customer" class="card-body" data-hook="login">
9
- <%= form_for resource, :as => :spree_user, :url => spree.registration_path do |f| %>
10
- <div data-hook="signup_inside_form">
11
- <%= render :partial => 'spree/shared/user_form', :locals => { :f => f } %>
12
- <div><%= f.submit Spree.t(:create), :class => 'btn btn-lg btn-success btn-block' %></div>
13
- </div>
14
- <% end %>
15
- <div class="text-center">
16
- <%= Spree.t(:or) %>
17
- <%= link_to Spree.t(:login_as_existing), spree.login_path %>
18
- </div>
19
- <div data-hook="login_extras"></div>
4
+ <h3 class="spree-header spree-mb-large spree-mt-large"><%= Spree.t(:new_customer) %></h3>
5
+ <div id="new-customer" data-hook="login">
6
+ <%= form_for resource, as: :spree_user, url: spree.registration_path do |f| %>
7
+ <div data-hook="signup_inside_form">
8
+ <%= render partial: 'spree/shared/user_form', locals: { f: f, remember_me_field: true } %>
9
+ <div><%= f.submit Spree.t(:sign_up), class: 'btn btn-primary btn-block spree-btn mb-5' %></div>
20
10
  </div>
11
+ <% end %>
12
+
13
+ <h3 class="spree-header header-sm spree-mt-medium mb-3 mb-sm-4 mb-xl-4"><%= Spree.t('already_have_account') %></h3>
14
+ <%= link_to Spree.t(:log_in), spree.login_path, class: 'btn btn-block btn-outline-primary spree-btn spree-mb-large' %>
15
+ <div data-hook="login_extras"></div>
21
16
  </div>
22
17
  </div>
@@ -1,17 +1,16 @@
1
1
  <% @body_id = 'login' %>
2
- <div class="col-lg-6 <%= request.path == spree.login_path ? "offset-lg-3" : "" %>">
3
- <div class="card mb-3">
4
- <div class="card-header">
5
- <h3 class="card-title mb-0 h6"><%= Spree.t(:login_as_existing) %></h3>
6
- </div>
7
- <div id="existing-customer" class="card-body" data-hook="login">
8
- <%= render :partial => 'spree/shared/login' %>
9
- <div class="text-center">
10
- <%= Spree.t(:or) %>
11
- <%= link_to Spree.t(:create_a_new_account), spree.signup_path %> |
12
- <%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
13
- </div>
2
+ <div class="container user-sessions user-sessions-new">
3
+ <div class="row">
4
+ <div class="col-lg-6 offset-lg-3">
5
+ <div class="mb-3">
6
+ <div id="existing-customer" data-hook="login">
7
+ <%= render partial: 'spree/shared/login' %>
14
8
  <div data-hook="login_extras"></div>
9
+ </div>
10
+ <div class="col-lg-11 mx-auto" data-hook="registration">
11
+ <%= render partial: 'spree/shared/registration', locals: { registration_button: 'registration-button' } %>
12
+ </div>
15
13
  </div>
14
+ </div>
16
15
  </div>
17
16
  </div>
data/config/routes.rb CHANGED
@@ -27,7 +27,6 @@ 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
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails-controller-testing"
6
- gem "spree", "~> 3.5.0"
6
+ gem "spree", github: "spree/spree", branch: "master"
7
7
 
8
8
  gemspec path: "../"
@@ -1,11 +1,11 @@
1
1
  class Spree::UsersController < Spree::StoreController
2
- skip_before_action :set_current_order, only: :show
2
+ before_action :set_current_order, except: :show
3
+ prepend_before_action :load_object, only: [:show, :edit, :update]
3
4
  prepend_before_action :authorize_actions, only: :new
4
5
 
5
6
  include Spree::Core::ControllerHelpers
6
7
 
7
8
  def show
8
- load_object
9
9
  @orders = @user.orders.complete.order('completed_at desc')
10
10
  end
11
11
 
@@ -23,12 +23,7 @@ skip_before_action :set_current_order, only: :show
23
23
  end
24
24
  end
25
25
 
26
- def edit
27
- load_object
28
- end
29
-
30
26
  def update
31
- load_object
32
27
  if @user.update(user_params)
33
28
  if params[:user][:password].present?
34
29
  # this logic needed b/c devise wants to log us out after password changes
@@ -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'
@@ -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
@@ -5,7 +5,7 @@ module Spree
5
5
 
6
6
  context '#authorize_admin' do
7
7
  it 'grants access to users with an admin role' do
8
- spree_get :new
8
+ get :new
9
9
  expect(response).to redirect_to spree.cart_admin_order_path(Order.last)
10
10
  end
11
11
  end
@@ -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 { spree_get :authorization_failure }
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) } }
@@ -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
- spree_get :edit, { state: 'address' }
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
- spree_get :edit, { state: 'address' }
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
- spree_get :edit, { state: 'address' }
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
- spree_get :edit, { state: 'address' }
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
- spree_post :update, { state: 'confirm' }
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
- spree_post :update, { state: 'confirm' }
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
- spree_get :registration
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
- spree_get :registration, {}
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
- spree_put :update_registration, { order: {} }
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
- spree_put :update_registration, { order: { email: 'invalid' } }
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
- spree_put :update_registration, { order: { email: 'jobs@spreecommerce.com' } }
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
- spree_put :update_registration, { order: { email: 'jobs@spreecommerce.com' } }
158
+ put :update_registration, params: { order: { email: 'jobs@spreecommerce.com' } }
160
159
  end
161
160
  end
162
161
  end
@@ -2,7 +2,7 @@ RSpec.describe Spree::ProductsController, type: :controller do
2
2
  let!(:product) { create(:product, available_on: 1.year.from_now) }
3
3
  let!(:user) { build_stubbed(:user, spree_api_key: 'fake') }
4
4
 
5
- subject(:request) { spree_get :show, id: product.to_param }
5
+ subject(:request) { get :show, params: { id: product.to_param }}
6
6
 
7
7
  before do
8
8
  allow(controller).to receive(:before_save_new_order)