Skip to content
Merged
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
46 changes: 30 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,47 @@ orbs:
# or goes EOL.
solidusio_extensions: solidusio/extensions@volatile

executors:
sqlite:
description: Run specs with an SQLite
docker:
- image: cimg/ruby:2.7-browsers
environment:
RAILS_ENV: test
DB: sqlite

jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
executor:
name: solidusio_extensions/postgres
ruby_version: "3.2"
environment:
FRONTEND: "/home/circleci/project/spec/solidus_frontend_app_template.rb"
AUTHENTICATION: "devise"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we use to test this extension with solidus_auth_devise?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is necessary for triggering saving a customer on stripe within some specs. I had to force it because solidus main wasn't picking it up anymore (probably related to solidus_frontend support being removed).

steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
- checkout
- solidusio_extensions/dependencies
- solidusio_extensions/run-tests-solidus-main
- solidusio_extensions/store-test-results

run-specs-with-mysql:
executor: solidusio_extensions/mysql
executor:
name: solidusio_extensions/mysql
ruby_version: "3.1"
environment:
FRONTEND: "/home/circleci/project/spec/solidus_frontend_app_template.rb"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please better help me understand why this is needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's because up to Solidus v3.4 solidus_frontend was available as an option, and by just adding the gem to the gemfile we were able to trick the solidus installer into using it, having removed it in v4 we need a custom app template to install it. Rather than having different behaviors for v3 and v4 we just use the same recipe (which is fairly simple anyway).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Sounds like something we will need to use for all extensions that were testing against the old frontend at some point.

steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
- checkout
- solidusio_extensions/dependencies
- solidusio_extensions/run-tests-solidus-current
- solidusio_extensions/store-test-results
run-specs-with-sqlite:
executor: sqlite
executor:
name: solidusio_extensions/sqlite
ruby_version: "3.0"
steps:
- browser-tools/install-chrome
- solidusio_extensions/run-tests
- checkout
- solidusio_extensions/dependencies
- solidusio_extensions/run-tests-solidus-older
- solidusio_extensions/store-test-results
lint-code:
executor: solidusio_extensions/sqlite-memory
executor:
name: solidusio_extensions/sqlite-memory
ruby_version: "3.0"
steps:
- solidusio_extensions/lint-code

Expand Down
40 changes: 39 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,42 @@ ENV['SKIP_SOLIDUS_BOLT'] = 'true'
require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install

task default: 'extension:specs'
# Override the default dummy app generation task to
# make it compatible with all the supported Solidus versions.
Rake::Task['extension:test_app'].clear
task 'extension:test_app' do # rubocop:disable Rails/RakeEnvironment
Spree::DummyGeneratorHelper.inject_extension_requirements = true

require 'solidus_stripe'

Rails.env = ENV["RAILS_ENV"] = 'test'

Spree::DummyGenerator.start ["--lib-name=solidus_stripe"]

# While the dummy app is generated the current directory
# within ruby is changed to that of the dummy app.
sh({
'FRONTEND' => ENV['FRONTEND'] || "#{__dir__}/spec/solidus_frontend_app_template.rb",
}, [
'bin/rails',
'generate',
'solidus:install',
Dir.pwd, # use the current dir as Rails.root
"--auto-accept",
"--authentication=none",
"--payment-method=none",
"--migrate=false",
"--seed=false",
"--sample=false",
"--user-class=Spree::LegacyUser",
].shelljoin)

puts "Setting up dummy database..."
sh "bin/rails db:environment:set RAILS_ENV=test"
sh "bin/rails db:drop db:create db:migrate VERBOSE=false RAILS_ENV=test"

puts 'Running extension installation generator...'
sh "bin/rails generate solidus_stripe:install --auto-run-migrations"
end

task default: ['extension:specs']
2 changes: 1 addition & 1 deletion lib/generators/solidus_stripe/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def add_migrations
end

def run_migrations
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
run_migrations = options[:auto_run_migrations] || ENV['CI'] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
if run_migrations
run 'bin/rails db:migrate'
else
Expand Down
2 changes: 1 addition & 1 deletion solidus_stripe.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency 'solidus_core', ['>= 2.3', '< 4']
spec.add_dependency 'solidus_core', ['>= 3', '< 5']
spec.add_dependency 'solidus_support', '~> 0.8'
spec.add_dependency 'activemerchant', '>= 1.105'
spec.add_dependency 'rexml'
Expand Down
8 changes: 4 additions & 4 deletions spec/features/stripe_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

FactoryBot.create(:product, name: "DL-44")

visit spree.root_path
visit '/'
click_link "DL-44"
click_button "Add To Cart"

Expand Down Expand Up @@ -85,7 +85,7 @@
click_button "Place Order"
expect(page).to have_content("Your order has been processed successfully")

visit spree.root_path
visit '/'
click_link "DL-44"
click_button "Add To Cart"

Expand Down Expand Up @@ -207,7 +207,7 @@
click_button "Place Order"
expect(page).to have_content("Your order has been processed successfully")

visit spree.root_path
visit '/'
click_link "DL-44"
click_button "Add To Cart"

Expand Down Expand Up @@ -329,7 +329,7 @@
click_button "Place Order"
expect(page).to have_content("Your order has been processed successfully")

visit spree.root_path
visit '/'
click_link "DL-44"
click_button "Add To Cart"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
end

before do
response = double(success?: true, authorization: payment.response_code)
response = ActiveMerchant::Billing::Response.new(true, nil, {}, authorization: payment.response_code)
allow_any_instance_of(Spree::PaymentMethod::StripeCreditCard).to receive(:void) { response }
end

Expand Down
12 changes: 8 additions & 4 deletions spec/models/spree/payment_method/stripe_credit_card_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,14 @@
end

let!(:success_response) do
double('success_response', success?: true,
authorization: '123',
avs_result: { 'code' => 'avs-code' },
cvv_result: { 'code' => 'cvv-code', 'message' => "CVV Result" })
ActiveMerchant::Billing::Response.new(
true,
nil,
{},
avs_result: { 'code' => 'avs-code' },
cvv_result: 'cvv-code',
authorization: '123',
)
end

after do
Expand Down
17 changes: 17 additions & 0 deletions spec/solidus_frontend_app_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

create_file "public/robots.txt"
bundle_command "add solidus_frontend --github solidusio/solidus_frontend --branch #{ENV['SOLIDUS_BRANCH'] || 'main'}"
generate "solidus_frontend:install --auto-accept"
empty_directory 'lib/generators/solidus_frontend/install'

create_file 'lib/generators/solidus_frontend/install/install_generator.rb', <<-CODE
puts "SolidusFrontend::Generators::InstallGenerator was disabled."
module SolidusFrontend
module Generators
class InstallGenerator < Rails::Generators::Base
class_option :auto_accept, type: :boolean, default: false
end
end
end
CODE