Skip to content

Commit c5ebdc1

Browse files
Merge pull request #39 from mudbugmedia/fix-css-paths
Fix css paths
2 parents ce4c3a2 + d9205e8 commit c5ebdc1

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ group :development, :test do
66
gem 'actionpack'
77
gem 'byebug', platform: [:ruby], require: false
88
gem 'rubocop', require: false
9-
gem 'rspec-rails', '~> 3.6'
10-
gem 'capybara', '~> 2.16'
9+
gem 'rspec-rails', '~> 3.8'
10+
gem 'capybara', '~> 3.14'
1111
gem 'pry-rails'
1212
end
1313

critical-path-css-rails.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
1414
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
1515
gem.require_path = 'lib'
1616

17-
gem.add_development_dependency 'combustion', '~> 0.7.0'
17+
gem.add_development_dependency 'combustion', '~> 1.1.0'
1818

1919
gem.extensions = ['ext/npm/extconf.rb']
2020
end

lib/critical_path_css/rails/config_loader.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ def format_css_paths
2222
if config['css_path']
2323
config['css_path'] = format_path(config['css_path'])
2424
config['css_paths'] = []
25-
else
25+
elsif config['css_paths']
2626
config['css_path'] = ''
2727
config['css_paths'] = config['css_paths'].collect { |path| format_path(path) }
28+
else
29+
config['css_path'] = ActionController::Base.helpers.stylesheet_path(config['manifest_name'], host: '')
30+
config['css_paths'] = []
2831
end
2932
end
3033

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module CriticalPathCSS
22
module Rails
3-
VERSION = '3.0.0'.freeze
3+
VERSION = '3.0.1'.freeze
44
end
55
end

spec/lib/critical_path_css/rails/config_loader_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,32 @@
6363
end
6464
end
6565

66+
context 'when no paths are specified' do
67+
let(:config_file) {
68+
<<~CONFIG
69+
defaults: &defaults
70+
base_url: http://0.0.0.0:9292
71+
manifest_name: application
72+
routes:
73+
- /
74+
75+
development:
76+
<<: *defaults
77+
78+
test:
79+
<<: *defaults
80+
CONFIG
81+
}
82+
83+
it 'sets css_path with the path' do
84+
expect(subject.config['css_path']).to eq '/stylesheets/application.css'
85+
end
86+
87+
it 'leaves css_paths empty' do
88+
expect(subject.config['css_paths']).to eq []
89+
end
90+
end
91+
6692
context 'when single css_path and multiple css_paths are both specified' do
6793
let(:config_file) {
6894
<<~CONFIG

spec/spec_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
require 'capybara/rails'
1111

1212
RSpec.configure do |config|
13+
config.include Capybara::DSL
14+
1315
config.use_transactional_fixtures = true
1416

1517
# Enable flags like --only-failures and --next-failure

0 commit comments

Comments
 (0)