From c4a11171da2e56a46d7c2e1ee3ba82cca9a72a5f Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com> Date: Wed, 5 Apr 2017 18:01:34 +0900 Subject: Use appropriate type to `header` option The `header` option checks only whether it is specified or not. https://github.com/rails/rails/blob/e8c33349bfabca28996ac74d344d69c7aaffec50/railties/lib/rails/commands/dbconsole/dbconsole_command.rb#L52 --- railties/lib/rails/commands/dbconsole/dbconsole_command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb index 588fb06b15..5bfbe58d97 100644 --- a/railties/lib/rails/commands/dbconsole/dbconsole_command.rb +++ b/railties/lib/rails/commands/dbconsole/dbconsole_command.rb @@ -140,7 +140,7 @@ module Rails class_option :mode, enum: %w( html list line column ), type: :string, desc: "Automatically put the sqlite3 database in the specified mode (html, list, line, column)." - class_option :header, type: :string + class_option :header, type: :boolean class_option :environment, aliases: "-e", type: :string, desc: "Specifies the environment to run this console under (test/development/production)." -- cgit v1.2.3 From a31584692304cebd06f6530ce0347ef8075e46e1 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono <kamipo@gmail.com> Date: Fri, 7 Apr 2017 08:40:52 +0900 Subject: Remove duplicated "test" prefix --- railties/test/application/rake/migrations_test.rb | 6 +++--- railties/test/application/test_runner_test.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 00f6620188..449d281967 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -77,7 +77,7 @@ module ApplicationTests assert_equal "Schema migrations table does not exist yet.\n", output end - test "test migration status" do + test "migration status" do Dir.chdir(app_path) do `bin/rails generate model user username:string password:string; bin/rails generate migration add_email_to_users email:string; @@ -117,7 +117,7 @@ module ApplicationTests end end - test "test migration status after rollback and redo" do + test "migration status after rollback and redo" do Dir.chdir(app_path) do `bin/rails generate model user username:string password:string; bin/rails generate migration add_email_to_users email:string; @@ -224,7 +224,7 @@ module ApplicationTests end end - test "test migration status migrated file is deleted" do + test "migration status migrated file is deleted" do Dir.chdir(app_path) do `bin/rails generate model user username:string password:string; bin/rails generate migration add_email_to_users email:string; diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb index a8e3a7ec5b..23b259b503 100644 --- a/railties/test/application/test_runner_test.rb +++ b/railties/test/application/test_runner_test.rb @@ -323,7 +323,7 @@ module ApplicationTests assert true end - test "test line filter does not run this" do + test "line filter does not run this" do assert true end end -- cgit v1.2.3 From c597c3eb934454c1f4459c24b9462bb962403bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Fran=C3=A7a?= <rafaelmfranca@gmail.com> Date: Fri, 7 Apr 2017 13:51:30 -0400 Subject: :scissors: --- .../rails/app/templates/app/assets/stylesheets/application.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css b/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css index 865300bef9..d05ea0f511 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css @@ -2,7 +2,7 @@ * 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 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 -- cgit v1.2.3 From 866fc6a4e24c3807637be0ce34aec06da8025618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= <rafaelmfranca@gmail.com> Date: Fri, 7 Apr 2017 13:54:30 -0400 Subject: More :scissors: --- railties/lib/rails/generators/rails/app/templates/bin/setup.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/bin/setup.tt b/railties/lib/rails/generators/rails/app/templates/bin/setup.tt index c6607dbb2b..52b3de5ee5 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/setup.tt +++ b/railties/lib/rails/generators/rails/app/templates/bin/setup.tt @@ -19,9 +19,9 @@ chdir APP_ROOT do <% unless options[:skip_yarn] %> # Install JavaScript dependencies if using Yarn # system('bin/yarn') - <% end %> <% unless options.skip_active_record -%> + # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # cp 'config/database.yml.sample', 'config/database.yml' -- cgit v1.2.3 From 8f0d8551893789f26e5d6b82ccef00779296818f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= <rafaelmfranca@gmail.com> Date: Fri, 7 Apr 2017 13:55:54 -0400 Subject: Spaces --- railties/lib/rails/generators/rails/app/templates/bin/update.tt | 1 + 1 file changed, 1 insertion(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/bin/update.tt b/railties/lib/rails/generators/rails/app/templates/bin/update.tt index d23af018c7..d385b363c6 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/update.tt +++ b/railties/lib/rails/generators/rails/app/templates/bin/update.tt @@ -17,6 +17,7 @@ chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') <% unless options.skip_active_record -%> + puts "\n== Updating database ==" system! 'bin/rails db:migrate' <% end -%> -- cgit v1.2.3 From fb9e846be9a1e1a907c84f5d0336bec56fe2a5bc Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com> Date: Wed, 12 Apr 2017 07:41:59 +0900 Subject: Fix rubocop violations --- railties/lib/rails/generators/named_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 46001f306a..aef66adb64 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -150,7 +150,7 @@ module Rails end def field_id(attribute_name) - [singular_table_name, attribute_name].join('_') + [singular_table_name, attribute_name].join("_") end def singular_table_name # :doc: -- cgit v1.2.3 From a6d907e5880e15c641fc457f7e96187fe1e8509d Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com> Date: Sun, 9 Apr 2017 10:48:56 +0900 Subject: Don't generate system test files if `skip_system_test` option is specified --- .../generators/rails/app/templates/config/application.rb | 4 ++++ railties/test/generators/app_generator_test.rb | 11 +++++++++++ 2 files changed, 15 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index d5d214052f..0b1d22228e 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -34,6 +34,10 @@ module <%= app_const_base %> # Middleware like session, flash, cookies can be added back manually. # Skip views, helpers and assets when generating a new resource. config.api_only = true +<%- elsif !depends_on_system_test? -%> + + # Don't generate system test files. + config.generators.system_tests = nil <%- end -%> end end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 7965bd68d0..0016714383 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -452,6 +452,17 @@ class AppGeneratorTest < Rails::Generators::TestCase end end + def test_does_not_generate_system_test_files_if_skip_system_test_is_given + run_generator [destination_root, "--skip_system_test"] + + Dir.chdir(destination_root) do + quietly { `./bin/rails g scaffold User` } + + assert_no_file("test/application_system_test_case.rb") + assert_no_file("test/system/users_test.rb") + end + end + def test_generator_if_api_is_given run_generator [destination_root, "--api"] assert_file "Gemfile" do |content| -- cgit v1.2.3 From c26452b2321b49300e5a5d880f1c14a398662365 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com> Date: Thu, 13 Apr 2017 07:57:45 +0900 Subject: Make code statistics task handle system tests properly If it is not added to `TEST_TYPES`, it is not regarded as a test when counting the total count. --- railties/lib/rails/code_statistics.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb index 9c4bd16aad..70dce268f1 100644 --- a/railties/lib/rails/code_statistics.rb +++ b/railties/lib/rails/code_statistics.rb @@ -7,7 +7,8 @@ class CodeStatistics #:nodoc: "Model tests", "Mailer tests", "Job tests", - "Integration tests"] + "Integration tests", + "System tests"] HEADERS = { lines: " Lines", code_lines: " LOC", classes: "Classes", methods: "Methods" } -- cgit v1.2.3 From 827bfe4f41c39eade078e26ad5653979891d89c7 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com> Date: Sat, 1 Apr 2017 13:22:25 +0900 Subject: Use the config value directly when call `secrets` Currently, `read_encrypted_secrets` is set with initializer. Therefore if refer to `secrets` in config, `read_encrypted_secrets` is false, so can not get the value of `secrets.yml.enc`. In order to be able to refer to secrets in config, modified to refer to `config.read_encrypted_secrets` when calling `secrets`. Fixes #28618. --- railties/lib/rails/application.rb | 4 +++- railties/lib/rails/application/bootstrap.rb | 1 - railties/lib/rails/secrets.rb | 10 ++------- railties/test/secrets_test.rb | 34 ++++++++++++++++++++++------- 4 files changed, 31 insertions(+), 18 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 89f7b5991f..f8a923141d 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -386,7 +386,9 @@ module Rails def secrets @secrets ||= begin secrets = ActiveSupport::OrderedOptions.new - secrets.merge! Rails::Secrets.parse(config.paths["config/secrets"].existent, env: Rails.env) + files = config.paths["config/secrets"].existent + files = files.reject { |path| path.end_with?(".enc") } unless config.read_encrypted_secrets + secrets.merge! Rails::Secrets.parse(files, env: Rails.env) # Fallback to config.secret_key_base if secrets.secret_key_base isn't set secrets.secret_key_base ||= config.secret_key_base diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index 4223c38146..dc0491035d 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -81,7 +81,6 @@ INFO initializer :set_secrets_root, group: :all do Rails::Secrets.root = root - Rails::Secrets.read_encrypted_secrets = config.read_encrypted_secrets end end end diff --git a/railties/lib/rails/secrets.rb b/railties/lib/rails/secrets.rb index 2a95712cd9..8b644f212c 100644 --- a/railties/lib/rails/secrets.rb +++ b/railties/lib/rails/secrets.rb @@ -14,12 +14,10 @@ module Rails end @cipher = "aes-128-gcm" - @read_encrypted_secrets = false @root = File # Wonky, but ensures `join` uses the current directory. class << self - attr_writer :root - attr_accessor :read_encrypted_secrets + attr_writer :root def parse(paths, env:) paths.each_with_object(Hash.new) do |path, all_secrets| @@ -88,11 +86,7 @@ module Rails def preprocess(path) if path.end_with?(".enc") - if @read_encrypted_secrets - decrypt(IO.binread(path)) - else - "" - end + decrypt(IO.binread(path)) else IO.read(path) end diff --git a/railties/test/secrets_test.rb b/railties/test/secrets_test.rb index 953408f0b4..73b6cb7a66 100644 --- a/railties/test/secrets_test.rb +++ b/railties/test/secrets_test.rb @@ -9,22 +9,22 @@ class Rails::SecretsTest < ActiveSupport::TestCase def setup build_app - - @old_read_encrypted_secrets, Rails::Secrets.read_encrypted_secrets = - Rails::Secrets.read_encrypted_secrets, true end def teardown - Rails::Secrets.read_encrypted_secrets = @old_read_encrypted_secrets - teardown_app end test "setting read to false skips parsing" do - Rails::Secrets.read_encrypted_secrets = false + run_secrets_generator do + Rails::Secrets.write(<<-end_of_secrets) + test: + yeah_yeah: lets-walk-in-the-cool-evening-light + end_of_secrets - Dir.chdir(app_path) do - assert_equal Hash.new, Rails::Secrets.parse(%w( config/secrets.yml.enc ), env: "production") + Rails.application.config.read_encrypted_secrets = false + Rails.application.instance_variable_set(:@secrets, nil) # Dance around caching 💃🕺 + assert_not Rails.application.secrets.yeah_yeah end end @@ -90,11 +90,29 @@ class Rails::SecretsTest < ActiveSupport::TestCase end_of_secrets Rails.application.config.root = app_path + Rails.application.config.read_encrypted_secrets = true Rails.application.instance_variable_set(:@secrets, nil) # Dance around caching 💃🕺 assert_equal "lets-walk-in-the-cool-evening-light", Rails.application.secrets.yeah_yeah end end + test "refer secrets inside env config" do + run_secrets_generator do + Rails::Secrets.write(<<-end_of_yaml) + production: + some_secret: yeah yeah + end_of_yaml + + add_to_env_config "production", <<-end_of_config + config.dereferenced_secret = Rails.application.secrets.some_secret + end_of_config + + Dir.chdir(app_path) do + assert_equal "yeah yeah\n", `bin/rails runner -e production "puts Rails.application.config.dereferenced_secret"` + end + end + end + private def run_secrets_generator Dir.chdir(app_path) do -- cgit v1.2.3 From fadb50ef0fc11b55dbd561a26c43569dde17d463 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen <kaspth@gmail.com> Date: Sun, 16 Apr 2017 16:22:34 +0200 Subject: Let run_secrets_generator handle chdir. --- railties/test/secrets_test.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/test/secrets_test.rb b/railties/test/secrets_test.rb index 73b6cb7a66..36c8ef1fd9 100644 --- a/railties/test/secrets_test.rb +++ b/railties/test/secrets_test.rb @@ -107,9 +107,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase config.dereferenced_secret = Rails.application.secrets.some_secret end_of_config - Dir.chdir(app_path) do - assert_equal "yeah yeah\n", `bin/rails runner -e production "puts Rails.application.config.dereferenced_secret"` - end + assert_equal "yeah yeah\n", `bin/rails runner -e production "puts Rails.application.config.dereferenced_secret"` end end -- cgit v1.2.3 From a4c1282854795d1f0d7696ce1ccbabf94b3d9098 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen <kaspth@gmail.com> Date: Thu, 23 Mar 2017 21:57:42 +0100 Subject: Add `form_with_generates_remote_forms` config. Allows users to not have remote forms by default, since there's more JS harness, e.g. bundling rails-ujs, otherwise. Also don't skip creating defaults file anymore. Sprockets isn't the only new config. --- railties/lib/rails/generators/rails/app/app_generator.rb | 4 +--- .../templates/config/initializers/new_framework_defaults_5_1.rb.tt | 3 +++ railties/test/generators/app_generator_test.rb | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 324843a5f5..f4717bb35b 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -403,9 +403,7 @@ module Rails end def delete_new_framework_defaults - # Sprockets owns the only new default for 5.1: if it's disabled, - # we don't want the file. - unless options[:update] && !options[:skip_sprockets] + unless options[:update] remove_file "config/initializers/new_framework_defaults_5_1.rb" end end diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt index 5f5545c4c7..a0c7f44b60 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt @@ -5,6 +5,9 @@ # Once upgraded flip defaults one by one to migrate to the new default. # # Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make `form_with` generate non-remote forms. +Rails.application.config.action_view.form_with_generates_remote_forms = false <%- unless options[:skip_sprockets] -%> # Unknown asset fallback will return the path passed in when the given diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 7965bd68d0..d3e131db94 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -410,7 +410,6 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_no_match(/config\.assets\.js_compressor = :uglifier/, content) assert_no_match(/config\.assets\.css_compressor = :sass/, content) end - assert_no_file "config/initializers/new_framework_defaults_5_1.rb" end def test_generator_if_skip_yarn_is_given -- cgit v1.2.3 From b77d2aa0c336492ba33cbfade4964ba0eda3ef84 Mon Sep 17 00:00:00 2001 From: bogdanvlviv <bogdanvlviv@gmail.com> Date: Sat, 25 Feb 2017 17:49:32 +0200 Subject: Fix `bin/rails db:forward` first migration --- railties/test/application/rake/migrations_test.rb | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'railties') diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 449d281967..451045f08b 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -142,6 +142,31 @@ module ApplicationTests end end + test "migration status after rollback and forward" do + Dir.chdir(app_path) do + `bin/rails generate model user username:string password:string; + bin/rails generate migration add_email_to_users email:string; + bin/rails db:migrate` + + output = `bin/rails db:migrate:status` + + assert_match(/up\s+\d{14}\s+Create users/, output) + assert_match(/up\s+\d{14}\s+Add email to users/, output) + + `bin/rails db:rollback STEP=2` + output = `bin/rails db:migrate:status` + + assert_match(/down\s+\d{14}\s+Create users/, output) + assert_match(/down\s+\d{14}\s+Add email to users/, output) + + `bin/rails db:forward STEP=2` + output = `bin/rails db:migrate:status` + + assert_match(/up\s+\d{14}\s+Create users/, output) + assert_match(/up\s+\d{14}\s+Add email to users/, output) + end + end + test "migration status after rollback and redo without timestamps" do add_to_config("config.active_record.timestamped_migrations = false") -- cgit v1.2.3 From bb9d6eb094f29bb94ef1f26aa44f145f17b973fe Mon Sep 17 00:00:00 2001 From: bogdanvlviv <bogdanvlviv@gmail.com> Date: Sat, 25 Feb 2017 19:32:50 +0200 Subject: Add additional raise UnknownMigrationVersionError Raise error on the movement of migrations when the current migration does not exist. --- railties/test/application/rake/migrations_test.rb | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/test/application/rake/migrations_test.rb b/railties/test/application/rake/migrations_test.rb index 451045f08b..2c9770e147 100644 --- a/railties/test/application/rake/migrations_test.rb +++ b/railties/test/application/rake/migrations_test.rb @@ -167,6 +167,37 @@ module ApplicationTests end end + test "raise error on any move when current migration does not exist" do + Dir.chdir(app_path) do + `bin/rails generate model user username:string password:string; + bin/rails generate migration add_email_to_users email:string; + bin/rails db:migrate + rm db/migrate/*email*.rb` + + output = `bin/rails db:migrate:status` + assert_match(/up\s+\d{14}\s+Create users/, output) + assert_match(/up\s+\d{14}\s+\** NO FILE \**/, output) + + output = `bin/rails db:rollback 2>&1` + assert_match(/rails aborted!/, output) + assert_match(/ActiveRecord::UnknownMigrationVersionError:/, output) + assert_match(/No migration with version number\s\d{14}\./, output) + + output = `bin/rails db:migrate:status` + assert_match(/up\s+\d{14}\s+Create users/, output) + assert_match(/up\s+\d{14}\s+\** NO FILE \**/, output) + + output = `bin/rails db:forward 2>&1` + assert_match(/rails aborted!/, output) + assert_match(/ActiveRecord::UnknownMigrationVersionError:/, output) + assert_match(/No migration with version number\s\d{14}\./, output) + + output = `bin/rails db:migrate:status` + assert_match(/up\s+\d{14}\s+Create users/, output) + assert_match(/up\s+\d{14}\s+\** NO FILE \**/, output) + end + end + test "migration status after rollback and redo without timestamps" do add_to_config("config.active_record.timestamped_migrations = false") @@ -257,7 +288,6 @@ module ApplicationTests rm db/migrate/*email*.rb` output = `bin/rails db:migrate:status` - File.write("test.txt", output) assert_match(/up\s+\d{14}\s+Create users/, output) assert_match(/up\s+\d{14}\s+\** NO FILE \**/, output) -- cgit v1.2.3 From d862cb89837d78f2c0f59caa9541383c6a0314b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= <rafaelmfranca@gmail.com> Date: Wed, 19 Apr 2017 19:55:06 -0400 Subject: Use released sass-rails instead of master version --- railties/lib/rails/generators/app_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 9109be5e04..c715e5ac9f 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -304,7 +304,7 @@ module Rails return [] if options[:skip_sprockets] gems = [] - gems << GemfileEntry.github("sass-rails", "rails/sass-rails", nil, + gems << GemfileEntry.version("sass-rails", "~> 5.0", "Use SCSS for stylesheets") if !options[:skip_javascript] -- cgit v1.2.3 From df641263badb79df571955874e6510ae8dedd399 Mon Sep 17 00:00:00 2001 From: Jan Krutisch <jan@krutisch.de> Date: Thu, 20 Apr 2017 17:56:24 +0200 Subject: Namespace CSS selectors on error pages The css selectors on the generated error pages are too broad (for example `text-align: center` on `body` and thus bleed out to the following pages (say, by pressing the back button) when using Turbolinks. This commit namespaces all the selectors. --- railties/CHANGELOG.md | 7 +++++++ .../lib/rails/generators/rails/app/templates/public/404.html | 12 ++++++------ .../lib/rails/generators/rails/app/templates/public/422.html | 12 ++++++------ .../lib/rails/generators/rails/app/templates/public/500.html | 12 ++++++------ 4 files changed, 25 insertions(+), 18 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 6032d2e1a1..5463b05b60 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1 +1,8 @@ +* Namespace error pages' CSS selectors to stop the styles from bleeding into other pages + when using Turbolinks. + + *Jan Krutisch* + + + Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/railties/CHANGELOG.md) for previous changes. diff --git a/railties/lib/rails/generators/rails/app/templates/public/404.html b/railties/lib/rails/generators/rails/app/templates/public/404.html index b612547fc2..2be3af26fc 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/404.html +++ b/railties/lib/rails/generators/rails/app/templates/public/404.html @@ -4,7 +4,7 @@ <title>The page you were looking for doesn't exist (404)</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> - body { + .rails-default-error-page { background-color: #EFEFEF; color: #2E2F30; text-align: center; @@ -12,13 +12,13 @@ margin: 0; } - div.dialog { + .rails-default-error-page div.dialog { width: 95%; max-width: 33em; margin: 4em auto 0; } - div.dialog > div { + .rails-default-error-page div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; @@ -31,13 +31,13 @@ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } - h1 { + .rails-default-error-page h1 { font-size: 100%; color: #730E15; line-height: 1.5em; } - div.dialog > p { + .rails-default-error-page div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; @@ -54,7 +54,7 @@ </style> </head> -<body> +<body class="rails-default-error-page"> <!-- This file lives in public/404.html --> <div class="dialog"> <div> diff --git a/railties/lib/rails/generators/rails/app/templates/public/422.html b/railties/lib/rails/generators/rails/app/templates/public/422.html index a21f82b3bd..c08eac0d1d 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/422.html +++ b/railties/lib/rails/generators/rails/app/templates/public/422.html @@ -4,7 +4,7 @@ <title>The change you wanted was rejected (422)</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> - body { + .rails-default-error-page { background-color: #EFEFEF; color: #2E2F30; text-align: center; @@ -12,13 +12,13 @@ margin: 0; } - div.dialog { + .rails-default-error-page div.dialog { width: 95%; max-width: 33em; margin: 4em auto 0; } - div.dialog > div { + .rails-default-error-page div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; @@ -31,13 +31,13 @@ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } - h1 { + .rails-default-error-page h1 { font-size: 100%; color: #730E15; line-height: 1.5em; } - div.dialog > p { + .rails-default-error-page div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; @@ -54,7 +54,7 @@ </style> </head> -<body> +<body class="rails-default-error-page"> <!-- This file lives in public/422.html --> <div class="dialog"> <div> diff --git a/railties/lib/rails/generators/rails/app/templates/public/500.html b/railties/lib/rails/generators/rails/app/templates/public/500.html index 061abc587d..78a030af22 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/500.html +++ b/railties/lib/rails/generators/rails/app/templates/public/500.html @@ -4,7 +4,7 @@ <title>We're sorry, but something went wrong (500)</title> <meta name="viewport" content="width=device-width,initial-scale=1"> <style> - body { + .rails-default-error-page { background-color: #EFEFEF; color: #2E2F30; text-align: center; @@ -12,13 +12,13 @@ margin: 0; } - div.dialog { + .rails-default-error-page div.dialog { width: 95%; max-width: 33em; margin: 4em auto 0; } - div.dialog > div { + .rails-default-error-page div.dialog > div { border: 1px solid #CCC; border-right-color: #999; border-left-color: #999; @@ -31,13 +31,13 @@ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); } - h1 { + .rails-default-error-page h1 { font-size: 100%; color: #730E15; line-height: 1.5em; } - div.dialog > p { + .rails-default-error-page div.dialog > p { margin: 0 0 1em; padding: 1em; background-color: #F7F7F7; @@ -54,7 +54,7 @@ </style> </head> -<body> +<body class="rails-default-error-page"> <!-- This file lives in public/500.html --> <div class="dialog"> <div> -- cgit v1.2.3 From 128b804c6ce40fcbde744f294f8cb98654f6efec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= <rafaelmfranca@gmail.com> Date: Fri, 21 Apr 2017 12:23:49 -0400 Subject: Configure form_with_generates_remote_forms in its own initializer This configuration is not present in ActionView::Base so we can't let the action_view.set_configs initializer set it. Also add tests to make sure this config works. Fixes #28824 --- railties/test/application/configuration_test.rb | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'railties') diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 14433fbba0..32eab74190 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -693,6 +693,38 @@ module ApplicationTests assert_match(/label/, last_response.body) end + test "form_with can be configured with form_with_generates_remote_forms" do + app_file "config/initializers/form_builder.rb", <<-RUBY + Rails.configuration.action_view.form_with_generates_remote_forms = false + RUBY + + app_file "app/models/post.rb", <<-RUBY + class Post + include ActiveModel::Model + attr_accessor :name + end + RUBY + + app_file "app/controllers/posts_controller.rb", <<-RUBY + class PostsController < ApplicationController + def index + render inline: "<%= begin; form_with(model: Post.new) {|f| f.text_field(:name)}; rescue => e; e.to_s; end %>" + end + end + RUBY + + add_to_config <<-RUBY + routes.prepend do + resources :posts + end + RUBY + + app "development" + + get "/posts" + assert_no_match(/data-remote/, last_response.body) + end + test "default method for update can be changed" do app_file "app/models/post.rb", <<-RUBY class Post -- cgit v1.2.3 From 87d6cb379d8cffd3f12b2dab6248ff3e8f830307 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" <yuuji.yaginuma@gmail.com> Date: Sat, 22 Apr 2017 12:27:25 +0900 Subject: Set to `form_with_generates_remote_forms` only when config is explicitly specified Without this check, even if config is not specified, `ActionView::Helpers::FormHelper.form_with_generates_remote_forms` always be set to nil and remote form not be generated. Follow up to 128b804c6ce40fcbde744f294f8cb98654f6efec --- railties/test/application/configuration_test.rb | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'railties') diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 32eab74190..07c6afed7f 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -725,6 +725,34 @@ module ApplicationTests assert_no_match(/data-remote/, last_response.body) end + test "form_with generates remote forms by default" do + app_file "app/models/post.rb", <<-RUBY + class Post + include ActiveModel::Model + attr_accessor :name + end + RUBY + + app_file "app/controllers/posts_controller.rb", <<-RUBY + class PostsController < ApplicationController + def index + render inline: "<%= begin; form_with(model: Post.new) {|f| f.text_field(:name)}; rescue => e; e.to_s; end %>" + end + end + RUBY + + add_to_config <<-RUBY + routes.prepend do + resources :posts + end + RUBY + + app "development" + + get "/posts" + assert_match(/data-remote/, last_response.body) + end + test "default method for update can be changed" do app_file "app/models/post.rb", <<-RUBY class Post -- cgit v1.2.3