diff --git a/app/controllers/spree/admin/prototypes_controller.rb b/app/controllers/spree/admin/prototypes_controller.rb index 63b2849..8075d03 100644 --- a/app/controllers/spree/admin/prototypes_controller.rb +++ b/app/controllers/spree/admin/prototypes_controller.rb @@ -2,26 +2,31 @@ module Spree module Admin - class PrototypesController < ResourceController - def show - if request.xhr? - render layout: false - else - redirect_to admin_prototypes_path + if defined? ::Spree::Backend + class PrototypesController < ResourceController + def show + if request.xhr? + render layout: false + else + redirect_to admin_prototypes_path + end end - end - def available - @prototypes = Prototype.order('name asc') - respond_with(@prototypes) do |format| - format.html { render layout: !request.xhr? } - format.js + def available + @prototypes = Prototype.order('name asc') + respond_with(@prototypes) do |format| + format.html { render layout: !request.xhr? } + format.js + end end - end - def select - @prototype ||= Prototype.find(params[:id]) - @prototype_properties = @prototype.properties + def select + @prototype ||= Prototype.find(params[:id]) + @prototype_properties = @prototype.properties + end + end + else + class PrototypesController end end end diff --git a/config/initializers/spree.rb b/config/initializers/spree.rb index f4eb050..dd1ca54 100644 --- a/config/initializers/spree.rb +++ b/config/initializers/spree.rb @@ -1,18 +1,20 @@ Rails.application.config.to_prepare do Spree::PermittedAttributes.product_attributes << :prototype_id - Spree::Backend::Config.configure do |config| - product_tab = config.menu_items.detect { |menu_item| - menu_item.label == :products - } - if product_tab.respond_to?(:children) - product_tab.children << Spree::BackendConfiguration::MenuItem.new( - condition: -> { can?(:admin, Spree::Prototype) }, - url: :admin_prototypes_path, - label: :prototypes, - match_path: '/prototypes' - ) - else - product_tab.sections << :prototypes + if defined?(Spree::Backend) + Spree::Backend::Config.configure do |config| + product_tab = config.menu_items.detect { |menu_item| + menu_item.label == :products + } + if product_tab.respond_to?(:children) + product_tab.children << Spree::BackendConfiguration::MenuItem.new( + condition: -> { can?(:admin, Spree::Prototype) }, + url: :admin_prototypes_path, + label: :prototypes, + match_path: '/prototypes' + ) + else + product_tab.sections << :prototypes + end end end end diff --git a/lib/backend/controllers/spree/admin/products_controller_decorator.rb b/lib/backend/controllers/spree/admin/products_controller_decorator.rb index 589bdbc..2199e26 100644 --- a/lib/backend/controllers/spree/admin/products_controller_decorator.rb +++ b/lib/backend/controllers/spree/admin/products_controller_decorator.rb @@ -19,7 +19,7 @@ def load_prototype @prototype = Spree::Prototype.find(params[resource][:prototype_id]) end - ::Spree::Admin::ProductsController.prepend self + ::Spree::Admin::ProductsController.prepend self if defined? ::Spree::Admin::ProductsController end end end diff --git a/solidus_prototypes.gemspec b/solidus_prototypes.gemspec index 324ea23..da80a47 100644 --- a/solidus_prototypes.gemspec +++ b/solidus_prototypes.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.description = "Breaking out prototypes from solidus" s.license = "BSD-3-Clause" - s.required_ruby_version = [">= 3.0", "< 4"] + s.required_ruby_version = Gem::Requirement.new('>= 3.0') s.author = "Graeme Nathan" s.email = "graeme@stembolt.com" @@ -34,5 +34,8 @@ Gem::Specification.new do |s| s.add_dependency "solidus_core", [">= 3.2.0", "< 5"] s.add_dependency "solidus_support", "~> 0.4" - s.add_development_dependency "solidus_dev_support" + s.add_development_dependency 'rubocop', '~> 1.0' + s.add_development_dependency 'rubocop-performance', '~> 1.5' + s.add_development_dependency 'rubocop-rails', '~> 2.3' + s.add_development_dependency 'rubocop-rspec', '~> 2.0' end