Skip to content

Commit

Permalink
Merge pull request #63 from tvdeyen/solidus-4.0-support
Browse files Browse the repository at this point in the history
Add Solidus 4.0, 4.1, 4.2 and 4.3 support
  • Loading branch information
tvdeyen authored Nov 7, 2023
2 parents 631ba43 + d0ef957 commit b902fe4
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 39 deletions.
11 changes: 3 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
%w[solidusio/solidus solidusio/solidus_frontend]
else
%w[solidusio/solidus] * 2
end
gem 'solidus', github: solidus_git, branch: branch
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
solidus_branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: "solidusio/solidus", branch: solidus_branch

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
Expand All @@ -19,6 +13,7 @@ gem 'rails', '>0.a'

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'
gem 'solidus_dev_support', github: "solidusio/solidus_dev_support", branch: "main"

case ENV['DB']
when 'mysql'
Expand Down
2 changes: 0 additions & 2 deletions app/assets/javascripts/spree/frontend/solidus_prototypes.js

This file was deleted.

4 changes: 0 additions & 4 deletions app/assets/stylesheets/spree/frontend/solidus_prototypes.css

This file was deleted.

6 changes: 0 additions & 6 deletions app/overrides/decorate_admin_product_tabs.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# frozen_string_literal: true

Spree::Backend::Config.configure do |config|
config.menu_items.detect { |menu_item|
menu_item.label == :products
}.sections << :prototypes
end

Deface::Override.new(
virtual_path: "spree/admin/shared/_product_sub_menu",
name: "prototypes_admin_tab",
Expand Down
15 changes: 15 additions & 0 deletions config/initializers/spree.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
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
end
end
end
12 changes: 2 additions & 10 deletions lib/generators/solidus_prototypes/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
# frozen_string_literal: true

require 'solidus_support'

module SolidusPrototypes
module Generators
class InstallGenerator < Rails::Generators::Base
class_option :auto_run_migrations, type: :boolean, default: false

def add_javascripts
append_file(
'vendor/assets/javascripts/spree/frontend/all.js',
"//= require spree/frontend/solidus_prototypes\n"
)
append_file(
'vendor/assets/javascripts/spree/backend/all.js',
"//= require spree/backend/solidus_prototypes\n"
)
end

def add_stylesheets
inject_into_file(
'vendor/assets/stylesheets/spree/frontend/all.css',
" *= require spree/frontend/solidus_prototypes\n",
before: %r{\*/},
verbose: true
)
inject_into_file(
'vendor/assets/stylesheets/spree/backend/all.css',
" *= require spree/backend/solidus_prototypes\n",
Expand Down
2 changes: 0 additions & 2 deletions lib/solidus_prototypes/testing_support/factories.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'spree/testing_support/factories/property_factory'

FactoryBot.define do
factory :prototype, class: 'Spree::Prototype' do
name { 'Baseball Cap' }
Expand Down
4 changes: 2 additions & 2 deletions solidus_prototypes.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Gem::Specification.new do |s|
end

s.add_dependency "deface"
s.add_dependency "solidus_core", [">= 2.1.0", "< 4"]
s.add_dependency "solidus_backend", [">= 3.2.0", "< 5"]
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 "selenium-webdriver", "< 4.8.2"
end
10 changes: 5 additions & 5 deletions spec/support/feature/base_feature_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

module BaseFeatureHelper
def click_nav(nav_text, subnav_text = nil)
primary_nav = find(".admin-nav-menu>ul>li>a", text: /#{nav_text}/i)
if subnav_text
primary_nav.find('+ul>li>a', text: /#{subnav_text}/i).click
def click_nav(nav_text)
if Spree.solidus_gem_version > Gem::Version.new("4.2")
primary_nav = find(".solidus-admin--nav--menu .tab-with-icon", text: /#{nav_text}/i)
else
primary_nav.click
primary_nav = find(".admin-nav-menu>ul>li>a", text: /#{nav_text}/i)
end
primary_nav.click
end
end

Expand Down

0 comments on commit b902fe4

Please sign in to comment.