Skip to content

Commit

Permalink
Merge pull request #464 from spark-solutions/feature/rails-6-0
Browse files Browse the repository at this point in the history
Rails 6.0 and Spree 4.0 support
  • Loading branch information
damianlegawiec authored Aug 27, 2019
2 parents e44f653 + 1d935d0 commit 15d7431
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 20 deletions.
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ script:

addons:
chrome: stable
postgresql: 9.4

env:
- DB=mysql
Expand All @@ -23,16 +24,27 @@ gemfile:
- gemfiles/spree_3_2.gemfile
- gemfiles/spree_3_5.gemfile
- gemfiles/spree_3_7.gemfile
- gemfiles/spree_4_0.gemfile
- gemfiles/spree_master.gemfile

matrix:
allow_failures:
- gemfile: gemfiles/spree_master.gemfile
exclude:
- rvm: 2.3.7
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.4.4
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.3.7
gemfile: gemfiles/spree_4_0.gemfile
- rvm: 2.4.4
gemfile: gemfiles/spree_4_0.gemfile
- rvm: 2.3.7
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.4.4
gemfile: gemfiles/spree_master.gemfile
- rvm: 2.5.1
gemfile: gemfiles/spree_3_2.gemfile
- rvm: 2.5.1
gemfile: gemfiles/spree_3_2.gemfile
- rvm: 2.5.1
gemfile: gemfiles/spree_3_5.gemfile

before_install:
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
Expand Down
6 changes: 6 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ appraise 'spree-3-5' do
end

appraise 'spree-3-7' do
gem 'sass-rails'
gem 'spree', '~> 3.7.0.rc3'
gem 'rails-controller-testing'
end

appraise 'spree-4-0' do
gem 'spree', github: 'spree/spree', tag: 'v4.0.0.beta'
gem 'rails-controller-testing'
end

appraise 'spree-master' do
gem 'spree', github: 'spree/spree', branch: 'master'
gem 'rails-controller-testing'
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ en:
user_registrations:
destroyed: Bye! Your account was successfully cancelled. We hope to see you again soon.
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
signed_up_but_unconfirmed: You have signed up successfully.
signed_up: Welcome! You have signed up successfully.
updated: You updated your account successfully.
user_sessions:
Expand Down
1 change: 1 addition & 0 deletions gemfiles/spree_3_7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ source "https://rubygems.org"

gem "rails-controller-testing"
gem "spree", "~> 3.7.0.rc3"
gem "sass-rails"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/spree_4_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails-controller-testing"
gem "spree", github: "spree/spree", tag: "v4.0.0.beta"

gemspec path: "../"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Spree::Admin::BaseController.class_eval do
module Spree::Admin::BaseControllerDecorator
# Redirect as appropriate when an access request fails. The default action is to redirect to the login screen.
# Override this method in your controllers if you want to have special behavior in case the user is not authorized
# to access the requested action. For example, a popup window might simply close itself.
Expand All @@ -22,3 +22,4 @@ def model_class
nil
end
end
Spree::Admin::BaseController.prepend(Spree::Admin::BaseControllerDecorator)
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Spree::Admin::Orders::CustomerDetailsController.class_eval do
before_action :check_authorization
module Spree::Admin::Orders::CustomerDetailsControllerDecorator

def self.prepended(base)
base.before_action :check_authorization
end

private

Expand All @@ -14,3 +17,4 @@ def check_authorization
authorize! action, resource, session[:access_token]
end
end
Spree::Admin::Orders::CustomerDetailsController.prepend(Spree::Admin::Orders::CustomerDetailsControllerDecorator)
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Spree::Admin::OrdersController.class_eval do
before_action :check_authorization
module Spree::Admin::OrdersControllerDecorator

def self.prepended(base)
base.before_action :check_authorization
end

private

Expand All @@ -19,3 +22,4 @@ def check_authorization
end
end
end
Spree::Admin::OrdersController.prepend(Spree::Admin::OrdersControllerDecorator)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Spree::Admin::ResourceControllerDecorator
def self.prepended(base)
base.rescue_from CanCan::AccessDenied, with: :unauthorized
end
end
Spree::Admin::ResourceController.prepend(Spree::Admin::ResourceControllerDecorator)
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require 'spree/core/validators/email' if Spree.version.to_f < 3.5
Spree::CheckoutController.class_eval do
before_action :check_authorization
before_action :check_registration, except: [:registration, :update_registration]
module Spree::CheckoutControllerDecorator
def self.prepended(base)
base.before_action :check_authorization
base.before_action :check_registration, except: [:registration, :update_registration]
end

def registration
@user = Spree::User.new
Expand Down Expand Up @@ -39,3 +41,4 @@ def check_registration
redirect_to spree.checkout_registration_path
end
end
Spree::CheckoutController.prepend(Spree::CheckoutControllerDecorator)
3 changes: 2 additions & 1 deletion lib/controllers/frontend/spree/store_controller_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Spree::StoreController.class_eval do
module Spree::StoreControllerDecorator
def account_link
render partial: 'spree/shared/link_to_account'
fresh_when(spree_current_user)
end
end
Spree::StoreController.prepend(Spree::StoreControllerDecorator)
3 changes: 1 addition & 2 deletions spec/features/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@

expect(page).to have_text 'Registration'

fill_in 'Email', with: '[email protected]'
fill_in 'Email', with: '[email protected]', match: :first
fill_in 'Password', with: 'spree123'
fill_in 'Password Confirmation', with: 'spree123'
click_button 'Create'

expect(page).to have_text 'You have signed up successfully.'

str_addr = 'bill_address'
Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

config.order = :random
Kernel.srand(config.seed)

config.before(:each) do
allow(RSpec::Rails::ViewRendering::EmptyTemplateHandler)
.to receive(:call)
.and_return(%("")) if Rails.gem_version >= Gem::Version.new('6.0.0.beta1')
end
end

Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
4 changes: 2 additions & 2 deletions spree_auth_devise.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_auth_devise'
s.version = '4.0.0.beta'
s.version = '4.0.0.rc1'
s.summary = 'Provides authentication and authorization services for use with Spree by using Devise and CanCan.'
s.description = s.summary

Expand All @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

s.add_dependency 'devise', '>= 4.4', '< 4.7'
s.add_dependency 'devise', '~> 4.7'
s.add_dependency 'devise-encryptable', '0.2.0'

spree_version = '>= 3.1.0', '< 5.0'
Expand Down

0 comments on commit 15d7431

Please sign in to comment.