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
62 changes: 50 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,73 @@
version: 2.1

orbs:
# Required for feature specs.
browser-tools: circleci/browser-tools@1.1

# 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-postgres:
executor: solidusio_extensions/postgres
run-specs:
parameters:
solidus:
type: string
default: main
db:
type: string
default: "postgres"
ruby:
type: string
default: "3.2"
executor:
name: solidusio_extensions/<< parameters.db >>
ruby_version: << parameters.ruby >>
steps:
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
- checkout
- browser-tools/install-chrome
- solidusio_extensions/run-tests-solidus-<< parameters.solidus >>

lint-code:
executor:
name: solidusio_extensions/sqlite
ruby_version: "3.2"
steps:
- solidusio_extensions/run-tests
- solidusio_extensions/lint-code

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
"Weekly run specs against master":
- run-specs:
name: &name "run-specs-solidus-<< matrix.solidus >>-ruby-<< matrix.ruby >>-db-<< matrix.db >>"
matrix:
parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
- run-specs:
name: *name
matrix:
parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
- run-specs:
name: *name
matrix:
parameters: { solidus: ["older"], ruby: ["3.1"], db: ["sqlite"] }
- lint-code

"Weekly run specs against main":
triggers:
- schedule:
cron: "0 0 * * 4" # every Thursday
filters:
branches:
only:
- master
- main
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- run-specs:
name: *name
matrix:
parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
- run-specs:
name: *name
matrix:
parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
36 changes: 36 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
inherit_from: .rubocop_todo.yml

require:
- solidus_dev_support/rubocop

FactoryBot/CreateList:
Enabled: false

FactoryBot/AssociationStyle:
Enabled: false

FactoryBot/FactoryNameStyle:
Enabled: false

FactoryBot/ConsistentParenthesesStyle:
Enabled: false

FactoryBot/FactoryClassName:
Enabled: false

FactoryBot/RedundantFactoryOption:
Enabled: false

Gemspec/RequiredRubyVersion:
Enabled: false

Capybara/RSpec/PredicateMatcher:
Enabled: false

Capybara/NegationMatcher:
Enabled: false

Capybara/ClickLinkOrButtonStyle:
Enabled: false

AllCops:
NewCops: disable
TargetRubyVersion: 3.2
73 changes: 73 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-03-18 11:13:14 UTC using RuboCop version 1.74.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).
Lint/RedundantCopDisableDirective:
Exclude:
- 'lib/generators/solidus_static_content/install/install_generator.rb'

# Offense count: 3
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/features/spree/static_content_spec.rb'
- 'spec/models/spree/page_spec.rb'

# Offense count: 1
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'spec/helpers/spree/page_helper_spec.rb'

# Offense count: 4
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/models/spree/page_spec.rb'

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

# Offense count: 4
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Exclude:
- 'spec/controllers/spree/admin/pages_controller_spec.rb'
- 'spec/lib/solidus_static_content/route_matcher_spec.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/spree/page.rb'

# Offense count: 1
Rails/OutputSafety:
Exclude:
- 'app/helpers/spree/pages_helper.rb'

# Offense count: 4
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
Rails/SkipsModelValidations:
Exclude:
- 'db/migrate/20090625125735_extend_pages.rb'
- 'db/migrate/20090814113100_add_visible_to_pages.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Max: 150
51 changes: 32 additions & 19 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,43 @@
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

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
# See https://github.com/bundler/bundler/issues/6677
gem 'rails', '>0.a'

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

case ENV['DB']
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'
else
gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
end

rails_version = ENV.fetch('RAILS_VERSION', '~> 7.0')
gem 'rails', rails_version

# Extract the minimum Rails version from the version requirement.
# For example, a requirement of "~> 7.0" translates to ">= 7.0" and "< 8.0".
rails_req = Gem::Requirement.new(rails_version)
# Find the minimum version specified by a ">=" constraint, if any.
min_rails_version = rails_req.requirements.find { |op, _| op == '>=' }&.last || Gem::Version.new('0')

# Determine the sqlite3 version based on the minimum Rails version.
# If the minimum Rails version is less than 7.2, use "~> 1.4"; otherwise, use "~> 2.0".
sqlite_version =
if min_rails_version < Gem::Version.new('7.2')
"~> 1.4"
else
"~> 2.0"
end

case ENV.fetch('DB', nil)
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
else
gem 'sqlite3'
gem 'sqlite3', sqlite_version
end

gemspec
Expand Down
4 changes: 3 additions & 1 deletion Guardfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

guard "rspec", cmd: "bundle exec rspec" do
watch("spec/spec_helper.rb") { "spec" }
watch("config/routes.rb") { "spec/controllers" }
watch("app/controllers/application_controller.rb") { "spec/controllers" }
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,27 @@ Good, clean content management of pages for Solidus. You can use it to:

Add solidus_static_content to your Gemfile:

```ruby
gem 'solidus_static_content'
```
### Starter Frontend

Bundle your dependencies and run the installation generator:

```shell
bundle
bundle exec rails g solidus_static_content:install
bin/rails generate solidus_static_content:install --frontend=starter
```

Please, be aware that the installation only works with the default
implementation of the starter frontend. Any customization to the files that
will be modified by the installer might break the installation procedure.
If that happens, try to adapt the installed code on top of the customizations
of the store.

### Legacy Frontend

If you are using the legacy `solidus_frontend` gem, please run this command instead:

```shell
bin/rails generate solidus_static_content:install
```

## Usage
Expand Down
14 changes: 9 additions & 5 deletions app/helpers/spree/pages_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module Spree::PagesHelper
def render_snippet(slug)
page = Spree::Page.find_by_slug(slug)
raw page.body if page
# frozen_string_literal: true

module Spree
module PagesHelper
def render_snippet(slug)
page = Spree::Page.find_by(slug: slug)
raw page.body if page
end
end
end
end
Loading