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
20 changes: 11 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
version: 2.1

orbs:
# 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
solidusio_extensions: solidusio/[email protected]

jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
executor:
name: solidusio_extensions/postgres
ruby_version: "3.1"
steps:
- solidusio_extensions/run-tests
- checkout
- solidusio_extensions/run-tests-solidus-older
run-specs-with-mysql:
executor: solidusio_extensions/mysql
executor:
name: solidusio_extensions/mysql
ruby_version: "3.1"
steps:
- solidusio_extensions/run-tests
- checkout
- solidusio_extensions/run-tests-solidus-older
lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
Expand Down
6 changes: 0 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ require:

Layout/LineLength:
Enabled: false

RSpec/NestedGroups:
Max: 4

RSpec/MessageSpies:
Enabled: false
29 changes: 13 additions & 16 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
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
solidus_branch = ENV.fetch('SOLIDUS_BRANCH', 'v4.5')
gem 'solidus', github: "solidusio/solidus", branch: solidus_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'
gem "rails", ">0.a"

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

case ENV['DB']
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
gem 'concurrent-ruby', '1.3.4'
gem 'state_machines', '0.6.0'

case ENV["DB"]
when "mysql"
gem "mysql2"
when "postgresql"
gem "pg"
else
gem 'sqlite3'
gem "sqlite3", "~> 1.4"
end

gemspec
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)
4 changes: 2 additions & 2 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,7 +28,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.0.0', '< 4']
spec.add_dependency 'solidus_core', ['>= 4.0.0', '< 4.6']
spec.add_dependency 'solidus_support', '~> 0.8'

spec.add_development_dependency 'solidus_dev_support'
Expand Down
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: 1 addition & 1 deletion spec/solidus_tracking/event/cancelled_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
end

it 'includes an event ID and value' do
order = build_stubbed(:order)
order = build(:order)
allow(SolidusTracking::Serializer::LineItem).to receive(:serialize)
.with(order)
.and_return('foo' => 'bar')
Expand Down
3 changes: 2 additions & 1 deletion spec/solidus_tracking/event/fulfilled_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
end

it 'includes an event ID and value' do
order = build_stubbed(:order)
order = build(:order)

allow(SolidusTracking::Serializer::LineItem).to receive(:serialize)
.with(order)
.and_return('foo' => 'bar')
Expand Down
2 changes: 1 addition & 1 deletion spec/solidus_tracking/event/placed_order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
end

it 'includes an event ID and value' do
order = build_stubbed(:order)
order = build(:order)
allow(SolidusTracking::Serializer::LineItem).to receive(:serialize)
.with(order)
.and_return('foo' => 'bar')
Expand Down
2 changes: 1 addition & 1 deletion spec/solidus_tracking/event/started_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
end

it 'includes an event ID and value' do
order = build_stubbed(:order)
order = build(:order)
allow(SolidusTracking::Serializer::LineItem).to receive(:serialize)
.with(order)
.and_return('foo' => 'bar')
Expand Down
2 changes: 1 addition & 1 deletion spec/solidus_tracking/serializer/address_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe SolidusTracking::Serializer::Address do
describe '.serialize' do
it 'serializes the address' do
address = build_stubbed(:address)
address = build(:address)

expect(described_class.serialize(address)).to be_instance_of(Hash)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/solidus_tracking/serializer/payment_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe SolidusTracking::Serializer::PaymentSource do
describe '.serialize' do
it 'serializes the payment source' do
payment_source = build_stubbed(:credit_card)
payment_source = build(:credit_card)

expect(described_class.serialize(payment_source)).to be_instance_of(Hash)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/solidus_tracking/serializer/payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe SolidusTracking::Serializer::Payment do
describe '.serialize' do
it 'serializes the payment' do
payment = build_stubbed(:payment)
payment = build(:payment)

expect(described_class.serialize(payment)).to be_instance_of(Hash)
end
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