File tree 4 files changed +11
-34
lines changed
spec/lib/critical_path_css
4 files changed +11
-34
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,6 @@ def base_url
9
9
@config [ 'base_url' ]
10
10
end
11
11
12
- def css_path
13
- @config [ 'css_path' ]
14
- end
15
-
16
12
def css_paths
17
13
@config [ 'css_paths' ]
18
14
end
Original file line number Diff line number Diff line change @@ -19,15 +19,12 @@ def configuration_file_path
19
19
end
20
20
21
21
def format_css_paths
22
- if config [ 'css_path' ]
23
- config [ 'css_path' ] = format_path ( config [ 'css_path' ] )
24
- config [ 'css_paths' ] = [ ]
25
- elsif config [ 'css_paths' ]
26
- config [ 'css_path' ] = ''
27
- config [ 'css_paths' ] = config [ 'css_paths' ] . collect { |path | format_path ( path ) }
22
+ config [ 'css_paths' ] = [ config [ 'css_path' ] ] if config [ 'css_path' ]
23
+
24
+ if config [ 'css_paths' ]
25
+ config [ 'css_paths' ] . map! { |path | format_path ( path ) }
28
26
else
29
- config [ 'css_path' ] = ActionController ::Base . helpers . stylesheet_path ( config [ 'manifest_name' ] , host : '' )
30
- config [ 'css_paths' ] = [ ]
27
+ config [ 'css_paths' ] = [ ActionController ::Base . helpers . stylesheet_path ( config [ 'manifest_name' ] , host : '' ) ]
31
28
end
32
29
end
33
30
Original file line number Diff line number Diff line change 18
18
19
19
describe '#fetch_route' do
20
20
context 'when a single css_path is configured' do
21
- let ( :css_path ) { '/test.css' }
22
- let ( :css_paths ) { [ ] }
21
+ let ( :css_paths ) { [ '/test.css' ] }
23
22
24
23
it 'generates css for the single route' do
25
24
expect ( Open3 ) . to receive ( :capture3 ) do |arg1 , arg2 , arg3 |
35
34
36
35
describe '#fetch' do
37
36
context 'when a single css_path is configured' do
38
- let ( :css_path ) { '/test.css' }
39
- let ( :css_paths ) { [ ] }
37
+ let ( :css_paths ) { [ '/test.css' ] }
40
38
41
39
it 'generates css for each route from the same file' do
42
40
expect ( Open3 ) . to receive ( :capture3 ) do |arg1 , arg2 , arg3 |
50
48
end
51
49
52
50
context 'when multiple css_paths are configured' do
53
- let ( :css_path ) { '' }
54
51
let ( :css_paths ) { [ '/test.css' , '/test2.css' ] }
55
52
56
53
it 'generates css for each route from the respective file' do
67
64
end
68
65
69
66
context 'when same css file applies to multiple routes' do
70
- let ( :css_path ) { '' }
71
67
let ( :css_paths ) { [ '/test.css' , '/test2.css' , '/test.css' ] }
72
68
let ( :routes ) { [ '/' , '/new_route' , '/newer_route' ] }
73
69
Original file line number Diff line number Diff line change 11
11
context 'when single css_path is specified' do
12
12
let ( :config_file ) { file_fixture ( 'config/single-css-path.yml' ) . read }
13
13
14
- it 'sets css_path with the path' do
15
- expect ( subject . config [ 'css_path' ] ) . to eq '/app/spec/internal/public/test.css'
16
- end
17
-
18
- it 'leaves css_paths empty' do
19
- expect ( subject . config [ 'css_paths' ] ) . to eq [ ]
14
+ it 'sets css_paths with the lone path' do
15
+ expect ( subject . config [ 'css_paths' ] ) . to eq [ '/app/spec/internal/public/test.css' ]
20
16
end
21
17
end
22
18
23
19
context 'when multiple css_paths are specified' do
24
20
let ( :config_file ) { file_fixture ( 'config/mutliple-css-paths.yml' ) . read }
25
21
26
- it 'sets css_path to empty string' do
27
- expect ( subject . config [ 'css_path' ] ) . to eq ''
28
- end
29
-
30
22
it 'leaves css_paths to an array of paths' do
31
23
expect ( subject . config [ 'css_paths' ] ) . to eq [ '/app/spec/internal/public/test.css' , '/app/spec/internal/public/test2.css' ]
32
24
end
35
27
context 'when no paths are specified' do
36
28
let ( :config_file ) { file_fixture ( 'config/no-paths-specified.yml' ) . read }
37
29
38
- it 'sets css_path with the path' do
39
- expect ( subject . config [ 'css_path' ] ) . to eq '/stylesheets/application.css'
40
- end
41
-
42
- it 'leaves css_paths empty' do
43
- expect ( subject . config [ 'css_paths' ] ) . to eq [ ]
30
+ it 'sets css_paths with the lone manifest path' do
31
+ expect ( subject . config [ 'css_paths' ] ) . to eq [ '/stylesheets/application.css' ]
44
32
end
45
33
end
46
34
You can’t perform that action at this time.
0 commit comments