Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Corrected Stylesheet Path for Rails 4 #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 features/nifty_layout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Feature: Nifty Layout Generator
Then I should see "h(page_title" in file "app/helpers/layout_helper.rb"
And I should see file "app/helpers/layout_helper.rb"
And I should see file "app/helpers/error_messages_helper.rb"
And I should see file "public/stylesheets/application.css"
And I should see file "app/assets/stylesheets/application.css"

Scenario: Generate named layout with haml and sass
Given a new Rails app
When I run "rails g nifty:layout FooBar --haml -f"
Then I should see "stylesheet_link_tag "foo_bar"" in file "app/views/layouts/foo_bar.html.haml"
And I should see file "public/stylesheets/sass/foo_bar.sass"
And I should see file "app/assets/stylesheets/sass/foo_bar.sass"
And I should see file "app/helpers/layout_helper.rb"
4 changes: 2 additions & 2 deletions lib/generators/nifty/layout/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Examples:
rails generate nifty:layout

Layout: app/views/layouts/application.html.erb
Stylesheet: public/stylesheets/application.css
Stylesheet: app/assets/stylesheets/application.css
Helper: app/helpers/layout_helper.rb


rails generate nifty:layout admin

Layout: app/views/layouts/admin.html.erb
Stylesheet: public/stylesheets/admin.css
Stylesheet: app/assets/stylesheets/admin.css
Helper: app/helpers/layout_helper.rb
4 changes: 2 additions & 2 deletions lib/generators/nifty/layout/layout_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class LayoutGenerator < Base
def create_layout
if options.haml?
template 'layout.html.haml', "app/views/layouts/#{file_name}.html.haml"
copy_file 'stylesheet.sass', "public/stylesheets/sass/#{file_name}.sass"
copy_file 'stylesheet.sass', "app/assets/stylesheets/sass/#{file_name}.sass"
else
template 'layout.html.erb', "app/views/layouts/#{file_name}.html.erb"
copy_file 'stylesheet.css', "public/stylesheets/#{file_name}.css"
copy_file 'stylesheet.css', "app/assets/stylesheets/#{file_name}.css"
end
copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb'
copy_file 'error_messages_helper.rb', 'app/helpers/error_messages_helper.rb'
Expand Down
4 changes: 2 additions & 2 deletions rails_generators/nifty_layout/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Examples:
script/generate nifty_layout

Layout: app/views/layouts/application.html.erb
Stylesheet: public/stylesheets/application.css
Stylesheet: app/assets/stylesheets/application.css
Helper: app/helpers/layout_helper.rb


script/generate nifty_layout admin

Layout: app/views/layouts/admin.html.erb
Stylesheet: public/stylesheets/admin.css
Stylesheet: app/assets/stylesheets/admin.css
Helper: app/helpers/layout_helper.rb
8 changes: 4 additions & 4 deletions rails_generators/nifty_layout/nifty_layout_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ def initialize(runtime_args, runtime_options = {})
def manifest
record do |m|
m.directory 'app/views/layouts'
m.directory 'public/stylesheets'
m.directory 'app/assets/stylesheets'
m.directory 'app/helpers'

if options[:haml]
m.directory 'public/stylesheets/sass'
m.directory 'app/assets/stylesheets'
m.template "layout.html.haml", "app/views/layouts/#{file_name}.html.haml"
m.file "stylesheet.sass", "public/stylesheets/sass/#{file_name}.sass"
m.file "stylesheet.sass", "app/assets/stylesheets/sass/#{file_name}.sass"
else
m.template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
m.file "stylesheet.css", "public/stylesheets/#{file_name}.css"
m.file "stylesheet.css", "app/assets/stylesheets/#{file_name}.css"
end
m.file "helper.rb", "app/helpers/layout_helper.rb"
end
Expand Down
4 changes: 2 additions & 2 deletions test/test_nifty_layout_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestNiftyLayoutGenerator < Test::Unit::TestCase
context "generator with name" do
rails_generator :nifty_layout, "foobar"
should_generate_file 'app/views/layouts/foobar.html.erb'
should_generate_file 'public/stylesheets/foobar.css'
should_generate_file 'app/assets/stylesheets/foobar.css'
should_generate_file 'app/helpers/layout_helper.rb'
end

Expand All @@ -37,6 +37,6 @@ class TestNiftyLayoutGenerator < Test::Unit::TestCase
context "generator with haml option" do
rails_generator :nifty_layout, "foobar", :haml => true
should_generate_file 'app/views/layouts/foobar.html.haml'
should_generate_file 'public/stylesheets/sass/foobar.sass'
should_generate_file 'app/assets/stylesheets/sass/foobar.sass'
end
end