Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update extension with latest solidus_dev_support #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
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
Expand All @@ -11,14 +14,17 @@ jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/run-tests
lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
- browser-tools/install-browser-tools
- solidusio_extensions/lint-code

workflows:
Expand Down
19 changes: 11 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ 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
gem 'solidus', github: 'solidusio/solidus', branch: branch

# The solidus_frontend gem has been pulled out since v3.2
gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
Expand All @@ -20,7 +18,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 @@ -35,6 +33,11 @@ gem 'dato', require: 'dato'
gem 'prismic.io', require: 'prismic'
gem 'solidus_static_content', github: 'solidusio-contrib/solidus_static_content'

# 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
42 changes: 29 additions & 13 deletions bin/sandbox
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash

set -e
if [ ! -z $DEBUG ]
then
set -x
fi

case "$DB" in
postgres|postgresql)
Expand All @@ -9,21 +13,36 @@ postgres|postgresql)
mysql)
RAILSDB="mysql"
;;
sqlite|'')
sqlite3|sqlite)
RAILSDB="sqlite3"
;;
'')
echo "~~> Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
RAILSDB="sqlite3"
;;
*)
echo "Invalid DB specified: $DB"
echo "Invalid value specified for the Solidus sandbox: DB=\"$DB\"."
echo "Please use 'postgres', 'mysql', or 'sqlite' instead."
exit 1
;;
esac
echo "~~> Using $RAILSDB as the database engine"

if [ ! -z $SOLIDUS_BRANCH ]
if [ -n $SOLIDUS_BRANCH ]
then
BRANCH=$SOLIDUS_BRANCH
else
echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch"
BRANCH="master"
fi
echo "~~> Using branch $BRANCH of solidus"

if [ -z $SOLIDUS_FRONTEND ]
then
echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
SOLIDUS_FRONTEND="solidus_frontend"
fi
echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend"

extension_name="solidus_content"

Expand All @@ -50,7 +69,6 @@ fi
cd ./sandbox
cat <<RUBY >> Gemfile
gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
gem 'solidus_auth_devise', '>= 2.1.0'
gem 'rails-i18n'
gem 'solidus_i18n'

Expand All @@ -67,20 +85,18 @@ unbundled bundle install --gemfile Gemfile

unbundled bundle exec rake db:drop db:create

unbundled bundle exec rails generate spree:install \
unbundled bundle exec rails generate solidus:install \
--auto-accept \
--user_class=Spree::User \
--enforce_available_locales=true \
--with-authentication=false \
--payment-method=none
--with-authentication=true \
--payment-method=none \
--frontend=${SOLIDUS_FRONTEND} \
$@

unbundled bundle exec rails generate solidus:auth:install
unbundled bundle exec rails generate ${extension_name}:install
unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations
unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations

echo
echo "🚀 Sandbox app successfully created for $extension_name!"
echo "🚀 Using $RAILSDB and Solidus $BRANCH"
echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
echo "🚀 This app is intended for test purposes."
echo "🧪 This app is intended for test purposes."
2 changes: 2 additions & 0 deletions spec/features/admin/sidebar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
end

it 'shows Content menu item in the sidebar' do
find('#admin-nav-toggle').click

within '[data-hook="admin_tabs"]' do
expect(page).to have_text(I18n.t(:content, scope: %i[spree admin tab]))
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/solidus_content/entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
end

specify "#data" do
expect(entry.entry_type)
allow(entry.entry_type)
.to receive(:content_for).with(entry).and_return(data: :foo)

expect(entry.data).to eq(:foo)
Expand All @@ -92,7 +92,7 @@
specify "#content" do
content = instance_double(Hash)

expect(entry.entry_type)
allow(entry.entry_type)
.to receive(:content_for).with(entry).and_return(content)

expect(entry.content).to eq(content)
Expand Down
2 changes: 1 addition & 1 deletion spec/models/solidus_content/entry_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

shared_examples 'a content provider' do
it 'calls the content-provider call method' do
expect(
allow(
SolidusContent.config.providers[provider_name.to_sym]
).to receive(:call).with(
slug: entry.slug,
Expand Down
4 changes: 2 additions & 2 deletions spec/solidus_content/providers/contentful_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
end

it 'returns data using Contentful client' do
expect(Contentful::Client)
allow(Contentful::Client)
.to receive(:new)
.with(space: contentful_space_id, access_token: contentful_access_token)
.and_return(contentful)

expect(contentful).to receive(:entry).with(entry_id).and_return(entry)
allow(contentful).to receive(:entry).with(entry_id).and_return(entry)

expect(subject[:data]).to eq(data)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/solidus_content/providers/dato_cms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
end

it 'returns data using DatoCMS client' do
expect(Dato::Site::Client)
allow(Dato::Site::Client)
.to receive(:new)
.with(api_token, environment: environment)
.and_return(dato)

expect(repo).to receive(:find).with(item_id, version: version).and_return(fields)
allow(repo).to receive(:find).with(item_id, version: version).and_return(fields)

expect(subject[:data]).to eq(fields)
end
Expand Down
8 changes: 4 additions & 4 deletions spec/solidus_content/providers/prismic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
end

it 'returns data using Prismic client' do
expect(::Prismic)
allow(::Prismic)
.to receive(:api)
.with(api_entry_point, api_token)
.and_return(prismic)

expect(prismic).to receive(:getByID).with(id).and_return(entry)
allow(prismic).to receive(:getByID).with(id).and_return(entry)

expect(subject[:data]).to eq(data)
end
Expand All @@ -68,12 +68,12 @@
end

it 'returns data using Prismic client' do
expect(::Prismic)
allow(::Prismic)
.to receive(:api)
.with(api_entry_point, nil)
.and_return(prismic)

expect(prismic).to receive(:getByID).with(id).and_return(entry)
allow(prismic).to receive(:getByID).with(id).and_return(entry)

expect(subject[:data]).to eq(data)
end
Expand Down
11 changes: 0 additions & 11 deletions spec/support/capybara.rb

This file was deleted.