solidus_dev_support 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2909d8c487345aa45ebf8962ace27cbc7d8e2a34eeb2f3eb6ba380913b50c2b4
|
4
|
+
data.tar.gz: a921fad3ec04944509f46f7a113a073b48100971395950525242c48a83b994e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb86bd58f06496f53b3c5f4d84ce47b41b9be72135d77aba58ee12b0bffdbc3afef0325fc4ec1dd2926d6cf6a97b11527380372ba28e4adb26719f5d3c9dc4d
|
7
|
+
data.tar.gz: 39e02e67c9b94436456bf5c751196a6b600dac9ac70b7c90488fa5f2793f959c41302cfc8b66ad860c1daac28ea8811e41571fd711f18ba55526ea59133b3fae
|
@@ -1,10 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'factory_bot'
|
4
|
+
|
5
|
+
Spree::Deprecation.silence do
|
6
|
+
require 'spree/testing_support/factories'
|
7
|
+
puts <<~MSG
|
8
|
+
We are transitioning to a new way of loading factories for extensions.
|
9
|
+
Be sure this extension does not load factories using require but uses
|
10
|
+
the load_for() method in its spec_helper.rb, eg:
|
11
|
+
|
12
|
+
SolidusDevSupport::TestingSupport::Factories.load_for(ExtensionName1::Engine, ExtensionName2::Engine)
|
13
|
+
|
14
|
+
This will load Solidus Core factories right before the ones defined in
|
15
|
+
lib/extension_name/testing_support/factories/*_factory.rb or
|
16
|
+
lib/extension_name/testing_support/factories.rb
|
17
|
+
|
18
|
+
This message will be removed when all extensions are updated.
|
19
|
+
MSG
|
20
|
+
end
|
21
|
+
|
3
22
|
begin
|
4
23
|
require 'spree/testing_support/factory_bot'
|
5
24
|
rescue LoadError
|
6
|
-
|
7
|
-
require 'spree/testing_support/factories'
|
25
|
+
# Do nothing, we are testing the extension against an old version of Solidus
|
8
26
|
end
|
9
27
|
|
10
28
|
module SolidusDevSupport
|
@@ -12,21 +30,37 @@ module SolidusDevSupport
|
|
12
30
|
module Factories
|
13
31
|
def self.load_for(*engines)
|
14
32
|
paths = engines.flat_map do |engine|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
33
|
+
# Check if the extension has a lib/*/factories.rb. If it does, we emit a
|
34
|
+
# deprecation warning and just use it.
|
35
|
+
obsolete_factories_file = engine.root.glob('lib/*/factories.rb').first # 'lib/*/factories/*_factory.rb'
|
36
|
+
if obsolete_factories_file.present?
|
19
37
|
ActiveSupport::Deprecation.warn <<-WARN.squish, caller(4)
|
20
38
|
SolidusDevSupport::TestingSupport::Factories.load_for() is automatically loading
|
21
|
-
all factories present
|
22
|
-
|
39
|
+
all factories present in #{obsolete_factories_file.dirname.to_s.gsub(engine.root.to_s, '')}/testing_support/factories/.
|
40
|
+
Please move the content of #{obsolete_factories_file.to_s.gsub(engine.root.to_s, '')} to that directory.
|
23
41
|
WARN
|
24
42
|
|
25
|
-
|
43
|
+
[obsolete_factories_file]
|
26
44
|
else
|
27
|
-
|
28
|
-
|
29
|
-
|
45
|
+
# If there are both a lib/*/testing_support/factories.rb and a lib/*/testing_support/factories/,
|
46
|
+
# we assume that the factories.rb file is only used to load all factories prensent in the directory.
|
47
|
+
# That file can be removed from the extension, in fact, we ignore it and emit a message asking to
|
48
|
+
# remove it.
|
49
|
+
factories_file_or_folder = engine.root.glob('lib/*/testing_support/factories{,.rb}')
|
50
|
+
if factories_file_or_folder.size == 2
|
51
|
+
folder, file = factories_file_or_folder.partition(&:directory?).map(&:first).map { |path| path.to_s.gsub(engine.root.to_s, '') }
|
52
|
+
ActiveSupport::Deprecation.warn <<-WARN.squish, caller(4)
|
53
|
+
SolidusDevSupport::TestingSupport::Factories.load_for() is automatically loading
|
54
|
+
all factories present into #{folder}. You should now safely remove #{file} if it
|
55
|
+
is only used to load ./factories content.
|
56
|
+
WARN
|
57
|
+
|
58
|
+
engine.root.glob('lib/*/testing_support/factories/**/*_factory.rb')
|
59
|
+
else
|
60
|
+
factories_file_or_folder
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end.map { |path| path.sub(/.rb\z/, '').to_s }
|
30
64
|
|
31
65
|
if using_factory_bot_definition_file_paths?
|
32
66
|
FactoryBot.definition_file_paths = [
|