Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
version: 2.1

orbs:
# Required for feature specs.
browser-tools: circleci/[email protected]

# Always take the latest version of the orb, this allows us to
# run specs against Solidus supported versions only without the need
# to change this configuration every time a Solidus version is released
# or goes EOL.
solidusio_extensions: solidusio/extensions@volatile

jobs:
run-specs-with-sqlite:
executor:
name: solidusio_extensions/sqlite
ruby_version: "3.0"
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
run-specs-with-postgres:
executor: solidusio_extensions/postgres
executor:
name: solidusio_extensions/postgres
ruby_version: "3.0"
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
executor:
name: solidusio_extensions/mysql
ruby_version: "3.0"
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
lint-code:
executor:
name: solidusio_extensions/sqlite-memory
ruby_version: "3.0"
steps:
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-sqlite
- run-specs-with-postgres
- run-specs-with-mysql
- lint-code

"Weekly run specs against master":
triggers:
- schedule:
Expand All @@ -31,5 +56,6 @@ workflows:
only:
- master
jobs:
- run-specs-with-sqlite
- run-specs-with-postgres
- run-specs-with-mysql
1 change: 1 addition & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: .github
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
inherit_from: .rubocop_todo.yml

require:
- solidus_dev_support/rubocop

AllCops:
NewCops: disable
67 changes: 67 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-10-13 08:30:45 UTC using RuboCop version 1.36.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequireMFA:
Exclude:
- 'solidus_static_content.gemspec'

# Offense count: 1
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'lib/solidus_static_content/factories.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/NonDeterministicRequireOrder:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/OrAssignmentToConstant:
Exclude:
- 'app/models/solidus_static_content/configuration.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Lint/RedundantCopDisableDirective:
Exclude:
- 'bin/rails'

# Offense count: 1
RSpec/AnyInstance:
Exclude:
- 'spec/features/admin/homepage_spec.rb'

# Offense count: 3
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/features/admin/homepage_spec.rb'

# Offense count: 2
RSpec/MultipleExpectations:
Max: 2

# Offense count: 1
# Style/ClassVars:
# Exclude:
# - 'app/controllers/spree/admin/reports_controller.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Exclude:
- 'Gemfile'
35 changes: 26 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
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
branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
gem 'solidus', github: 'solidusio/solidus', branch: branch

# The solidus_frontend gem has been pulled out since v3.2
if branch >= 'v3.2'
gem 'solidus_frontend'
elsif branch == 'main'
gem 'solidus_frontend', github: 'solidusio/solidus_frontend', branch: branch
else
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
end

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

case ENV['DB']
case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
Expand All @@ -29,6 +32,20 @@ else
gem 'sqlite3'
end

group :development, :test do
gem 'factory_bot', '> 4.10.0'
gem 'pry-rails'
end

group :test do
gem 'rails-controller-testing'
end

# While we still support Ruby < 3 we need to workaround a limitation in
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
# resolve gems based on the required ruby version.
gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')

gemspec

# Use a local Gemfile to include development dependencies that might not be
Expand Down
4 changes: 0 additions & 4 deletions lib/solidus_static_content.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

require 'solidus_core'
require 'solidus_support'
require 'deface'

require 'solidus_static_content/version'
require 'solidus_static_content/route_matcher'
require 'solidus_static_content/engine'
4 changes: 2 additions & 2 deletions lib/solidus_static_content/engine.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'spree/core'
require 'solidus_static_content'
require 'solidus_core'
require 'solidus_support'

module SolidusStaticContent
class Engine < Rails::Engine
Expand Down
14 changes: 7 additions & 7 deletions solidus_static_content.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ Gem::Specification.new do |spec|
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_static_content#readme'
spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_static_content/releases'

spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
spec.required_ruby_version = '>= 2.5'

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

spec.files = files.grep_v(%r{^(test|spec|features)/})
spec.test_files = files.grep(%r{^(test|spec|features)/})
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_dependency 'deface', '~> 1.0'
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
spec.add_dependency 'solidus_support', '~> 0.6'
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 5']
spec.add_dependency 'solidus_support', '~> 0.8'

spec.add_development_dependency 'solidus_dev_support'
spec.add_development_dependency 'rails-controller-testing'
spec.add_development_dependency 'solidus_dev_support', '~> 2.7'
end
9 changes: 4 additions & 5 deletions spec/features/spree/static_content_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'spec_helper'

feature 'Static Content Page', js: true do

let!(:store) { create(:store, default: true) }

context 'render page' do
Expand Down Expand Up @@ -29,10 +28,10 @@
expect(page).to have_text 'Root Page Test'
end

scenario 'is limited within its own constraints', js: false do
create(:taxon, permalink: 'test', name: 'The Taxon')
create(:page, slug: '/t/test', title: 'The Page', stores: [store])
visit '/t/test'
scenario 'is limited within its own constraints' do
taxon = create(:taxon, permalink: 'test', name: 'The Taxon')
create(:page, slug: "/t/#{taxon.permalink}", title: 'The Page', stores: [store])
visit "/t/#{taxon.permalink}"
expect(page).to have_content('The Taxon')
expect(page).not_to have_content('The Page')
end
Expand Down
22 changes: 15 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'

require 'rails-controller-testing'
Rails::Controller::Testing.install

# Run Coverage report
require 'solidus_dev_support/rspec/coverage'

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

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

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

# Requires factories defined in lib/solidus_static_content/factories.rb
require 'solidus_static_content/factories'
# Requires factories defined in Solidus core and this extension.
# See: lib/solidus_static_content/testing_support/factories.rb
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusStaticContent::Engine)

RSpec.configure do |config|
config.infer_spec_type_from_file_location!
config.use_transactional_fixtures = false

if Spree.solidus_gem_version < Gem::Version.new('2.11')
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
end
end