@@ -2,39 +2,32 @@ module RSpec
2
2
module Rails
3
3
# @private
4
4
module FixtureFileUploadSupport
5
- extend ActiveSupport ::Concern
6
-
7
- included do
8
- delegate :fixture_file_upload , :to => :rails_fixture_file_wrapper
9
- end
10
-
11
- private
12
-
13
- def rails_fixture_file_wrapper
14
- resolved_fixture_path = ( fixture_path || RSpec . configuration . fixture_path || '' )
15
- RailsFixtureFileWrapper . fixture_path = File . join ( resolved_fixture_path , '' )
16
- RailsFixtureFileWrapper . instance
5
+ def self . included ( other )
6
+ if defined? ( ActionDispatch ::TestProcess )
7
+ other . include ActionDispatch ::TestProcess
8
+ end
9
+ other . extend FixturePathAttribute
17
10
end
18
11
19
- class RailsFixtureFileWrapper
20
- class << self
21
- attr_reader :fixture_path
12
+ module FixturePathAttribute
13
+ def fixture_path
14
+ @fixture_path ||= calculate_path
15
+ end
22
16
23
- # Get the instance of wrapper
24
- def instance
25
- @instance ||= new
17
+ def fixture_path = ( value )
18
+ # Rails 3.0..3.1 are using ActionController::TestCase class to resolve fixture_path
19
+ # see https://apidock.com/rails/v3.0.0/ActionDispatch/TestProcess/fixture_file_upload
20
+ if ActionController ::TestCase . respond_to? ( :fixture_path )
21
+ ActionController ::TestCase . fixture_path = value
26
22
end
23
+ @fixture_path = value
24
+ end
27
25
28
- def fixture_path = ( value )
29
- # Rails 3.0..3.1 are using ActionController::TestCase class to resolve fixture_path
30
- # see https://apidock.com/rails/v3.0.0/ActionDispatch/TestProcess/fixture_file_upload
31
- if ActionController ::TestCase . respond_to? ( :fixture_path )
32
- ActionController ::TestCase . fixture_path = value
33
- end
34
- @fixture_path = value
35
- end
26
+ private
36
27
37
- include ActionDispatch ::TestProcess if defined? ( ActionDispatch ::TestProcess )
28
+ def calculate_fixture_path
29
+ resolved_fixture_path = ( fixture_path || RSpec . configuration . fixture_path || '' )
30
+ self . fixture_path = File . join ( resolved_fixture_path , '' )
38
31
end
39
32
end
40
33
end
0 commit comments