Remove default reliance on Sass and CSS generators (#43110)

* No benefit to having actiontext css as scss

* Update test

* Update docs

* No more css assets to be generated

New world, new CSS frameworks, new needs.

* SCSS is becoming optional

* Remove Sass as a default-on setting

But continue to make it easy to add.

* Update docs

* No longer used

* Update tests

* Update docs

* Update docs

* No longer used

* No longer by default

* Fix tests

* Promote Tailwind CSS as an alternative to Sass

* Fix test and copy task

* Update railties/lib/rails/generators/rails/app/templates/Gemfile.tt

Co-authored-by: Kevin Newton <kddnewton@gmail.com>

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
This commit is contained in:
David Heinemeier Hansson 2021-08-26 13:40:25 +02:00 committed by GitHub
parent af7428c4ac
commit d5b9618da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 58 additions and 408 deletions

View File

@ -13,7 +13,6 @@ gem "capybara", ">= 3.26"
gem "selenium-webdriver", ">= 4.0.0.alpha7"
gem "rack-cache", "~> 1.2"
gem "sass-rails"
gem "stimulus-rails"
gem "turbo-rails"
gem "webpacker", "~> 6.0.0.rc.5", require: ENV["SKIP_REQUIRE_WEBPACKER"] != "true"

View File

@ -422,16 +422,6 @@ GEM
rubyzip (2.3.0)
rufus-scheduler (3.7.0)
fugit (~> 1.1, >= 1.1.6)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
sdoc (2.2.0)
rdoc (>= 5.0)
selenium-webdriver (4.0.0.beta4)
@ -583,7 +573,6 @@ DEPENDENCIES
rubocop-packaging
rubocop-performance
rubocop-rails
sass-rails
sdoc (>= 2.2.0)
selenium-webdriver (>= 4.0.0.alpha7)
sequel

View File

@ -62,7 +62,7 @@ module ActionText
end
def create_actiontext_files
template "actiontext.scss", "app/assets/stylesheets/actiontext.scss"
template "actiontext.css", "app/assets/stylesheets/actiontext.css"
copy_file "#{GEM_ROOT}/app/views/active_storage/blobs/_blob.html.erb",
"app/views/active_storage/blobs/_blob.html.erb"

View File

@ -0,0 +1,35 @@
/*
* Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
* the trix-editor content (whether displayed or under editing). Feel free to incorporate this
* inclusion directly in any other asset bundle and remove this file.
*
<%- if defined?(Webpacker::Engine) -%>
*= require trix/dist/trix
<%- else -%>
*= require trix
<% end -%>
*/
/*
* We need to override trix.csss image gallery styles to accommodate the
* <action-text-attachment> element we wrap around attachments. Otherwise,
* images in galleries will be squished by the max-width: 33%; rule.
*/
.trix-content .attachment-gallery > action-text-attachment,
.trix-content .attachment-gallery > .attachment {
flex: 1 0 33%;
padding: 0 0.5em;
max-width: 33%;
}
.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
flex-basis: 50%;
max-width: 50%;
}
.trix-content action-text-attachment .attachment {
padding: 0 !important;
max-width: 100% !important;
}

View File

@ -1,40 +0,0 @@
//
// Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
// the trix-editor content (whether displayed or under editing). Feel free to incorporate this
// inclusion directly in any other asset bundle and remove this file.
//
<%- if defined?(Webpacker::Engine) -%>
//= require trix/dist/trix
<%- else -%>
//= require trix
<% end -%>
// We need to override trix.csss image gallery styles to accommodate the
// <action-text-attachment> element we wrap around attachments. Otherwise,
// images in galleries will be squished by the max-width: 33%; rule.
.trix-content {
.attachment-gallery {
> action-text-attachment,
> .attachment {
flex: 1 0 33%;
padding: 0 0.5em;
max-width: 33%;
}
&.attachment-gallery--2,
&.attachment-gallery--4 {
> action-text-attachment,
> .attachment {
flex-basis: 50%;
max-width: 50%;
}
}
}
action-text-attachment {
.attachment {
padding: 0 !important;
max-width: 100% !important;
}
}
}

View File

@ -49,9 +49,9 @@ Run `bin/rails action_text:install` to add the Yarn package and copy over the ne
NOTE: ActionText uses polymorphic relationships with the `action_text_rich_texts` table so that it can be shared with all models that have rich text attributes. If your models with ActionText content use UUID values for identifiers, all models that use ActionText attributes will need to use UUID values for their unique identifiers. The generated migration for ActionText will also need to be updated to specify `type: :uuid` for the `:record` `references` line.
After the installation is complete, a Rails app using Webpacker should have the following changes:
After the installation is complete, a Rails app should have the following changes:
1. Both `trix` and `@rails/actiontext` should be required in your JavaScript pack.
1. Both `trix` and `@rails/actiontext` should be required in your JavaScript entrypoint.
```js
// application.js
@ -59,18 +59,7 @@ After the installation is complete, a Rails app using Webpacker should have the
import "@rails/actiontext"
```
2. The `trix` stylesheet should be imported into `actiontext.scss`.
```scss
@import "trix/dist/trix";
```
Additionally, this `actiontext.scss` file should be imported into your stylesheet pack.
```scss
// application.scss
@import "./actiontext.scss";
```
2. The `trix` stylesheet will be included together with Action Text styles in your `application.css` file.
## Creating Rich Text content

View File

@ -33,24 +33,11 @@ passing the `--skip-sprockets` option.
$ rails new appname --skip-sprockets
```
Rails automatically adds the [`sass-rails`](https://github.com/rails/sass-rails)
gem to your `Gemfile`, which is used by Sprockets for
[Sass](https://sass-lang.com) compilation:
Rails can easily work with Sass by adding the [`sassc-rails`](https://github.com/sass/sassc-rails)
gem to your `Gemfile`, which is used by Sprockets for [Sass](https://sass-lang.com) compilation:
```ruby
gem 'sass-rails'
```
Using the `--skip-sprockets` option will prevent Rails from adding
this gem, so if you later want to enable the asset pipeline
you will have to add it to your `Gemfile` manually. Also,
creating an application with the `--skip-sprockets` option will generate
a slightly different `config/application.rb` file, with a require statement
for the sprockets railtie that is commented-out. You will have to remove
the comment operator on that line to later enable the asset pipeline:
```ruby
# require "sprockets/railtie"
gem 'sassc-rails'
```
To set asset compression methods, set the appropriate configuration options
@ -62,7 +49,7 @@ config.assets.css_compressor = :yui
config.assets.js_compressor = :uglifier
```
NOTE: The `sass-rails` gem is automatically used for CSS compression if included
NOTE: The `sassc-rails` gem is automatically used for CSS compression if included
in the `Gemfile` and no `config.assets.css_compressor` option is set.
### Main Features

View File

@ -210,9 +210,6 @@ $ bin/rails generate controller Greetings hello
invoke helper
create app/helpers/greetings_helper.rb
invoke test_unit
invoke assets
invoke scss
create app/assets/stylesheets/greetings.scss
```
What all did this generate? It made sure a bunch of directories were in our application, and created a controller file, a view file, a functional test file, a helper for the view, a JavaScript file, and a stylesheet file.
@ -302,11 +299,6 @@ $ bin/rails generate scaffold HighScore game:string score:integer
create app/views/high_scores/index.json.jbuilder
create app/views/high_scores/show.json.jbuilder
create app/views/high_scores/_high_score.json.jbuilder
invoke assets
invoke scss
create app/assets/stylesheets/high_scores.scss
invoke scss
create app/assets/stylesheets/scaffolds.scss
```
The generator checks that there exist the directories for models, controllers, helpers, layouts, functional and unit tests, stylesheets, creates the views, controller, model and database migration for HighScore (creating the `high_scores` table and fields), takes care of the route for the **resource**, and new tests for everything.

View File

@ -211,7 +211,6 @@ end
The full set of methods that can be used in this block are as follows:
* `assets` allows to create assets on generating a scaffold. Defaults to `true`.
* `force_plural` allows pluralized model names. Defaults to `false`.
* `helper` defines whether or not to generate helpers. Defaults to `true`.
* `integration_tool` defines which integration tool to use to generate integration tests. Defaults to `:test_unit`.
@ -221,9 +220,6 @@ The full set of methods that can be used in this block are as follows:
* `resource_route` defines whether a resource route definition should be generated
or not. Defaults to `true`.
* `scaffold_controller` different from `resource_controller`, defines which generator to use for generating a _scaffolded_ controller when using `bin/rails generate scaffold`. Defaults to `:scaffold_controller`.
* `stylesheets` turns on the hook for stylesheets in generators. Used in Rails for when the `scaffold` generator is run, but this hook can be used in other generates as well. Defaults to `true`.
* `stylesheet_engine` configures the stylesheet engine (for e.g. sass) to be used when generating assets. Defaults to `:css`.
* `scaffold_stylesheet` creates `scaffold.css` when generating a scaffolded resource. Defaults to `true`.
* `test_framework` defines which test framework to use. Defaults to `false` and will use minitest by default.
* `template_engine` defines which template engine to use, such as ERB or Haml. Defaults to `:erb`.

View File

@ -357,11 +357,6 @@ create test/system/blorgh/articles_test.rb
invoke helper
create app/helpers/blorgh/articles_helper.rb
invoke test_unit
invoke assets
invoke css
create app/assets/stylesheets/blorgh/articles.css
invoke css
create app/assets/stylesheets/scaffold.css
```
The first thing that the scaffold generator does is invoke the `active_record`
@ -427,8 +422,6 @@ end
This helps prevent conflicts with any other engine or application that may have
an article resource as well.
Finally, the assets for this resource are generated in one file: `app/assets/stylesheets/blorgh/articles.css`. You'll see how to use these a little later.
You can see what the engine has so far by running `bin/rails db:migrate` at the root
of our engine to run the migration generated by the scaffold generator, and then
running `bin/rails server` in `test/dummy`. When you open
@ -579,9 +572,6 @@ create test/controllers/blorgh/comments_controller_test.rb
invoke helper
create app/helpers/blorgh/comments_helper.rb
invoke test_unit
invoke assets
invoke css
create app/assets/stylesheets/blorgh/comments.css
```
The form will be making a `POST` request to `/articles/:article_id/comments`, which

View File

@ -204,23 +204,10 @@ $ bin/rails generate scaffold User name:string
invoke test_unit
create test/application_system_test_case.rb
create test/system/users_test.rb
invoke assets
invoke scss
create app/assets/stylesheets/users.scss
invoke scss
create app/assets/stylesheets/scaffolds.scss
```
Looking at this output, it's easy to understand how generators work in Rails 3.0 and above. The scaffold generator doesn't actually generate anything, it just invokes others to do the work. This allows us to add/replace/remove any of those invocations. For instance, the scaffold generator invokes the scaffold_controller generator, which invokes erb, test_unit and helper generators. Since each generator has a single responsibility, they are easy to reuse, avoiding code duplication.
If we want to avoid generating the default `app/assets/stylesheets/scaffolds.scss` file when scaffolding a new resource we can disable `scaffold_stylesheet`:
```ruby
config.generators do |g|
g.scaffold_stylesheet false
end
```
The next customization on the workflow will be to stop generating stylesheet and test fixture files for scaffolds altogether. We can achieve that by changing our configuration to the following:
```ruby
@ -228,7 +215,6 @@ config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework :test_unit, fixture: false
g.stylesheets false
end
```
@ -349,7 +335,6 @@ config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework :test_unit, fixture: false
g.stylesheets false
end
```
@ -383,7 +368,6 @@ config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework :shoulda, fixture: false
g.stylesheets false
# Add a fallback!
g.fallbacks[:shoulda] = :test_unit
@ -421,9 +405,6 @@ $ bin/rails generate scaffold Comment body:text
invoke test_unit
create test/application_system_test_case.rb
create test/system/comments_test.rb
invoke assets
invoke scss
create app/assets/stylesheets/scaffolds.scss
```
Fallbacks allow your generators to have a single responsibility, increasing code reuse and reducing the amount of duplication.

View File

@ -57,9 +57,6 @@ module Rails
resource_controller: :controller,
resource_route: true,
scaffold_controller: :scaffold_controller,
stylesheets: true,
stylesheet_engine: :css,
scaffold_stylesheet: true,
system_tests: nil,
test_framework: nil,
template_engine: :erb
@ -132,14 +129,12 @@ module Rails
# Returns an array of generator namespaces that are hidden.
# Generator namespaces may be hidden for a variety of reasons.
# Some are aliased such as "rails:migration" and can be
# invoked with the shorter "migration", others are private to other generators
# such as "css:scaffold".
# invoked with the shorter "migration".
def hidden_namespaces
@hidden_namespaces ||= begin
orm = options[:rails][:orm]
test = options[:rails][:test_framework]
template = options[:rails][:template_engine]
css = options[:rails][:stylesheet_engine]
[
"rails",
@ -158,10 +153,6 @@ module Rails
"#{template}:controller",
"#{template}:scaffold",
"#{template}:mailer",
"#{css}:scaffold",
"#{css}:assets",
"css:assets",
"css:scaffold",
"action_text:install",
"action_mailbox:install"
]

View File

@ -108,7 +108,6 @@ module Rails
[rails_gemfile_entry,
database_gemfile_entry,
web_server_gemfile_entry,
assets_gemfile_entry,
webpacker_gemfile_entry,
javascript_gemfile_entry,
jbuilder_gemfile_entry,
@ -307,12 +306,6 @@ module Rails
end
end
def assets_gemfile_entry
return [] if options[:skip_sprockets]
GemfileEntry.version("sass-rails", ">= 6", "Use SCSS for stylesheets")
end
def webpacker_gemfile_entry
if options[:webpack]
GemfileEntry.version "webpacker", "~> 6.0.0.rc.5", "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker"

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
require "rails/generators/named_base"
module Css # :nodoc:
module Generators # :nodoc:
class AssetsGenerator < Rails::Generators::NamedBase # :nodoc:
source_root File.expand_path("templates", __dir__)
def copy_stylesheet
copy_file "stylesheet.css", File.join("app/assets/stylesheets", class_path, "#{file_name}.css")
end
end
end
end

View File

@ -1,4 +0,0 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -1,18 +0,0 @@
# frozen_string_literal: true
require "rails/generators/named_base"
module Css # :nodoc:
module Generators # :nodoc:
class ScaffoldGenerator < Rails::Generators::NamedBase # :nodoc:
source_root Rails::Generators::ScaffoldGenerator.source_root
# In order to allow the Sass generators to pick up the default Rails CSS and
# transform it, we leave it in a standard location for the CSS stylesheet
# generators to handle. For the simple, default case, just copy it over.
def copy_stylesheet
copy_file "scaffold.css", "app/assets/stylesheets/scaffold.css"
end
end
end
end

View File

@ -17,6 +17,14 @@ ruby <%= "\"#{RUBY_VERSION}\"" -%>
"#{k}: #{v.inspect.gsub('"', '\'')}" }.join(", ") %>
<% end -%>
<% end -%>
<% unless options.skip_sprockets? %>
# Use Sass to process CSS
# gem "sassc-rails", "~> 2.1"
# Use Tailwind CSS. See: https://github.com/rails/tailwindcss-rails
# gem "tailwindcss-rails", "~> 0.4.3"
<% end -%>
# Use Active Model has_secure_password
# gem "bcrypt", "~> 3.1.7"

View File

@ -2,11 +2,11 @@
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* compiled file so the styles you add here take precedence over styles defined in any other CSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*

View File

@ -1,16 +0,0 @@
Description:
Generates new asset placeholders. Pass the asset name, either CamelCased
or under_scored.
To create an asset within a folder, specify the asset's name as a
path like 'parent/name'.
This generates a stylesheet stub in app/assets/stylesheets.
If Sass 3 is available, stylesheets will be generated with the .scss extension.
Example:
`bin/rails generate assets posts`
Posts assets.
Stylesheet: app/assets/stylesheets/posts.css

View File

@ -1,26 +0,0 @@
# frozen_string_literal: true
module Rails
module Generators
class AssetsGenerator < NamedBase # :nodoc:
class_option :javascripts, type: :boolean, desc: "Generate JavaScripts"
class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
class_option :javascript_engine, desc: "Engine for JavaScripts"
class_option :stylesheet_engine, desc: "Engine for Stylesheets"
private
def asset_name
file_name
end
hook_for :javascript_engine do |javascript_engine|
invoke javascript_engine, [name] if options[:javascripts]
end
hook_for :stylesheet_engine do |stylesheet_engine|
invoke stylesheet_engine, [name] if options[:stylesheets]
end
end
end
end

View File

@ -1,4 +0,0 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -6,7 +6,6 @@ module Rails
argument :actions, type: :array, default: [], banner: "action action"
class_option :skip_routes, type: :boolean, desc: "Don't add routes to config/routes.rb."
class_option :helper, type: :boolean
class_option :assets, type: :boolean
check_class_collision suffix: "Controller"
@ -21,7 +20,7 @@ module Rails
route routing_code, namespace: regular_class_path
end
hook_for :template_engine, :test_framework, :helper, :assets do |generator|
hook_for :template_engine, :test_framework, :helper do |generator|
invoke generator, [ remove_possible_suffix(name), actions ]
end

View File

@ -9,28 +9,9 @@ module Rails
remove_class_option :actions
class_option :api, type: :boolean
class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
class_option :stylesheet_engine, desc: "Engine for Stylesheets"
class_option :assets, type: :boolean
class_option :resource_route, type: :boolean
class_option :scaffold_stylesheet, type: :boolean
def handle_skip
@options = @options.merge(stylesheets: false) unless options[:assets]
@options = @options.merge(stylesheet_engine: false) unless options[:stylesheets] && options[:scaffold_stylesheet]
end
hook_for :scaffold_controller, required: true
hook_for :assets do |assets|
invoke assets, [controller_name]
end
hook_for :stylesheet_engine do |stylesheet_engine|
if behavior == :invoke
invoke stylesheet_engine, [controller_name]
end
end
end
end
end

View File

@ -1,47 +0,0 @@
div.field,
div.actions {
margin-bottom: 10px;
}
#notice {
color: green;
}
.scaffold_record {
border: 1px solid black;
padding: 10px;
margin-bottom: 10px;
}
.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px 7px 0;
margin-bottom: 20px;
background-color: #f0f0f0;
}
#error_explanation h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px -7px 0;
background-color: #c00;
color: #fff;
}
#error_explanation ul li {
font-size: 12px;
list-style: square;
}
label {
display: block;
}

View File

@ -22,7 +22,7 @@ namespace :app do
project_templates = "#{Rails.root}/lib/templates"
default_templates = { "erb" => %w{controller mailer scaffold},
"rails" => %w{controller helper scaffold_controller assets} }
"rails" => %w{controller helper scaffold_controller} }
default_templates.each do |type, names|
local_template_type_dir = File.join(project_templates, type)

View File

@ -305,7 +305,7 @@ module ApplicationTests
%w(controller mailer scaffold).each do |dir|
assert File.exist?(File.join(app_path, "lib", "templates", "erb", dir))
end
%w(controller helper scaffold_controller assets).each do |dir|
%w(controller helper scaffold_controller).each do |dir|
assert File.exist?(File.join(app_path, "lib", "templates", "rails", dir))
end
end

View File

@ -65,7 +65,7 @@ class ActionText::Generators::InstallGeneratorTest < Rails::Generators::TestCase
test "creates Action Text stylesheet" do
run_generator_instance
assert_file "app/assets/stylesheets/actiontext.scss"
assert_file "app/assets/stylesheets/actiontext.css"
end
test "creates Active Storage view partial" do

View File

@ -551,12 +551,6 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_gem "puma", '"~> 5.0"'
end
def test_generator_has_assets_gems
run_generator
assert_gem "sass-rails"
end
def test_action_cable_redis_gems
run_generator
assert_file "Gemfile", /^# gem "redis"/

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
require "generators/generators_test_helper"
require "rails/generators/rails/assets/assets_generator"
class AssetsGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments %w(posts)
def test_assets
run_generator
assert_file "app/assets/stylesheets/posts.css"
end
def test_skipping_assets
run_generator ["posts", "--no-stylesheets"]
assert_no_file "app/assets/stylesheets/posts.css"
end
end

View File

@ -37,16 +37,6 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/helpers/account_helper.rb"
end
def test_invokes_assets
run_generator
assert_file "app/assets/stylesheets/account.css"
end
def test_does_not_invoke_assets_if_required
run_generator ["account", "--skip-assets"]
assert_no_file "app/assets/stylesheets/account.css"
end
def test_invokes_default_test_framework
run_generator
assert_file "test/controllers/account_controller_test.rb"
@ -136,8 +126,5 @@ class ControllerGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/helpers/account_controller_helper.rb"
assert_file "app/helpers/account_helper.rb"
assert_no_file "app/assets/stylesheets/account_controller.css"
assert_file "app/assets/stylesheets/account.css"
end
end

View File

@ -227,9 +227,6 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
# Helpers
assert_file "app/helpers/test_app/product_lines_helper.rb"
# Stylesheets
assert_file "app/assets/stylesheets/scaffold.css"
end
def test_scaffold_on_revoke
@ -257,9 +254,6 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
# Helpers
assert_no_file "app/helpers/test_app/product_lines_helper.rb"
# Stylesheets (should not be removed)
assert_file "app/assets/stylesheets/scaffold.css"
end
def test_scaffold_with_namespace_on_invoke
@ -293,9 +287,6 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
# Helpers
assert_file "app/helpers/test_app/admin/roles_helper.rb"
# Stylesheets
assert_file "app/assets/stylesheets/scaffold.css"
end
def test_scaffold_with_namespace_on_revoke
@ -324,9 +315,6 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
# Helpers
assert_no_file "app/helpers/test_app/admin/roles_helper.rb"
# Stylesheets (should not be removed)
assert_file "app/assets/stylesheets/scaffold.css"
end
def test_scaffold_with_nested_namespace_on_invoke
@ -360,9 +348,6 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
# Helpers
assert_file "app/helpers/test_app/admin/user/special/roles_helper.rb"
# Stylesheets
assert_file "app/assets/stylesheets/scaffold.css"
end
def test_scaffold_with_nested_namespace_on_revoke
@ -390,9 +375,6 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
# Helpers
assert_no_file "app/helpers/test_app/admin/user/special/roles_helper.rb"
# Stylesheets (should not be removed)
assert_file "app/assets/stylesheets/scaffold.css"
end
def test_api_scaffold_with_namespace_on_invoke

View File

@ -92,10 +92,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
# Helpers
assert_file "app/helpers/product_lines_helper.rb"
# Assets
assert_file "app/assets/stylesheets/scaffold.css"
assert_file "app/assets/stylesheets/product_lines.css"
end
def test_api_scaffold_on_invoke
@ -164,10 +160,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
# Helpers
assert_no_file "app/helpers/product_lines_helper.rb"
# Assets
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_no_file "app/assets/stylesheets/product_lines.css"
end
def test_functional_tests_without_attributes
@ -219,10 +211,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
# Helpers
assert_no_file "app/helpers/product_lines_helper.rb"
# Assets
assert_file "app/assets/stylesheets/scaffold.css", /.scaffold_record/
assert_no_file "app/assets/stylesheets/product_lines.css"
end
def test_scaffold_with_namespace_on_invoke
@ -292,10 +280,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
# Helpers
assert_file "app/helpers/admin/roles_helper.rb"
# Assets
assert_file "app/assets/stylesheets/scaffold.css", /.scaffold_record/
assert_file "app/assets/stylesheets/admin/roles.css"
end
def test_scaffold_with_namespace_on_revoke
@ -327,10 +311,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
# Helpers
assert_no_file "app/helpers/admin/roles_helper.rb"
# Assets
assert_file "app/assets/stylesheets/scaffold.css"
assert_no_file "app/assets/stylesheets/admin/roles.css"
end
def test_scaffold_generator_on_revoke_does_not_mutilate_legacy_map_parameter
@ -371,30 +351,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_file "config/routes.rb", /\.routes\.draw do\n resources :products\n/
end
def test_scaffold_generator_no_assets_with_switch_no_assets
run_generator [ "posts", "--no-assets" ]
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_no_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_no_assets_with_switch_assets_false
run_generator [ "posts", "--assets=false" ]
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_no_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_no_scaffold_stylesheet_with_switch_no_scaffold_stylesheet
run_generator [ "posts", "--no-scaffold-stylesheet" ]
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_no_scaffold_stylesheet_with_switch_scaffold_stylesheet_false
run_generator [ "posts", "--scaffold-stylesheet=false" ]
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_with_switch_resource_route_false
run_generator [ "posts", "--resource-route=false" ]
assert_file "config/routes.rb" do |route|
@ -416,12 +372,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/helpers/posts_helper.rb"
end
def test_scaffold_generator_no_stylesheets
run_generator [ "posts", "--no-stylesheets" ]
assert_no_file "app/assets/stylesheets/scaffold.css"
assert_no_file "app/assets/stylesheets/posts.css"
end
def test_scaffold_generator_outputs_error_message_on_missing_attribute_type
run_generator ["post", "title", "body:text", "author"]
@ -683,8 +633,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert File.exist?("app/views/bukkits/users/_form.html.erb")
assert File.exist?("app/helpers/bukkits/users_helper.rb")
assert File.exist?("app/assets/stylesheets/bukkits/users.css")
end
end
@ -712,8 +660,6 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
assert_not File.exist?("app/views/bukkits/users/_form.html.erb")
assert_not File.exist?("app/helpers/bukkits/users_helper.rb")
assert_not File.exist?("app/assets/stylesheets/bukkits/users.css")
end
end
end