Skip to content

Fix css paths #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ group :development, :test do
gem 'actionpack'
gem 'byebug', platform: [:ruby], require: false
gem 'rubocop', require: false
gem 'rspec-rails', '~> 3.6'
gem 'capybara', '~> 2.16'
gem 'rspec-rails', '~> 3.8'
gem 'capybara', '~> 3.14'
gem 'pry-rails'
end

Expand Down
2 changes: 1 addition & 1 deletion critical-path-css-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
gem.require_path = 'lib'

gem.add_development_dependency 'combustion', '~> 0.7.0'
gem.add_development_dependency 'combustion', '~> 1.1.0'

gem.extensions = ['ext/npm/extconf.rb']
end
5 changes: 4 additions & 1 deletion lib/critical_path_css/rails/config_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def format_css_paths
if config['css_path']
config['css_path'] = format_path(config['css_path'])
config['css_paths'] = []
else
elsif config['css_paths']
config['css_path'] = ''
config['css_paths'] = config['css_paths'].collect { |path| format_path(path) }
else
config['css_path'] = ActionController::Base.helpers.stylesheet_path(config['manifest_name'], host: '')
config['css_paths'] = []
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/critical_path_css/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module CriticalPathCSS
module Rails
VERSION = '3.0.0'.freeze
VERSION = '3.0.1'.freeze
end
end
26 changes: 26 additions & 0 deletions spec/lib/critical_path_css/rails/config_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,32 @@
end
end

context 'when no paths are specified' do
let(:config_file) {
<<~CONFIG
defaults: &defaults
base_url: http://0.0.0.0:9292
manifest_name: application
routes:
- /

development:
<<: *defaults

test:
<<: *defaults
CONFIG
}

it 'sets css_path with the path' do
expect(subject.config['css_path']).to eq '/stylesheets/application.css'
end

it 'leaves css_paths empty' do
expect(subject.config['css_paths']).to eq []
end
end

context 'when single css_path and multiple css_paths are both specified' do
let(:config_file) {
<<~CONFIG
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
require 'capybara/rails'

RSpec.configure do |config|
config.include Capybara::DSL

config.use_transactional_fixtures = true

# Enable flags like --only-failures and --next-failure
Expand Down