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
26 changes: 18 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,46 @@ name: Test
on:
push:
branches:
- master
- main
pull_request:
schedule:
- cron: "0 0 * * 4" # every Thursday
concurrency:
group: test-${{ github.ref_name }}
cancel-in-progress: ${{ github.ref_name != 'master' }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
permissions:
contents: read
jobs:
rspec:
name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }}
runs-on: ubuntu-24.04
strategy:
fail-fast: true
fail-fast: false
matrix:
rails-version:
- "7.0"
- "7.0.10"
- "7.1.6"
- "8.0.2"
ruby-version:
- "3.1"
- "3.2"
- "3.3"
solidus-branch:
- "v3.2"
- "v3.3"
- "v3.4"
- "v4.0"
- "v4.3"
- "v4.5"
database:
- "postgresql"
- "mysql"
- "sqlite"
exclude:
- rails-version: "7.1.6"
solidus-branch: "v4.0"
- rails-version: "8.0.2"
solidus-branch: "v4.0"
- rails-version: "8.0.2"
solidus-branch: "v4.3"
- rails-version: "8.0.2"
ruby-version: "3.1"
steps:
- uses: actions/checkout@v4
- name: Run extension tests
Expand Down
56 changes: 27 additions & 29 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'v3.4')
solidus_git, solidus_frontend_git = if (branch == 'main') || (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
solidus_version = ENV.fetch("SOLIDUS_BRANCH", "v4.5")
gem "solidus", github: "solidusio/solidus", branch: solidus_version

# 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'
rails_requirement_string = ENV.fetch("RAILS_VERSION", ">0.a")
gem "rails", rails_requirement_string

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

# Standard library gems that became separate in Ruby 3.4+
gem 'bigdecimal'
gem 'mutex_m'
gem 'drb'
gem 'csv'
gem 'ostruct'

# This is locked due to a 'stack level too deep' error/bug in v0.1.0.
gem 'state_machines', '~> 0.6.0'

gem 'concurrent-ruby', '1.3.4'

case ENV['DB']
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
gem "bigdecimal"
gem "mutex_m"
gem "drb"
gem "csv"
gem "ostruct"

# This is locked due to a "stack level too deep" error/bug in v0.10.0
gem "state_machines", "~> 0.6.0"

gem "concurrent-ruby", "1.3.4"

case ENV["DB"]
when "mysql"
gem "mysql2"
when "postgresql"
gem "pg"
else
gem 'sqlite3', '~> 1.4'
rails_version = Gem::Requirement.new(rails_requirement_string).requirements[0][1]
sqlite_version = (rails_version < Gem::Version.new(7.2)) ? "~> 1.4" : "~> 2.0"

gem "sqlite3", sqlite_version
end

gemspec
Expand All @@ -48,4 +46,4 @@ gemspec
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# solidus_tracking

[![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_tracking.svg?style=svg)](https://circleci.com/gh/solidusio-contrib/solidus_tracking)
[![Test](https://github.com/solidusio-contrib/solidus_tracking/actions/workflows/test.yml/badge.svg)](https://github.com/solidusio-contrib/solidus_tracking/actions/workflows/test.yml)

This extension provides a data tracking platform (think [Segment](https://segment.com), but
on-premise) for your Solidus store.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

module SolidusTracking
module Spree
module Order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module MailerSubscriber
module DisableConfirmEmail
def self.prepended(base)
base.module_eval do
alias_method :original_order_finalized, :order_finalized
alias_method :original_send_confirmation_email, :send_confirmation_email

def order_finalized(event)
def send_confirmation_email(event)
return if SolidusTracking.configuration.disable_builtin_emails

original_order_finalized(event)
original_send_confirmation_email(event)
end
end
end
Expand All @@ -20,6 +20,4 @@ def order_finalized(event)
end
end

if Spree.solidus_gem_version >= Gem::Version.new('2.9.0')
Spree::MailerSubscriber.prepend(SolidusTracking::Spree::MailerSubscriber::DisableConfirmEmail)
end
Spree::OrderMailerSubscriber.prepend(SolidusTracking::Spree::MailerSubscriber::DisableConfirmEmail)
10 changes: 10 additions & 0 deletions lib/generators/solidus_tracking/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
module SolidusTracking
module Generators
class InstallGenerator < Rails::Generators::Base
class_option :auto_run_migrations, type: :boolean, default: false
source_root File.expand_path('templates', __dir__)

def copy_initializer
template 'initializer.rb', 'config/initializers/solidus_tracking.rb'
end

def run_migrations
run_migrations = options[:auto_run_migrations] || ["", "y", "Y"].include?(ask("Would you like to run the migrations now? [Y/n]"))
if run_migrations
run "bin/rails db:migrate"
else
puts "Skipping bin/rails db:migrate, don't forget to run it!" # rubocop:disable Rails/Output
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/solidus_tracking/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SolidusTracking
VERSION = '0.0.1'
VERSION = '1.0.0'
end
8 changes: 4 additions & 4 deletions solidus_tracking.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_tracking'
spec.metadata['changelog_uri'] = 'https://github.com/aldesantis/solidus_tracking/releases'

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

# 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.
Expand All @@ -28,8 +28,8 @@ 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.0.0', '< 4']
spec.add_dependency 'solidus_support', '~> 0.8'
spec.add_dependency 'solidus_core', ['>= 4.0.0', '< 4.6']

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you add something in this commit about why we don't support 4.6/main?

spec.add_dependency 'solidus_support', ['>= 0.13.0', '< 1']

spec.add_development_dependency 'solidus_dev_support'
spec.add_development_dependency 'solidus_dev_support', '~> 2.6'
end
9 changes: 4 additions & 5 deletions spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
expect(SolidusTracking::TrackEventJob).to have_been_enqueued.with(
'started_checkout',
order: order,
)
).at_least(:once)
end
end
end
Expand All @@ -25,19 +25,18 @@
expect(SolidusTracking::TrackEventJob).to have_been_enqueued.with(
'placed_order',
order: order,
)
).at_least(:once)
end

it 'tracks the Ordered Product events' do
order = Spree::TestingSupport::OrderWalkthrough.up_to(:payment)

order.complete!

order.line_items.each do |line_item|
expect(SolidusTracking::TrackEventJob).to have_been_enqueued.with(
'ordered_product',
line_item: line_item,
)
).at_least(:once)
end
end

Expand Down Expand Up @@ -75,7 +74,7 @@
expect(SolidusTracking::TrackEventJob).to have_been_enqueued.with(
'cancelled_order',
order: order,
)
).at_least(:once)
end

context 'when disable_builtin_emails is true' do
Expand Down
7 changes: 7 additions & 0 deletions spec/models/spree/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
end
end


describe '#send_reset_password_instructions' do
before do
allow(Devise.mailer)
.to receive(:reset_password_instructions)
.and_return(double(deliver_now: true))
end

it 'tracks the Requested Password Reset event' do
create(:store)
user = create(:user)
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'ostruct'

# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'

Expand Down