Skip to content

Commit

Permalink
Support Rails 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
John Hawthorn committed Jun 8, 2017
1 parent f5341e7 commit 178a4b5
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module SpreeMultiDomain::ShowProductSupport

included do
prepend(InstanceMethods)
before_filter :can_show_product, :only => :show
before_action :can_show_product, :only => :show
end

module InstanceMethods
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/spree/admin/stores_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Spree::Admin::StoresController < Spree::Admin::ResourceController

before_filter :load_payment_methods
before_filter :load_shipping_methods
before_action :load_payment_methods
before_action :load_shipping_methods

def index
@stores = @stores.ransack({ name_or_domains_or_code_cont: params[:q] }).result if params[:q]
Expand Down
10 changes: 3 additions & 7 deletions app/controllers/spree/api/shipments_controller_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
module SpreeMultiStore
module Api
module ShipmentsControllerDecorator
def self.included(base)
base.alias_method_chain :mine, :store_scope
end

def mine_with_store_scope
mine_without_store_scope
def mine
super
@shipments = @shipments.where(spree_orders: { store_id: current_store.id }) if @shipments
end
end
end
end

if SpreeMultiDomain::Engine.api_available?
Spree::Api::ShipmentsController.include(SpreeMultiStore::Api::ShipmentsControllerDecorator)
Spree::Api::ShipmentsController.prepend(SpreeMultiStore::Api::ShipmentsControllerDecorator)
Spree::Api::ShipmentsController.include(SpreeMultiDomain::CreateLineItemSupport)
end
2 changes: 1 addition & 1 deletion db/migrate/20091202123245_add_order_store.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddOrderStore < ActiveRecord::Migration
class AddOrderStore < SolidusSupport::Migration[4.2]
def self.up
if table_exists?('orders')
add_column :orders, :store_id, :integer
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20100227180338_create_products_stores.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateProductsStores < ActiveRecord::Migration
class CreateProductsStores < SolidusSupport::Migration[4.2]
def self.up
create_table :products_stores, :id => false do |t|
t.references :product
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20100616204303_store_id_for_taxonomies.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class StoreIdForTaxonomies < ActiveRecord::Migration
class StoreIdForTaxonomies < SolidusSupport::Migration[4.2]
def self.up
if table_exists?('taxonomies')
add_column :taxonomies, :store_id, :integer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RemoveDatetimeColumnsFromProductsStores < ActiveRecord::Migration
class RemoveDatetimeColumnsFromProductsStores < SolidusSupport::Migration[4.2]
def self.up
change_table :products_stores do |t|
t.remove :created_at, :updated_at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddIndexesToProductsStores < ActiveRecord::Migration
class AddIndexesToProductsStores < SolidusSupport::Migration[4.2]
def self.up
add_index :products_stores, :product_id
add_index :products_stores, :store_id
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20120223183401_namespace.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Namespace < ActiveRecord::Migration
class Namespace < SolidusSupport::Migration[4.2]
def up
rename_table :products_stores, :spree_products_stores
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20130308084714_add_logo_to_stores.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddLogoToStores < ActiveRecord::Migration
class AddLogoToStores < SolidusSupport::Migration[4.2]
def self.up
change_table :spree_stores do |t|
t.string :logo_file_name
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20130325231147_add_store_shipping_methods.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddStoreShippingMethods < ActiveRecord::Migration
class AddStoreShippingMethods < SolidusSupport::Migration[4.2]
def change
create_table :spree_store_shipping_methods do |t|
t.integer :store_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddSpreePromotionRulesStores < ActiveRecord::Migration
class AddSpreePromotionRulesStores < SolidusSupport::Migration[4.2]
def change
create_table :spree_promotion_rules_stores, :id => false do |t|
t.references :promotion_rule
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20150304200122_add_indexes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddIndexes < ActiveRecord::Migration
class AddIndexes < SolidusSupport::Migration[4.2]
def change
add_index :spree_promotion_rules_stores, :store_id
add_index :spree_promotion_rules_stores, :promotion_rule_id
Expand Down
3 changes: 2 additions & 1 deletion lib/solidus_multi_domain.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'spree_core'
require 'solidus_core'
require 'solidus_support'
require 'spree_multi_domain/engine'
require 'deface'
19 changes: 8 additions & 11 deletions lib/spree_multi_domain/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def frontend_available?
config.to_prepare &method(:activate).to_proc

initializer "templates with dynamic layouts" do |app|
ActionView::TemplateRenderer.class_eval do
def find_layout_with_multi_store(layout, *args)
ActionView::TemplateRenderer.prepend(Module.new do
def find_layout(layout, *args)
if @view.respond_to?(:current_store) && @view.current_store && !@view.controller.is_a?(Spree::Admin::BaseController)
store_layout = if layout.is_a?(String)
layout.gsub("layouts/", "layouts/#{@view.current_store.code}/")
Expand All @@ -42,22 +42,20 @@ def find_layout_with_multi_store(layout, *args)
end

begin
find_layout_without_multi_store(store_layout, *args)
super(store_layout, *args)
rescue ::ActionView::MissingTemplate
find_layout_without_multi_store(layout, *args)
super(layout, *args)
end
else
find_layout_without_multi_store(layout, *args)
super(layout, *args)
end
end

alias_method_chain :find_layout, :multi_store
end
end)
end

initializer "current order decoration" do |app|
require 'spree/core/controller_helpers/order'
::Spree::Core::ControllerHelpers::Order.module_eval do
::Spree::Core::ControllerHelpers::Order.prepend(Module.new do
def current_order_with_multi_domain(options = {})
options[:create_order_if_necessary] ||= false
current_order_without_multi_domain(options)
Expand All @@ -68,8 +66,7 @@ def current_order_with_multi_domain(options = {})

@current_order
end
alias_method_chain :current_order, :multi_domain
end
end)
end

initializer 'spree.promo.register.promotions.rules' do |app|
Expand Down
2 changes: 1 addition & 1 deletion lib/spree_multi_domain/multi_domain_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module MultiDomainHelpers
helper 'spree/products'
helper 'spree/taxons'

before_filter :add_current_store_id_to_params
before_action :add_current_store_id_to_params
helper_method :current_store
end

Expand Down
1 change: 1 addition & 0 deletions solidus_multi_domain.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.requirements << "none"

s.add_dependency "solidus", ['>= 1.1', '< 3']
s.add_dependency "solidus_support"
s.add_dependency "deface", '~> 1.0'

s.add_development_dependency "rspec-rails", "~> 3.2"
Expand Down

0 comments on commit 178a4b5

Please sign in to comment.