Skip to content

Commit cfc3725

Browse files
author
Jonathan Tapia
committed
Add support for v4
1 parent 78f07b0 commit cfc3725

File tree

10 files changed

+88
-36
lines changed

10 files changed

+88
-36
lines changed

.circleci/config.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
11
version: 2.1
22

33
orbs:
4+
# Required for feature specs.
5+
browser-tools: circleci/[email protected]
6+
47
# Always take the latest version of the orb, this allows us to
58
# run specs against Solidus supported versions only without the need
69
# to change this configuration every time a Solidus version is released
710
# or goes EOL.
811
solidusio_extensions: solidusio/extensions@volatile
912

1013
jobs:
14+
run-specs-with-sqlite:
15+
executor:
16+
name: solidusio_extensions/sqlite
17+
ruby_version: "3.0"
18+
steps:
19+
- browser-tools/install-chrome
20+
- solidusio_extensions/run-tests
1121
run-specs-with-postgres:
12-
executor: solidusio_extensions/postgres
22+
executor:
23+
name: solidusio_extensions/postgres
24+
ruby_version: "3.0"
1325
steps:
26+
- browser-tools/install-chrome
1427
- solidusio_extensions/run-tests
1528
run-specs-with-mysql:
16-
executor: solidusio_extensions/mysql
29+
executor:
30+
name: solidusio_extensions/mysql
31+
ruby_version: "3.0"
1732
steps:
33+
- browser-tools/install-chrome
1834
- solidusio_extensions/run-tests
35+
lint-code:
36+
executor:
37+
name: solidusio_extensions/sqlite-memory
38+
ruby_version: "3.0"
39+
steps:
40+
- solidusio_extensions/lint-code
1941

2042
workflows:
2143
"Run specs on supported Solidus versions":
2244
jobs:
45+
- run-specs-with-sqlite
2346
- run-specs-with-postgres
2447
- run-specs-with-mysql
48+
- lint-code
49+
2550
"Weekly run specs against master":
2651
triggers:
2752
- schedule:
@@ -31,5 +56,6 @@ workflows:
3156
only:
3257
- master
3358
jobs:
59+
- run-specs-with-sqlite
3460
- run-specs-with-postgres
3561
- run-specs-with-mysql

.github/stale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_extends: .github

.rubocop.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
inherit_from: .rubocop_todo.yml
2+
13
require:
24
- solidus_dev_support/rubocop
5+
6+
AllCops:
7+
NewCops: disable

Gemfile

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
source 'https://rubygems.org'
44
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

6-
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7-
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
8-
%w[solidusio/solidus solidusio/solidus_frontend]
9-
else
10-
%w[solidusio/solidus] * 2
11-
end
12-
gem 'solidus', github: solidus_git, branch: branch
13-
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
6+
branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7+
gem 'solidus', github: 'solidusio/solidus', branch: branch
8+
9+
# The solidus_frontend gem has been pulled out since v3.2
10+
if branch >= 'v3.2'
11+
gem 'solidus_frontend'
12+
elsif branch == 'main'
13+
gem 'solidus_frontend', github: 'solidusio/solidus_frontend', branch: branch
14+
else
15+
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
16+
end
1417

1518
# Needed to help Bundler figure out how to resolve dependencies,
1619
# otherwise it takes forever to resolve them.
@@ -20,7 +23,7 @@ gem 'rails', '>0.a'
2023
# Provides basic authentication functionality for testing parts of your engine
2124
gem 'solidus_auth_devise'
2225

23-
case ENV['DB']
26+
case ENV.fetch('DB', nil)
2427
when 'mysql'
2528
gem 'mysql2'
2629
when 'postgresql'
@@ -29,6 +32,20 @@ else
2932
gem 'sqlite3'
3033
end
3134

35+
group :development, :test do
36+
gem 'factory_bot', '> 4.10.0'
37+
gem 'pry-rails'
38+
end
39+
40+
group :test do
41+
gem 'rails-controller-testing'
42+
end
43+
44+
# While we still support Ruby < 3 we need to workaround a limitation in
45+
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
46+
# resolve gems based on the required ruby version.
47+
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
48+
3249
gemspec
3350

3451
# Use a local Gemfile to include development dependencies that might not be

lib/solidus_static_content.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'solidus_core'
4-
require 'solidus_support'
5-
require 'deface'
6-
73
require 'solidus_static_content/version'
84
require 'solidus_static_content/route_matcher'
95
require 'solidus_static_content/engine'

lib/solidus_static_content/engine.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

3-
require 'spree/core'
4-
require 'solidus_static_content'
3+
require 'solidus_core'
4+
require 'solidus_support'
55

66
module SolidusStaticContent
77
class Engine < Rails::Engine
File renamed without changes.

solidus_static_content.gemspec

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ Gem::Specification.new do |spec|
1717
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_static_content#readme'
1818
spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_static_content/releases'
1919

20-
spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
20+
spec.required_ruby_version = '>= 2.5'
2121

2222
# Specify which files should be added to the gem when it is released.
2323
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
2424
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
2525

2626
spec.files = files.grep_v(%r{^(test|spec|features)/})
2727
spec.test_files = files.grep(%r{^(test|spec|features)/})
28-
spec.bindir = "exe"
28+
spec.bindir = 'exe'
2929
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
30-
spec.require_paths = ["lib"]
30+
spec.require_paths = ['lib']
3131

32-
spec.add_dependency 'deface', '~> 1.0'
33-
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
34-
spec.add_dependency 'solidus_support', '~> 0.6'
32+
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 5']
33+
spec.add_dependency 'solidus_support', '~> 0.8'
3534

36-
spec.add_development_dependency 'solidus_dev_support'
35+
spec.add_development_dependency 'rails-controller-testing'
36+
spec.add_development_dependency 'solidus_dev_support', '~> 2.7'
3737
end

spec/features/spree/static_content_spec.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'spec_helper'
22

33
feature 'Static Content Page', js: true do
4-
54
let!(:store) { create(:store, default: true) }
65

76
context 'render page' do
@@ -29,10 +28,10 @@
2928
expect(page).to have_text 'Root Page Test'
3029
end
3130

32-
scenario 'is limited within its own constraints', js: false do
33-
create(:taxon, permalink: 'test', name: 'The Taxon')
34-
create(:page, slug: '/t/test', title: 'The Page', stores: [store])
35-
visit '/t/test'
31+
scenario 'is limited within its own constraints' do
32+
taxon = create(:taxon, permalink: 'test', name: 'The Taxon')
33+
create(:page, slug: "/t/#{taxon.permalink}", title: 'The Page', stores: [store])
34+
visit "/t/#{taxon.permalink}"
3635
expect(page).to have_content('The Taxon')
3736
expect(page).not_to have_content('The Page')
3837
end

spec/spec_helper.rb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@
33
# Configure Rails Environment
44
ENV['RAILS_ENV'] = 'test'
55

6+
require 'rails-controller-testing'
7+
Rails::Controller::Testing.install
8+
69
# Run Coverage report
710
require 'solidus_dev_support/rspec/coverage'
811

9-
require File.expand_path('dummy/config/environment.rb', __dir__).tap { |file|
10-
# Create the dummy app if it's still missing.
11-
system 'bin/rake extension:test_app' unless File.exist? file
12-
}
12+
# Create the dummy app if it's still missing.
13+
dummy_env = "#{__dir__}/dummy/config/environment.rb"
14+
system 'bin/rake extension:test_app' unless File.exist? dummy_env
15+
require dummy_env
1316

1417
# Requires factories and other useful helpers defined in spree_core.
1518
require 'solidus_dev_support/rspec/feature_helper'
1619

1720
# Requires supporting ruby files with custom matchers and macros, etc,
1821
# in spec/support/ and its subdirectories.
19-
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
22+
Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
2023

21-
# Requires factories defined in lib/solidus_static_content/factories.rb
22-
require 'solidus_static_content/factories'
24+
# Requires factories defined in Solidus core and this extension.
25+
# See: lib/solidus_static_content/testing_support/factories.rb
26+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusStaticContent::Engine)
2327

2428
RSpec.configure do |config|
2529
config.infer_spec_type_from_file_location!
2630
config.use_transactional_fixtures = false
31+
32+
if Spree.solidus_gem_version < Gem::Version.new('2.11')
33+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
34+
end
2735
end

0 commit comments

Comments
 (0)