spree_auth_devise 3.5.2 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spree_auth_devise might be problematic. Click here for more details.

Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -1
  3. data/Appraisals +6 -0
  4. data/README.md +10 -2
  5. data/app/views/spree/shared/_login.html.erb +12 -12
  6. data/app/views/spree/user_passwords/edit.html.erb +5 -5
  7. data/app/views/spree/user_passwords/new.html.erb +5 -5
  8. data/app/views/spree/user_registrations/new.html.erb +6 -6
  9. data/app/views/spree/user_sessions/new.html.erb +6 -6
  10. data/config/initializers/devise.rb +1 -1
  11. data/config/locales/en.yml +1 -0
  12. data/gemfiles/spree_3_7.gemfile +1 -0
  13. data/gemfiles/spree_4_0.gemfile +8 -0
  14. data/lib/controllers/backend/spree/admin/{admin_controller_decorator.rb → base_controller_decorator.rb} +2 -1
  15. data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +6 -2
  16. data/lib/controllers/backend/spree/admin/{admin_orders_controller_decorator.rb → orders_controller_decorator.rb} +6 -2
  17. data/lib/controllers/backend/spree/admin/resource_controller_decorator.rb +6 -0
  18. data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +6 -3
  19. data/lib/controllers/frontend/spree/store_controller_decorator.rb +2 -1
  20. data/lib/views/backend/spree/admin/user_sessions/new.html.erb +4 -4
  21. data/lib/views/backend/spree/layouts/login.html.erb +2 -2
  22. data/lib/views/frontend/spree/checkout/_new_user.html.erb +5 -5
  23. data/lib/views/frontend/spree/checkout/registration.html.erb +6 -6
  24. data/lib/views/frontend/spree/shared/_link_to_account.html.erb +3 -3
  25. data/lib/views/frontend/spree/users/edit.html.erb +5 -5
  26. data/lib/views/frontend/spree/users/show.html.erb +3 -3
  27. data/spec/controllers/spree/checkout_controller_spec.rb +15 -3
  28. data/spec/controllers/spree/user_registrations_controller_spec.rb +20 -4
  29. data/spec/controllers/spree/user_sessions_controller_spec.rb +34 -8
  30. data/spec/features/checkout_spec.rb +1 -2
  31. data/spec/spec_helper.rb +6 -0
  32. data/spree_auth_devise.gemspec +4 -3
  33. metadata +30 -21
  34. data/lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45307062e764620c14c90a2e46698079e68fcc2cf4a275c9b68b4dd7c440e235
4
- data.tar.gz: 51a0e596192d24d194635e319ae70894d3d7ff9dcb098c7783c0b70f865f3a53
3
+ metadata.gz: 904e54a1d9b6ad58df3685c412031328c5eb7d2a3bde8c1d3682656adb8d91ba
4
+ data.tar.gz: 25ab57e3858000af1e81c594c8d01dde94d355b0f7379b38d399c914754fa4b5
5
5
  SHA512:
6
- metadata.gz: 0467202177d333b27390f4f6fd025e54d8600dfa514419a93d8f9d836740928d7226f8f89a841c215cd5b7e7a83e266bd04f06af4bddd0e961c4faf12d7d944e
7
- data.tar.gz: 9d362bd0a46360b6907526dfb50c193b2399551bcd64e7804a65521cc893fc50e49adaf01a7ac981530677dfab3db5345ae65a8f48eb835bd82d6a54378f9327
6
+ metadata.gz: eb3236f668fcaab30ac537ef5b8072082d00d0e205f432671c0e37a7af838b3ec13eb62563daef69b816aad29113521e0b743e386e87335a0fa6e70e7b65d0cd
7
+ data.tar.gz: 2f82564fcf9e5e7c36d38611fa45965922e02593b69caf1b2068224e4dd6f20fcbc1a6e5590741e7af5180777751e17525a9fe65a25f4091dcda9d11214e91b1
data/.travis.yml CHANGED
@@ -7,6 +7,7 @@ script:
7
7
 
8
8
  addons:
9
9
  chrome: stable
10
+ postgresql: 9.4
10
11
 
11
12
  env:
12
13
  - DB=mysql
@@ -23,11 +24,27 @@ gemfile:
23
24
  - gemfiles/spree_3_2.gemfile
24
25
  - gemfiles/spree_3_5.gemfile
25
26
  - gemfiles/spree_3_7.gemfile
27
+ - gemfiles/spree_4_0.gemfile
26
28
  - gemfiles/spree_master.gemfile
27
29
 
28
30
  matrix:
29
31
  allow_failures:
30
- - gemfile: gemfiles/spree_master.gemfile
32
+ - gemfile: gemfiles/spree_master.gemfile
33
+ exclude:
34
+ - rvm: 2.3.7
35
+ gemfile: gemfiles/spree_4_0.gemfile
36
+ - rvm: 2.4.4
37
+ gemfile: gemfiles/spree_4_0.gemfile
38
+ - rvm: 2.3.7
39
+ gemfile: gemfiles/spree_master.gemfile
40
+ - rvm: 2.4.4
41
+ gemfile: gemfiles/spree_master.gemfile
42
+ - rvm: 2.5.1
43
+ gemfile: gemfiles/spree_3_2.gemfile
44
+ - rvm: 2.5.1
45
+ gemfile: gemfiles/spree_3_2.gemfile
46
+ - rvm: 2.5.1
47
+ gemfile: gemfiles/spree_3_5.gemfile
31
48
 
32
49
  before_install:
33
50
  - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
data/Appraisals CHANGED
@@ -9,10 +9,16 @@ appraise 'spree-3-5' do
9
9
  end
10
10
 
11
11
  appraise 'spree-3-7' do
12
+ gem 'sass-rails'
12
13
  gem 'spree', '~> 3.7.0.rc3'
13
14
  gem 'rails-controller-testing'
14
15
  end
15
16
 
17
+ appraise 'spree-4-0' do
18
+ gem 'spree', github: 'spree/spree', tag: 'v4.0.0.beta'
19
+ gem 'rails-controller-testing'
20
+ end
21
+
16
22
  appraise 'spree-master' do
17
23
  gem 'spree', github: 'spree/spree', branch: 'master'
18
24
  gem 'rails-controller-testing'
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/spree/spree_auth_devise.svg?branch=master)](https://travis-ci.org/spree/spree_auth_devise)
4
4
  [![Code Climate](https://codeclimate.com/github/spree/spree_auth_devise/badges/gpa.svg)](https://codeclimate.com/github/spree/spree_auth_devise)
5
5
 
6
- Provides authentication services for Spree, using the Devise gem.
6
+ Provides authentication services for [Spree](https://spreecommerce.org), using the [Devise](https://github.com/plataformatec/devise) gem.
7
7
 
8
8
 
9
9
  ## Installation
@@ -119,10 +119,18 @@ This methodology can also be used by gems that extend spree and want/need to add
119
119
 
120
120
  If you encounter issues when using Ruby 2.5, please run:
121
121
 
122
- ```
122
+ ```bash
123
123
  bundle update devise
124
124
  ```
125
125
 
126
+ ### Creating the default Admin user
127
+
128
+ If you didn't created the Admin user from the installer you can run this rake task:
129
+
130
+ ```bash
131
+ bundle exec rake spree_auth:admin:create
132
+ ```
133
+
126
134
  ## Testing
127
135
 
128
136
  You need to do a quick one-time creation of a test application and then you can use it to run the tests.
@@ -1,18 +1,18 @@
1
1
  <%= form_for Spree::User.new, :as => :spree_user, :url => spree.create_new_session_path do |f| %>
2
2
  <div id="password-credentials">
3
- <div class="form-group">
3
+ <p>
4
4
  <%= f.label :email, Spree.t(:email) %>
5
- <%= f.email_field :email, placeholder: "#{Spree.t(:email)}", :class => 'form-control', :tabindex => 1, autofocus: true %>
6
- </div>
7
- <div class="form-group">
5
+ <%= f.email_field :email, :class => 'form-control', :tabindex => 1, autofocus: true %>
6
+ </p>
7
+ <p>
8
8
  <%= f.label :password, Spree.t(:password) %>
9
- <%= f.password_field :password, placeholder: "#{Spree.t(:password)}", :class => 'form-control', :tabindex => 2 %>
10
- </div>
11
- </div>
12
- <div>
13
- <%= f.check_box :remember_me, :tabindex => 3 %>
14
- <%= f.label :remember_me, Spree.t(:remember_me) %>
9
+ <%= f.password_field :password, :class => 'form-control', :tabindex => 2 %>
10
+ </p>
15
11
  </div>
12
+ <p class="form-check">
13
+ <%= f.check_box :remember_me, :tabindex => 3, :class => 'form-check-input' %>
14
+ <%= f.label :remember_me, Spree.t(:remember_me), :class => 'form-check-label' %>
15
+ </p>
16
16
 
17
- <div><%= f.submit Spree.t(:login), :class => 'btn btn-lg btn-success btn-block', :tabindex => 4 %></div>
18
- <% end %>
17
+ <p><%= f.submit Spree.t(:login), :class => 'btn btn-lg btn-success btn-block', :tabindex => 4 %></p>
18
+ <% end %>
@@ -1,10 +1,10 @@
1
1
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
2
- <div class="col-md-6 col-md-offset-3">
3
- <div class="panel panel-default">
4
- <div class="panel-heading">
5
- <h3 class="panel-title"><%= Spree.t(:change_your_password) %></h3>
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
6
  </div>
7
- <div class="panel-body">
7
+ <div class="card-body">
8
8
  <%= form_for @spree_user, :as => :spree_user, :url => spree.update_password_path, :method => :put do |f| %>
9
9
  <div class="form-group">
10
10
  <%= f.label :password, Spree.t(:password) %>
@@ -1,10 +1,10 @@
1
1
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @spree_user } %>
2
- <div class="col-md-6 col-md-offset-3" id="forgot-password">
3
- <div class="panel panel-default">
4
- <div class="panel-heading">
5
- <h3 class="panel-title"><%= Spree.t(:forgot_password) %></h3>
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
6
  </div>
7
- <div class="panel-body">
7
+ <div class="card-body">
8
8
  <p><%= Spree.t(:instructions_to_reset_password) %></p>
9
9
 
10
10
  <%= form_for Spree::User.new, :as => :spree_user, :url => spree.reset_password_path do |f| %>
@@ -1,11 +1,11 @@
1
1
  <% @body_id = 'signup' %>
2
2
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
3
- <div class="col-md-6 col-md-offset-3">
4
- <div class="panel panel-default">
5
- <div class="panel-heading">
6
- <h3 class="panel-title"><%= Spree.t(:new_customer) %></h3>
7
- </div>
8
- <div id="new-customer" class="panel-body" data-hook="login">
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
9
  <%= form_for resource, :as => :spree_user, :url => spree.registration_path do |f| %>
10
10
  <div data-hook="signup_inside_form">
11
11
  <%= render :partial => 'spree/shared/user_form', :locals => { :f => f } %>
@@ -1,10 +1,10 @@
1
1
  <% @body_id = 'login' %>
2
- <div class="col-md-6 <%= request.path == spree.login_path ? "col-md-offset-3" : "" %>">
3
- <div class="panel panel-default">
4
- <div class="panel-heading">
5
- <h3 class="panel-title"><%= Spree.t(:login_as_existing) %></h3>
6
- </div>
7
- <div id="existing-customer" class="panel-body" data-hook="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
8
  <%= render :partial => 'spree/shared/login' %>
9
9
  <div class="text-center">
10
10
  <%= Spree.t(:or) %>
@@ -40,7 +40,7 @@ Devise.setup do |config|
40
40
  config.stretches = 20
41
41
 
42
42
  # Setup a pepper to generate the encrypted password.
43
- config.pepper = Rails.configuration.secret_token
43
+ # config.pepper = '<%= SecureRandom.hex(64) %>'
44
44
 
45
45
  # ==> Configuration for :confirmable
46
46
  # The time you want to give your user to confirm his account. During this time
@@ -41,6 +41,7 @@ en:
41
41
  user_registrations:
42
42
  destroyed: Bye! Your account was successfully cancelled. We hope to see you again soon.
43
43
  inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
44
+ signed_up_but_unconfirmed: You have signed up successfully.
44
45
  signed_up: Welcome! You have signed up successfully.
45
46
  updated: You updated your account successfully.
46
47
  user_sessions:
@@ -4,5 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails-controller-testing"
6
6
  gem "spree", "~> 3.7.0.rc3"
7
+ gem "sass-rails"
7
8
 
8
9
  gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails-controller-testing"
6
+ gem "spree", github: "spree/spree", tag: "v4.0.0.beta"
7
+
8
+ gemspec path: "../"
@@ -1,4 +1,4 @@
1
- Spree::Admin::BaseController.class_eval do
1
+ module Spree::Admin::BaseControllerDecorator
2
2
  # Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
3
3
  # Override this method in your controllers if you want to have special behavior in case the user is not authorized
4
4
  # to access the requested action. For example, a popup window might simply close itself.
@@ -22,3 +22,4 @@ Spree::Admin::BaseController.class_eval do
22
22
  nil
23
23
  end
24
24
  end
25
+ Spree::Admin::BaseController.prepend(Spree::Admin::BaseControllerDecorator)
@@ -1,5 +1,8 @@
1
- Spree::Admin::Orders::CustomerDetailsController.class_eval do
2
- before_action :check_authorization
1
+ module Spree::Admin::Orders::CustomerDetailsControllerDecorator
2
+
3
+ def self.prepended(base)
4
+ base.before_action :check_authorization
5
+ end
3
6
 
4
7
  private
5
8
 
@@ -14,3 +17,4 @@ Spree::Admin::Orders::CustomerDetailsController.class_eval do
14
17
  authorize! action, resource, session[:access_token]
15
18
  end
16
19
  end
20
+ Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Admin::Orders::CustomerDetailsControllerDecorator)
@@ -1,5 +1,8 @@
1
- Spree::Admin::OrdersController.class_eval do
2
- before_action :check_authorization
1
+ module Spree::Admin::OrdersControllerDecorator
2
+
3
+ def self.prepended(base)
4
+ base.before_action :check_authorization
5
+ end
3
6
 
4
7
  private
5
8
 
@@ -19,3 +22,4 @@ Spree::Admin::OrdersController.class_eval do
19
22
  end
20
23
  end
21
24
  end
25
+ Spree::Admin::OrdersController.prepend(Spree::Admin::OrdersControllerDecorator)
@@ -0,0 +1,6 @@
1
+ module Spree::Admin::ResourceControllerDecorator
2
+ def self.prepended(base)
3
+ base.rescue_from CanCan::AccessDenied, with: :unauthorized
4
+ end
5
+ end
6
+ Spree::Admin::ResourceController.prepend(Spree::Admin::ResourceControllerDecorator)
@@ -1,7 +1,9 @@
1
1
  require 'spree/core/validators/email' if Spree.version.to_f < 3.5
2
- Spree::CheckoutController.class_eval do
3
- before_action :check_authorization
4
- before_action :check_registration, except: [:registration, :update_registration]
2
+ module Spree::CheckoutControllerDecorator
3
+ def self.prepended(base)
4
+ base.before_action :check_authorization
5
+ base.before_action :check_registration, except: [:registration, :update_registration]
6
+ end
5
7
 
6
8
  def registration
7
9
  @user = Spree::User.new
@@ -39,3 +41,4 @@ Spree::CheckoutController.class_eval do
39
41
  redirect_to spree.checkout_registration_path
40
42
  end
41
43
  end
44
+ Spree::CheckoutController.prepend(Spree::CheckoutControllerDecorator)
@@ -1,6 +1,7 @@
1
- Spree::StoreController.class_eval do
1
+ module Spree::StoreControllerDecorator
2
2
  def account_link
3
3
  render partial: 'spree/shared/link_to_account'
4
4
  fresh_when(spree_current_user)
5
5
  end
6
6
  end
7
+ Spree::StoreController.prepend(Spree::StoreControllerDecorator)
@@ -2,8 +2,8 @@
2
2
  <div class="alert alert-danger"><%= flash[:alert] %></div>
3
3
  <% end %>
4
4
 
5
- <div data-hook="login" class="panel">
6
- <div class="panel-body">
5
+ <div data-hook="login" class="card border-0">
6
+ <div class="card-body">
7
7
  <%= form_for Spree::User.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">
@@ -17,13 +17,13 @@
17
17
  </div>
18
18
  <div class="checkbox form-group">
19
19
  <div class="row">
20
- <div class="col-md-6">
20
+ <div class="col-lg-6">
21
21
  <%= f.label :remember_me do %>
22
22
  <%= f.check_box :remember_me, :tabindex => 3 %>
23
23
  <%= Spree.t(:remember_me) %>
24
24
  <% end %>
25
25
  </div>
26
- <div class="col-md-6 text-right">
26
+ <div class="col-lg-6 text-right">
27
27
  <%= link_to Spree.t(:forgot_password), spree.recover_password_path %>
28
28
  </div>
29
29
  </div>
@@ -8,11 +8,11 @@
8
8
  <%= render partial: 'spree/admin/shared/head' %>
9
9
  </head>
10
10
 
11
- <body>
11
+ <body class="pt-5">
12
12
  <div class="container">
13
13
 
14
14
  <div class="row">
15
- <div class="col-md-4 col-md-offset-4">
15
+ <div class="col-lg-6 offset-lg-3">
16
16
  <%= render partial: 'spree/admin/shared/header' %>
17
17
 
18
18
  <%= flash_alert(flash) %>
@@ -1,9 +1,9 @@
1
- <div class="col-md-6">
2
- <div class="panel panel-default">
3
- <div class="panel-heading">
4
- <h3 class="panel-title"><%= Spree.t(:create_a_new_account) %></h3>
1
+ <div>
2
+ <div class="card mb-3">
3
+ <div class="card-header">
4
+ <h3 class="card-title mb-0 h6"><%= Spree.t(:create_a_new_account) %></h3>
5
5
  </div>
6
- <div id="new-customer" class="panel-body" data-hook="login">
6
+ <div id="new-customer" class="card-body" data-hook="login">
7
7
  <%= form_for @user, :as => :spree_user, :url => spree.registration_path(@user) do |f| %>
8
8
  <div data-hook="signup_inside_form">
9
9
  <%= render :partial => 'spree/shared/user_form', :locals => { :f => f } %>
@@ -1,16 +1,16 @@
1
1
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
2
2
  <h1><%= Spree.t(:registration) %></h1>
3
3
  <div id="registration" class="row" data-hook>
4
- <div id="account">
4
+ <div id="account" class="col-lg-6">
5
5
  <%= render :partial => 'new_user' %>
6
6
  </div>
7
7
  <% if Spree::Config[:allow_guest_checkout] %>
8
- <div class="col-md-6">
9
- <div class="panel panel-default">
10
- <div class="panel-heading">
11
- <h3 class="panel-title"><%= Spree.t(:guest_user_account) %></h3>
8
+ <div class="col-lg-6">
9
+ <div class="card mb-3">
10
+ <div class="card-header">
11
+ <h3 class="card-title mb-0 h6"><%= Spree.t(:guest_user_account) %></h3>
12
12
  </div>
13
- <div id="guest_checkout" class="panel-body" data-hook>
13
+ <div id="guest_checkout" class="card-body" data-hook>
14
14
  <%= form_for @order, :url => update_checkout_registration_path, :method => :put, :html => { :id => 'checkout_form_registration' } do |f| %>
15
15
  <div class="form-group">
16
16
  <%= f.label :email, Spree.t(:email), class: 'required', title: 'required' %>
@@ -1,6 +1,6 @@
1
1
  <% if spree_current_user %>
2
- <li><%= link_to Spree.t(:my_account), spree.account_path %></li>
3
- <li><%= link_to Spree.t(:logout), spree.logout_path %></li>
2
+ <li class="nav-item"><%= link_to Spree.t(:my_account), spree.account_path, :class => 'nav-link text-white' %></li>
3
+ <li class="nav-item"><%= link_to Spree.t(:logout), spree.logout_path, :class => 'nav-link text-white' %></li>
4
4
  <% else %>
5
- <li id="link-to-login"><%= link_to Spree.t(:login), spree.login_path %></li>
5
+ <li id="link-to-login" class="nav-item"><%= link_to Spree.t(:login), spree.login_path, :class => 'nav-link text-white' %></li>
6
6
  <% end %>
@@ -1,9 +1,9 @@
1
- <div class="col-md-6 col-md-offset-3">
2
- <div class="panel panel-default">
3
- <div class="panel-heading">
4
- <h3 class="panel-title"><%= Spree.t(:editing_user) %></h3>
1
+ <div class="col-lg-6 offset-lg-3">
2
+ <div class="card mb-3">
3
+ <div class="card-header">
4
+ <h3 class="card-title mb-0 h6"><%= Spree.t(:editing_user) %></h3>
5
5
  </div>
6
- <div class="panel-body">
6
+ <div class="card-body">
7
7
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
8
8
 
9
9
  <%= form_for Spree::User.new, :as => @user, :url => spree.user_path(@user), :method => :put do |f| %>
@@ -1,7 +1,7 @@
1
1
  <h1><%= accurate_title %></h1>
2
2
 
3
- <div data-hook="account_summary" class="account-summary well">
4
- <dl id="user-info">
3
+ <div data-hook="account_summary" class="account-summary card bg-light mb-3">
4
+ <dl id="user-info" class="card-body">
5
5
  <dt><%= Spree.t(:email) %></dt>
6
6
  <dd><%= @user.email %> (<%= link_to Spree.t(:edit), spree.edit_account_path %>)</dd>
7
7
  <br />
@@ -41,7 +41,7 @@
41
41
  </tbody>
42
42
  </table>
43
43
  <% else %>
44
- <div class="alert alert-info"><%= Spree.t(:you_have_no_orders_yet) %></div>
44
+ <div class="alert alert-info" role="alert"><%= Spree.t(:you_have_no_orders_yet) %></div>
45
45
  <% end %>
46
46
  <br />
47
47
 
@@ -91,7 +91,11 @@ RSpec.describe Spree::CheckoutController, type: :controller do
91
91
  before do
92
92
  allow(controller).to receive(:spree_current_user) { user }
93
93
  allow(order).to receive(:user) { user }
94
- allow(order).to receive(:guest_token) { nil }
94
+ if Spree.version.to_f > 3.6
95
+ allow(order).to receive(:token) { nil }
96
+ else
97
+ allow(order).to receive(:guest_token) { nil }
98
+ end
95
99
  end
96
100
 
97
101
  it 'redirects to the standard order view' do
@@ -111,7 +115,11 @@ RSpec.describe Spree::CheckoutController, type: :controller do
111
115
 
112
116
  it 'checks if the user is authorized for :edit' do
113
117
  expect(controller).to receive(:authorize!).with(:edit, order, token)
114
- request.cookie_jar.signed[:guest_token] = token
118
+ if Spree.version.to_f > 3.6
119
+ request.cookie_jar.signed[:token] = token
120
+ else
121
+ request.cookie_jar.signed[:guest_token] = token
122
+ end
115
123
  spree_get :registration, {}
116
124
  end
117
125
  end
@@ -141,7 +149,11 @@ RSpec.describe Spree::CheckoutController, type: :controller do
141
149
  end
142
150
 
143
151
  it 'checks if the user is authorized for :edit' do
144
- request.cookie_jar.signed[:guest_token] = token
152
+ if Spree.version.to_f > 3.6
153
+ request.cookie_jar.signed[:token] = token
154
+ else
155
+ request.cookie_jar.signed[:guest_token] = token
156
+ end
145
157
  allow(order).to receive(:update_attributes) { true }
146
158
  expect(controller).to receive(:authorize!).with(:edit, order, token)
147
159
  spree_put :update_registration, { order: { email: 'jobs@spreecommerce.com' } }
@@ -11,11 +11,19 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
11
11
 
12
12
  context 'with a guest token present' do
13
13
  before do
14
- request.cookie_jar.signed[:guest_token] = 'ABC'
14
+ if Spree.version.to_f > 3.6
15
+ request.cookie_jar.signed[:token] = 'ABC'
16
+ else
17
+ request.cookie_jar.signed[:guest_token] = 'ABC'
18
+ end
15
19
  end
16
20
 
17
21
  it 'assigns orders with the correct token and no user present' do
18
- order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
22
+ if Spree.version.to_f > 3.6
23
+ order = create(:order, token: 'ABC', user_id: nil, created_by_id: nil)
24
+ else
25
+ order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
26
+ end
19
27
  spree_post :create, spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }
20
28
  user = Spree::User.find_by_email('foobar@example.com')
21
29
 
@@ -25,14 +33,22 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
25
33
  end
26
34
 
27
35
  it 'does not assign orders with an existing user' do
28
- order = create(:order, guest_token: 'ABC', user_id: 200)
36
+ if Spree.version.to_f > 3.6
37
+ order = create(:order, token: 'ABC', user_id: 200)
38
+ else
39
+ order = create(:order, guest_token: 'ABC', user_id: 200)
40
+ end
29
41
  spree_post :create, spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }
30
42
 
31
43
  expect(order.reload.user_id).to eq 200
32
44
  end
33
45
 
34
46
  it 'does not assign orders with a different token' do
35
- order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
47
+ if Spree.version.to_f > 3.6
48
+ order = create(:order, token: 'DEF', user_id: nil, created_by_id: nil)
49
+ else
50
+ order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
51
+ end
36
52
  spree_post :create, spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }
37
53
 
38
54
  expect(order.reload.user_id).to be_nil
@@ -59,11 +59,19 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
59
59
 
60
60
  context 'with a guest token present' do
61
61
  before do
62
- request.cookie_jar.signed[:guest_token] = 'ABC'
62
+ if Spree.version.to_f > 3.6
63
+ request.cookie_jar.signed[:token] = 'ABC'
64
+ else
65
+ request.cookie_jar.signed[:guest_token] = 'ABC'
66
+ end
63
67
  end
64
68
 
65
69
  it 'assigns orders with the correct token and no user present' do
66
- order = create(:order, email: user.email, guest_token: 'ABC', user_id: nil, created_by_id: nil)
70
+ if Spree.version.to_f > 3.6
71
+ order = create(:order, email: user.email, token: 'ABC', user_id: nil, created_by_id: nil)
72
+ else
73
+ order = create(:order, email: user.email, guest_token: 'ABC', user_id: nil, created_by_id: nil)
74
+ end
67
75
  spree_post :create, spree_user: { email: user.email, password: 'secret' }
68
76
 
69
77
  order.reload
@@ -72,7 +80,11 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
72
80
  end
73
81
 
74
82
  it 'assigns orders with the correct token and no user or email present' do
75
- order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
83
+ if Spree.version.to_f > 3.6
84
+ order = create(:order, token: 'ABC', user_id: nil, created_by_id: nil)
85
+ else
86
+ order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
87
+ end
76
88
  spree_post :create, spree_user: { email: user.email, password: 'secret' }
77
89
 
78
90
  order.reload
@@ -81,9 +93,15 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
81
93
  end
82
94
 
83
95
  it 'does not assign completed orders' do
84
- order = create(:order, email: user.email, guest_token: 'ABC',
85
- user_id: nil, created_by_id: nil,
86
- completed_at: 1.minute.ago)
96
+ if Spree.version.to_f > 3.6
97
+ order = create(:order, email: user.email, token: 'ABC',
98
+ user_id: nil, created_by_id: nil,
99
+ completed_at: 1.minute.ago)
100
+ else
101
+ order = create(:order, email: user.email, guest_token: 'ABC',
102
+ user_id: nil, created_by_id: nil,
103
+ completed_at: 1.minute.ago)
104
+ end
87
105
  spree_post :create, spree_user: { email: user.email, password: 'secret' }
88
106
 
89
107
  order.reload
@@ -92,14 +110,22 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
92
110
  end
93
111
 
94
112
  it 'does not assign orders with an existing user' do
95
- order = create(:order, guest_token: 'ABC', user_id: 200)
113
+ if Spree.version.to_f > 3.6
114
+ order = create(:order, token: 'ABC', user_id: 200)
115
+ else
116
+ order = create(:order, guest_token: 'ABC', user_id: 200)
117
+ end
96
118
  spree_post :create, spree_user: { email: user.email, password: 'secret' }
97
119
 
98
120
  expect(order.reload.user_id).to eq 200
99
121
  end
100
122
 
101
123
  it 'does not assign orders with a different token' do
102
- order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
124
+ if Spree.version.to_f > 3.6
125
+ order = create(:order, token: 'DEF', user_id: nil, created_by_id: nil)
126
+ else
127
+ order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
128
+ end
103
129
  spree_post :create, spree_user: { email: user.email, password: 'secret' }
104
130
 
105
131
  expect(order.reload.user_id).to be_nil
@@ -133,11 +133,10 @@ RSpec.feature 'Checkout', :js, type: :feature do
133
133
 
134
134
  expect(page).to have_text 'Registration'
135
135
 
136
- fill_in 'Email', with: 'email@person.com'
136
+ fill_in 'Email', with: 'email@person.com', match: :first
137
137
  fill_in 'Password', with: 'spree123'
138
138
  fill_in 'Password Confirmation', with: 'spree123'
139
139
  click_button 'Create'
140
-
141
140
  expect(page).to have_text 'You have signed up successfully.'
142
141
 
143
142
  str_addr = 'bill_address'
data/spec/spec_helper.rb CHANGED
@@ -22,6 +22,12 @@ RSpec.configure do |config|
22
22
 
23
23
  config.order = :random
24
24
  Kernel.srand(config.seed)
25
+
26
+ config.before(:each) do
27
+ allow(RSpec::Rails::ViewRendering::EmptyTemplateHandler)
28
+ .to receive(:call)
29
+ .and_return(%("")) if Rails.gem_version >= Gem::Version.new('6.0.0.beta1')
30
+ end
25
31
  end
26
32
 
27
33
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = 'spree_auth_devise'
6
- s.version = '3.5.2'
6
+ s.version = '4.0.0.rc1'
7
7
  s.summary = 'Provides authentication and authorization services for use with Spree by using Devise and CanCan.'
8
8
  s.description = s.summary
9
9
 
@@ -19,12 +19,13 @@ Gem::Specification.new do |s|
19
19
  s.require_path = 'lib'
20
20
  s.requirements << 'none'
21
21
 
22
- s.add_dependency 'devise', '>= 4.4', '< 4.7'
22
+ s.add_dependency 'devise', '~> 4.7'
23
23
  s.add_dependency 'devise-encryptable', '0.2.0'
24
24
 
25
- spree_version = '>= 3.1.0', '< 4.0'
25
+ spree_version = '>= 3.1.0', '< 5.0'
26
26
  s.add_dependency 'spree_core', spree_version
27
27
  s.add_dependency 'spree_extension'
28
+ s.add_dependency 'deface', '~> 1.0'
28
29
 
29
30
  s.add_development_dependency 'capybara', '~> 2.7'
30
31
  s.add_development_dependency 'capybara-screenshot'
metadata CHANGED
@@ -1,33 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_auth_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 4.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-03 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '4.4'
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '4.7'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '4.4'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
26
  version: '4.7'
33
27
  - !ruby/object:Gem::Dependency
@@ -53,7 +47,7 @@ dependencies:
53
47
  version: 3.1.0
54
48
  - - "<"
55
49
  - !ruby/object:Gem::Version
56
- version: '4.0'
50
+ version: '5.0'
57
51
  type: :runtime
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,7 +57,7 @@ dependencies:
63
57
  version: 3.1.0
64
58
  - - "<"
65
59
  - !ruby/object:Gem::Version
66
- version: '4.0'
60
+ version: '5.0'
67
61
  - !ruby/object:Gem::Dependency
68
62
  name: spree_extension
69
63
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +72,20 @@ dependencies:
78
72
  - - ">="
79
73
  - !ruby/object:Gem::Version
80
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: deface
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.0'
81
89
  - !ruby/object:Gem::Dependency
82
90
  name: capybara
83
91
  requirement: !ruby/object:Gem::Requirement
@@ -311,7 +319,7 @@ dependencies:
311
319
  version: 3.1.0
312
320
  - - "<"
313
321
  - !ruby/object:Gem::Version
314
- version: '4.0'
322
+ version: '5.0'
315
323
  type: :development
316
324
  prerelease: false
317
325
  version_requirements: !ruby/object:Gem::Requirement
@@ -321,7 +329,7 @@ dependencies:
321
329
  version: 3.1.0
322
330
  - - "<"
323
331
  - !ruby/object:Gem::Version
324
- version: '4.0'
332
+ version: '5.0'
325
333
  - !ruby/object:Gem::Dependency
326
334
  name: spree_frontend
327
335
  requirement: !ruby/object:Gem::Requirement
@@ -331,7 +339,7 @@ dependencies:
331
339
  version: 3.1.0
332
340
  - - "<"
333
341
  - !ruby/object:Gem::Version
334
- version: '4.0'
342
+ version: '5.0'
335
343
  type: :development
336
344
  prerelease: false
337
345
  version_requirements: !ruby/object:Gem::Requirement
@@ -341,7 +349,7 @@ dependencies:
341
349
  version: 3.1.0
342
350
  - - "<"
343
351
  - !ruby/object:Gem::Version
344
- version: '4.0'
352
+ version: '5.0'
345
353
  - !ruby/object:Gem::Dependency
346
354
  name: sqlite3
347
355
  requirement: !ruby/object:Gem::Requirement
@@ -432,16 +440,17 @@ files:
432
440
  - gemfiles/spree_3_2.gemfile
433
441
  - gemfiles/spree_3_5.gemfile
434
442
  - gemfiles/spree_3_7.gemfile
443
+ - gemfiles/spree_4_0.gemfile
435
444
  - gemfiles/spree_master.gemfile
436
445
  - lib/assets/javascripts/spree/backend/spree_auth.js.erb
437
446
  - lib/assets/javascripts/spree/frontend/account.js
438
447
  - lib/assets/javascripts/spree/frontend/spree_auth.js.erb
439
448
  - lib/assets/stylesheets/spree/backend/spree_auth.css.erb
440
449
  - lib/assets/stylesheets/spree/frontend/spree_auth.css.erb
441
- - lib/controllers/backend/spree/admin/admin_controller_decorator.rb
442
- - lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb
443
- - lib/controllers/backend/spree/admin/admin_resource_controller_decorator.rb
450
+ - lib/controllers/backend/spree/admin/base_controller_decorator.rb
444
451
  - lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb
452
+ - lib/controllers/backend/spree/admin/orders_controller_decorator.rb
453
+ - lib/controllers/backend/spree/admin/resource_controller_decorator.rb
445
454
  - lib/controllers/backend/spree/admin/user_passwords_controller.rb
446
455
  - lib/controllers/backend/spree/admin/user_sessions_controller.rb
447
456
  - lib/controllers/frontend/spree/checkout_controller_decorator.rb
@@ -524,9 +533,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
524
533
  version: 2.2.7
525
534
  required_rubygems_version: !ruby/object:Gem::Requirement
526
535
  requirements:
527
- - - ">="
536
+ - - ">"
528
537
  - !ruby/object:Gem::Version
529
- version: '0'
538
+ version: 1.3.1
530
539
  requirements:
531
540
  - none
532
541
  rubygems_version: 3.0.2
@@ -1,3 +0,0 @@
1
- Spree::Admin::ResourceController.class_eval do
2
- rescue_from CanCan::AccessDenied, with: :unauthorized
3
- end