Skip to content

Commit 397224f

Browse files
authored
Merge branch 'solidusio:master' into make-sample-load-depend-on-seed
2 parents df4f5ce + f06fb16 commit 397224f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+49
-41
lines changed

.circleci/config.yml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: 2.1
33
orbs:
44
browser-tools: circleci/browser-tools@1.3
55
codecov: codecov/codecov@3.2.3
6-
slack: circleci/slack@4.9.3
76

87
executors:
98
base:
@@ -85,13 +84,6 @@ commands:
8584
paths:
8685
- vendor/bundle
8786

88-
notify:
89-
steps:
90-
- slack/notify:
91-
event: fail
92-
template: basic_fail_1
93-
branch_pattern: master, v[0-9]+\.[0-9]+
94-
9587
test:
9688
steps:
9789
- run:
@@ -169,16 +161,16 @@ commands:
169161
cat /tmp/.tool-versions
170162
- restore_cache:
171163
keys:
172-
- solidus-installer-v6-{{ checksum "/tmp/.tool-versions" }}
173-
- solidus-installer-v6-
164+
- solidus-installer-v7-{{ checksum "/tmp/.tool-versions" }}
165+
- solidus-installer-v7-
174166
- run:
175167
name: "Prepare the rails application"
176168
command: |
177169
cd /tmp
178170
test -d my_app || gem install rails solidus
179-
test -d my_app || rails new my_app --skip-javascript --skip-git
171+
test -d my_app || rails new my_app --skip-git
180172
- save_cache:
181-
key: solidus-installer-v5-{{ checksum "/tmp/.tool-versions" }}
173+
key: solidus-installer-v7-{{ checksum "/tmp/.tool-versions" }}
182174
paths:
183175
- /tmp/my_app
184176
- /home/circleci/.rubygems
@@ -247,7 +239,6 @@ jobs:
247239
bundle add solidus --git "file://$(ruby -e"puts File.expand_path ENV['CIRCLE_WORKING_DIRECTORY']")"
248240
export LIB_NAME=set # dummy requireable file
249241
bundle exec rake -rrails -rspree/testing_support/extension_rake -e'Rake::Task["extension:test_app"].invoke'
250-
- notify
251242
252243
test_solidus:
253244
parameters:
@@ -279,7 +270,6 @@ jobs:
279270
- setup
280271
- libvips
281272
- test
282-
- notify
283273

284274
test_with_coverage:
285275
parameters:
@@ -301,7 +291,6 @@ jobs:
301291
- setup
302292
- libvips
303293
- test_with_coverage
304-
- notify
305294

306295
dev_tools:
307296
docker:
@@ -314,34 +303,27 @@ jobs:
314303
cd dev_tools
315304
bundle
316305
bundle exec rspec
317-
- notify
318306
319307
workflows:
320308
build:
321309
jobs:
322-
- solidus_installer:
323-
context: slack-secrets
310+
- solidus_installer
324311

325312
# Only test with coverage support with the default versions
326313
- test_with_coverage:
327-
context: slack-secrets
328314
post-steps:
329315
- codecov/upload:
330316
file: $COVERAGE_FILE
331317

332318
# Based on supported versions for the current Solidus release and recommended versions from
333319
# https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html.
334320
- test_solidus:
335-
context: slack-secrets
336321
name: &name "test-rails-<<matrix.rails>>-ruby-<<matrix.ruby>>-<<matrix.database>>-<<#matrix.paperclip>>paperclip<</matrix.paperclip>><<^matrix.paperclip>>activestorage<</matrix.paperclip>><<#matrix.legacy_events>>-legacy_events<</matrix.legacy_events>>"
337322
matrix: { parameters: { rails: ['7.0'], ruby: ['3.1', '3.2'], database: ['mysql', 'sqlite', 'postgres'], paperclip: [true, false], legacy_events: [false] } }
338323
- test_solidus:
339-
context: slack-secrets
340324
name: *name
341325
matrix: { parameters: { rails: ['6.1'], ruby: ['2.7', '3.0', '3.1'], database: ['sqlite'], paperclip: [false], legacy_events: [false] } }
342326
- test_solidus:
343-
context: slack-secrets
344327
name: *name
345328
matrix: { parameters: { rails: ['6.0'], ruby: ['2.7'], database: ['sqlite'], paperclip: [true], legacy_events: [true] } }
346-
- dev_tools:
347-
context: slack-secrets
329+
- dev_tools

bin/sandbox

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ unbundled bundle exec rails new sandbox --database="$RAILSDB" \
4747
--skip-keeps \
4848
--skip-rc \
4949
--skip-spring \
50-
--skip-test \
51-
--skip-javascript
50+
--skip-test
5251

5352
if [ ! -d "sandbox" ]; then
5453
echo 'sandbox rails application failed'

core/app/models/spree/wallet/add_payment_sources_to_wallet.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ def add_to_wallet
2424
# add valid sources to wallet and optionally set a default
2525
if sources.any?
2626
# arbitrarily sort by id for picking a default
27-
sources.sort_by(&:id).each do |source|
27+
order_wallet_payment_sources = sources.sort_by(&:id).map do |source|
2828
order.user.wallet.add(source)
2929
end
3030

31-
make_default
31+
make_default(order_wallet_payment_sources)
3232
end
3333
end
3434
end
3535

3636
protected
3737

38-
def make_default
39-
order.user.wallet.default_wallet_payment_source = order.user.wallet_payment_sources.last
38+
def make_default(sources)
39+
order.user.wallet.default_wallet_payment_source = sources.last
4040
end
4141

4242
private

core/lib/spree/testing_support/dummy_app.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Application < ::Rails::Application
9090
config.active_record.dump_schema_after_migration = false
9191

9292
# Configure active storage to use storage within tmp folder
93-
unless ENV['DISABLE_ACTIVE_STORAGE']
93+
unless (ENV['DISABLE_ACTIVE_STORAGE'] == 'true')
9494
initializer 'solidus.active_storage' do
9595
config.active_storage.service_configurations = {
9696
test: {
@@ -140,7 +140,7 @@ class Application < ::Rails::Application
140140
Spree.config do |config|
141141
config.use_legacy_events = (ENV['USE_LEGACY_EVENTS'] == 'true')
142142

143-
if ENV['DISABLE_ACTIVE_STORAGE']
143+
if (ENV['DISABLE_ACTIVE_STORAGE'] == 'true')
144144
config.image_attachment_module = 'Spree::Image::PaperclipAttachment'
145145
config.taxon_attachment_module = 'Spree::Taxon::PaperclipAttachment'
146146
end

core/spec/models/spree/concerns/active_storage_adapter/attachment_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'rails_helper'
44

5-
unless ENV['DISABLE_ACTIVE_STORAGE']
5+
unless (ENV['DISABLE_ACTIVE_STORAGE'] == 'true')
66
RSpec.describe Spree::ActiveStorageAdapter::Attachment do
77
describe '#variant' do
88
it "converts to resize_to_limit when definition doesn't contain any special symbol" do

core/spec/models/spree/user_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
stub_spree_preferences(completable_order_created_cutoff_days: 1)
4040
end
4141

42-
it "excludes orders updated outside of the cutoff date" do
42+
it "excludes orders created outside of the cutoff date" do
4343
create(:order, user: user, created_by: user, created_at: 3.days.ago, updated_at: 2.days.ago)
4444
expect(user.last_incomplete_spree_order).to eq nil
4545
end
4646
end
4747

48-
context "with completable_order_created_cutoff set" do
48+
context "with completable_order_updated_cutoff set" do
4949
before do
5050
stub_spree_preferences(completable_order_updated_cutoff_days: 1)
5151
end

core/spec/models/spree/wallet/add_payment_sources_to_wallet_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,41 @@
44

55
RSpec.describe Spree::Wallet::AddPaymentSourcesToWallet, type: :model do
66
let(:order) { create(:order_ready_to_complete) }
7+
let(:user) { order.user }
78

89
describe '#add_to_wallet' do
910
subject { described_class.new(order) }
1011

12+
before do
13+
# Ensure the payment is reusable, otherwise false positives occur
14+
allow_any_instance_of(Spree::CreditCard).to receive(:reusable?).and_return(true)
15+
end
16+
1117
it 'saves the payment source' do
1218
expect { subject.add_to_wallet }.to change {
1319
order.user.wallet.wallet_payment_sources.count
1420
}.by(1)
1521
end
22+
23+
context "when the default wallet payment source is used and a more recent wallet payment exists" do
24+
before do
25+
credit_card_one = user.wallet.add(create(:credit_card, user: user))
26+
user.wallet.add(create(:credit_card, user: user))
27+
user.wallet.default_wallet_payment_source = credit_card_one # must be the first created card
28+
order.payments.first.update!(source: credit_card_one.payment_source)
29+
end
30+
31+
it 'does not make a new wallet payment source' do
32+
expect { subject.add_to_wallet }.to_not change {
33+
order.user.wallet.wallet_payment_sources.count
34+
}
35+
end
36+
37+
it 'does not change the default wallet payment source' do
38+
expect { subject.add_to_wallet }.to_not change {
39+
user.wallet.default_wallet_payment_source
40+
}
41+
end
42+
end
1643
end
1744
end

core/spec/rails_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
config.use_transactional_fixtures = true
3838

3939
config.before :suite do
40-
FileUtils.rm_rf(Rails.configuration.active_storage.service_configurations[:test][:root]) unless ENV['DISABLE_ACTIVE_STORAGE']
40+
FileUtils.rm_rf(Rails.configuration.active_storage.service_configurations[:test][:root]) unless (ENV['DISABLE_ACTIVE_STORAGE'] == 'true')
4141
DatabaseCleaner.clean_with :truncation
4242
end
4343

sample/db/samples/assets.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@
8282

8383
products[:solidus_tshirt].variants.each do |variant|
8484
color = variant.option_value("clothing-color").downcase
85-
main_image = image["solidus_tshirt_#{color}", "png"]
85+
main_image = image["solidus_tshirt_#{color}", "jpg"]
8686
File.open(main_image) do |f|
8787
variant.images.create!(attachment: f)
8888
end
89-
back_image = image["solidus_tshirt_back_#{color}", "png"]
89+
back_image = image["solidus_tshirt_back_#{color}", "jpg"]
9090

9191
next unless back_image
9292

@@ -97,11 +97,11 @@
9797

9898
products[:solidus_long].variants.each do |variant|
9999
color = variant.option_value("clothing-color").downcase
100-
main_image = image["solidus_long_#{color}", "png"]
100+
main_image = image["solidus_long_#{color}", "jpg"]
101101
File.open(main_image) do |f|
102102
variant.images.create!(attachment: f)
103103
end
104-
back_image = image["solidus_long_back_#{color}", "png"]
104+
back_image = image["solidus_long_back_#{color}", "jpg"]
105105

106106
next unless back_image
107107

@@ -112,7 +112,7 @@
112112

113113
products[:solidus_womens_tshirt].reload.variants.each do |variant|
114114
color = variant.option_value("clothing-color").downcase
115-
main_image = image["solidus_womens_tshirt_#{color}", "png"]
115+
main_image = image["solidus_womens_tshirt_#{color}", "jpg"]
116116
File.open(main_image) do |f|
117117
variant.images.create!(attachment: f)
118118
end
-53.3 KB

0 commit comments

Comments
 (0)