railties 5.1.0.beta1 → 5.1.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +47 -0
  3. data/RDOC_MAIN.rdoc +1 -1
  4. data/lib/rails/application/configuration.rb +28 -0
  5. data/lib/rails/command.rb +2 -2
  6. data/lib/rails/command/base.rb +7 -1
  7. data/lib/rails/commands/destroy/destroy_command.rb +6 -4
  8. data/lib/rails/commands/generate/generate_command.rb +7 -2
  9. data/lib/rails/commands/new/new_command.rb +4 -2
  10. data/lib/rails/commands/runner/runner_command.rb +5 -3
  11. data/lib/rails/commands/secrets/USAGE +8 -0
  12. data/lib/rails/commands/secrets/secrets_command.rb +20 -7
  13. data/lib/rails/commands/server/server_command.rb +51 -14
  14. data/lib/rails/commands/test/test_command.rb +4 -2
  15. data/lib/rails/engine/updater.rb +19 -0
  16. data/lib/rails/gem_version.rb +1 -1
  17. data/lib/rails/generators.rb +1 -1
  18. data/lib/rails/generators/app_base.rb +2 -3
  19. data/lib/rails/generators/erb.rb +2 -2
  20. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +1 -1
  21. data/lib/rails/generators/rails/app/app_generator.rb +16 -0
  22. data/lib/rails/generators/rails/app/templates/Gemfile +1 -1
  23. data/lib/rails/generators/rails/app/templates/config/application.rb +3 -0
  24. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +5 -3
  25. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt +13 -0
  26. data/lib/rails/generators/rails/plugin/plugin_generator.rb +3 -2
  27. data/lib/rails/secrets.rb +8 -13
  28. data/lib/rails/tasks/engine.rake +11 -0
  29. data/lib/rails/test_help.rb +0 -13
  30. data/lib/rails/test_unit/minitest_plugin.rb +9 -3
  31. data/lib/rails/test_unit/test_requirer.rb +5 -2
  32. data/lib/rails/test_unit/testing.rake +5 -5
  33. metadata +10 -9
  34. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e880b16a919cc3d8a4c1e4d5af463543b65dabeb
4
- data.tar.gz: 49348dad3c1e30a80b51255bf9ab795e581a3193
3
+ metadata.gz: 6895d9df1a4cccea1127fb2713f7f16d50526088
4
+ data.tar.gz: 4fe4884d5c19e294acfb03223c2f7306994ca3c3
5
5
  SHA512:
6
- metadata.gz: 363fb1df7296e63daa7e265196aefb5ecc4d73068b87b89deeb7a20e586783d8737428a86f08e9fca59da0a215d65ea8d3e1f068f99ed245c37ddd70a9b0ec3d
7
- data.tar.gz: 37021a5573c68336ed17ec9cac218007d804d966d02adfdbadb7e566029e8343b5e0ba9a0e5bbb903d6b111c10b24c63fb1d00b8da8d651c77cb0e15b27ba738
6
+ metadata.gz: 0dd8f119fd87746234d6e55a2f83c17b0b0b67da5f023e381f48fcb4005bdb88e3689d27013011ed0e341d4eae4081233408622cbbc20a88a6bb38eb76e12504
7
+ data.tar.gz: 8bd6dc9bdd29b17ba24dee55fbcc0920d1ec48b4f97a434062c364351292ff55acb9c8954818190ab3914b8a0bed680c0635afe1f2cc03dcaabd0950009db568
@@ -1,5 +1,48 @@
1
+ ## Rails 5.1.0.rc1 (March 20, 2017) ##
2
+
3
+ * Add `app:update` task to engines.
4
+
5
+ *Yuji Yaginuma*
6
+
7
+ * Avoid running system tests by default with the `bin/rails test`
8
+ and `bin/rake test` commands since they may be expensive.
9
+
10
+ Fixes #28286.
11
+
12
+ *Robin Dupret*
13
+
14
+ * Improve encryption for encrypted secrets.
15
+
16
+ Switch to aes-128-gcm authenticated encryption. Also generate a random
17
+ initialization vector for each encryption so the same input and key can
18
+ generate different encrypted data.
19
+
20
+ Double the encryption key entropy by properly extracting the underlying
21
+ bytes from the hexadecimal seed key.
22
+
23
+ NOTE: Since the encryption mechanism has been switched, you need to run
24
+ this script to upgrade:
25
+
26
+ https://gist.github.com/kaspth/bc37989c2f39a5642112f28b1d93f343
27
+
28
+ *Stephen Touset*
29
+
1
30
  ## Rails 5.1.0.beta1 (February 23, 2017) ##
2
31
 
32
+ * Add encrypted secrets in `config/secrets.yml.enc`.
33
+
34
+ Allow storing production secrets straight in the revision control system by
35
+ encrypting them.
36
+
37
+ Use `bin/rails secrets:setup` to opt-in by generating `config/secrets.yml.enc`
38
+ for the secrets themselves and `config/secrets.yml.key` for the encryption key.
39
+
40
+ Edit secrets with `bin/rails secrets:edit`.
41
+
42
+ See `bin/rails secrets:setup --help` for more.
43
+
44
+ *Kasper Timm Hansen*
45
+
3
46
  * Fix running multiple tests in one `rake` command
4
47
 
5
48
  e.g. `bin/rake test:models test:controllers`
@@ -89,6 +132,10 @@
89
132
 
90
133
  *Tsukuru Tanimichi*
91
134
 
135
+ * Add `--skip-coffee` option to `rails new`
136
+
137
+ *Seunghwan Oh*
138
+
92
139
  * Allow the use of listen's 3.1.x branch
93
140
 
94
141
  *Esteban Santana Santana*
@@ -57,7 +57,7 @@ can read more about Action Pack in its {README}[link:files/actionpack/README_rdo
57
57
 
58
58
  * The \README file created within your application.
59
59
  * {Getting Started with \Rails}[http://guides.rubyonrails.org/getting_started.html].
60
- * {Ruby on \Rails Tutorial}[http://www.railstutorial.org/book].
60
+ * {Ruby on \Rails Tutorial}[https://www.railstutorial.org/book].
61
61
  * {Ruby on \Rails Guides}[http://guides.rubyonrails.org].
62
62
  * {The API Documentation}[http://api.rubyonrails.org].
63
63
 
@@ -55,6 +55,34 @@ module Rails
55
55
  @read_encrypted_secrets = false
56
56
  end
57
57
 
58
+ def load_defaults(target_version)
59
+ case target_version.to_s
60
+ when "5.0"
61
+ if respond_to?(:action_controller)
62
+ action_controller.per_form_csrf_tokens = true
63
+ action_controller.forgery_protection_origin_check = true
64
+ end
65
+
66
+ ActiveSupport.to_time_preserves_timezone = true
67
+
68
+ if respond_to?(:active_record)
69
+ active_record.belongs_to_required_by_default = true
70
+ end
71
+
72
+ self.ssl_options = { hsts: { subdomains: true } }
73
+
74
+ when "5.1"
75
+ load_defaults "5.0"
76
+
77
+ if respond_to?(:assets)
78
+ assets.unknown_asset_fallback = false
79
+ end
80
+
81
+ else
82
+ raise "Unknown version #{target_version.to_s.inspect}"
83
+ end
84
+ end
85
+
58
86
  def encoding=(value)
59
87
  @encoding = value
60
88
  silence_warnings do
@@ -36,8 +36,8 @@ module Rails
36
36
  command_name = namespace
37
37
  end
38
38
 
39
- command_name = "help" if command_name.blank? || HELP_MAPPINGS.include?(command_name)
40
- namespace = "version" if %w( -v --version ).include?(command_name)
39
+ command_name, namespace = "help", "help" if command_name.blank? || HELP_MAPPINGS.include?(command_name)
40
+ command_name, namespace = "version", "version" if %w( -v --version ).include?(command_name)
41
41
 
42
42
  command = find_by_namespace(namespace, command_name)
43
43
  if command && command.all_commands[command_name]
@@ -64,7 +64,7 @@ module Rails
64
64
  end
65
65
 
66
66
  def printing_commands
67
- namespace.sub(/^rails:/, "")
67
+ namespaced_commands
68
68
  end
69
69
 
70
70
  def executable
@@ -135,6 +135,12 @@ module Rails
135
135
  def command_root_namespace
136
136
  (namespace.split(":") - %w( rails )).first
137
137
  end
138
+
139
+ def namespaced_commands
140
+ commands.keys.map do |key|
141
+ key == command_root_namespace ? key : "#{command_root_namespace}:#{key}"
142
+ end
143
+ end
138
144
  end
139
145
 
140
146
  def help
@@ -3,8 +3,10 @@ require "rails/generators"
3
3
  module Rails
4
4
  module Command
5
5
  class DestroyCommand < Base # :nodoc:
6
- def help
7
- Rails::Generators.help self.class.command_name
6
+ no_commands do
7
+ def help
8
+ Rails::Generators.help self.class.command_name
9
+ end
8
10
  end
9
11
 
10
12
  def perform(*)
@@ -12,9 +14,9 @@ module Rails
12
14
  return help unless generator
13
15
 
14
16
  require_application_and_environment!
15
- Rails.application.load_generators
17
+ load_generators
16
18
 
17
- Rails::Generators.invoke generator, args, behavior: :revoke, destination_root: Rails.root
19
+ Rails::Generators.invoke generator, args, behavior: :revoke, destination_root: Rails::Command.root
18
20
  end
19
21
  end
20
22
  end
@@ -3,8 +3,13 @@ require "rails/generators"
3
3
  module Rails
4
4
  module Command
5
5
  class GenerateCommand < Base # :nodoc:
6
- def help
7
- Rails::Generators.help self.class.command_name
6
+ no_commands do
7
+ def help
8
+ require_application_and_environment!
9
+ load_generators
10
+
11
+ Rails::Generators.help self.class.command_name
12
+ end
8
13
  end
9
14
 
10
15
  def perform(*)
@@ -1,8 +1,10 @@
1
1
  module Rails
2
2
  module Command
3
3
  class NewCommand < Base # :nodoc:
4
- def help
5
- Rails::Command.invoke :application, [ "--help" ]
4
+ no_commands do
5
+ def help
6
+ Rails::Command.invoke :application, [ "--help" ]
7
+ end
6
8
  end
7
9
 
8
10
  def perform(*)
@@ -5,9 +5,11 @@ module Rails
5
5
  default: Rails::Command.environment.dup,
6
6
  desc: "The environment for the runner to operate under (test/development/production)"
7
7
 
8
- def help
9
- super
10
- puts self.class.desc
8
+ no_commands do
9
+ def help
10
+ super
11
+ puts self.class.desc
12
+ end
11
13
  end
12
14
 
13
15
  def self.banner(*)
@@ -40,6 +40,14 @@ be encrypted.
40
40
  A `shared:` top level key is also supported such that any keys there is merged
41
41
  into the other environments.
42
42
 
43
+ Additionally, Rails won't read encrypted secrets out of the box even if you have
44
+ the key. Add this:
45
+
46
+ config.read_encrypted_secrets = true
47
+
48
+ to the environment you'd like to read encrypted secrets. `bin/rails secrets:setup`
49
+ inserts this into the production environment by default.
50
+
43
51
  === Editing Secrets
44
52
 
45
53
  After `bin/rails secrets:setup`, run `bin/rails secrets:edit`.
@@ -4,10 +4,12 @@ require "rails/secrets"
4
4
  module Rails
5
5
  module Command
6
6
  class SecretsCommand < Rails::Command::Base # :nodoc:
7
- def help
8
- say "Usage:\n #{self.class.banner}"
9
- say ""
10
- say self.class.desc
7
+ no_commands do
8
+ def help
9
+ say "Usage:\n #{self.class.banner}"
10
+ say ""
11
+ say self.class.desc
12
+ end
11
13
  end
12
14
 
13
15
  def setup
@@ -18,16 +20,27 @@ module Rails
18
20
  end
19
21
 
20
22
  def edit
23
+ if ENV["EDITOR"].to_s.empty?
24
+ say "No $EDITOR to open decrypted secrets in. Assign one like this:"
25
+ say ""
26
+ say %(EDITOR="mate --wait" bin/rails secrets:edit)
27
+ say ""
28
+ say "For editors that fork and exit immediately, it's important to pass a wait flag,"
29
+ say "otherwise the secrets will be saved immediately with no chance to edit."
30
+
31
+ return
32
+ end
33
+
21
34
  require_application_and_environment!
22
35
 
23
36
  Rails::Secrets.read_for_editing do |tmp_path|
24
- puts "Waiting for secrets file to be saved. Abort with Ctrl-C."
37
+ say "Waiting for secrets file to be saved. Abort with Ctrl-C."
25
38
  system("\$EDITOR #{tmp_path}")
26
39
  end
27
40
 
28
- puts "New secrets encrypted and saved."
41
+ say "New secrets encrypted and saved."
29
42
  rescue Interrupt
30
- puts "Aborted changing encrypted secrets: nothing saved."
43
+ say "Aborted changing encrypted secrets: nothing saved."
31
44
  rescue Rails::Secrets::MissingKeyError => error
32
45
  say error.message
33
46
  end
@@ -99,8 +99,9 @@ module Rails
99
99
 
100
100
  class_option :port, aliases: "-p", type: :numeric,
101
101
  desc: "Runs Rails on the specified port.", banner: :port, default: 3000
102
- class_option :binding, aliases: "-b", type: :string, default: "localhost",
103
- desc: "Binds Rails to the specified IP.", banner: :IP
102
+ class_option :binding, aliases: "-b", type: :string,
103
+ desc: "Binds Rails to the specified IP - defaults to 'localhost' in development and '0.0.0.0' in other environments'.",
104
+ banner: :IP
104
105
  class_option :config, aliases: "-c", type: :string, default: "config.ru",
105
106
  desc: "Uses a custom rackup configuration.", banner: :file
106
107
  class_option :daemon, aliases: "-d", type: :boolean, default: false,
@@ -133,28 +134,64 @@ module Rails
133
134
  no_commands do
134
135
  def server_options
135
136
  {
136
- server: @server,
137
- log_stdout: @log_stdout,
138
- Port: port,
139
- Host: host,
140
- DoNotReverseLookup: true,
141
- config: options[:config],
142
- environment: environment,
143
- daemonize: options[:daemon],
144
- pid: pid,
145
- caching: options["dev-caching"],
146
- restart_cmd: restart_command
137
+ user_supplied_options: user_supplied_options,
138
+ server: @server,
139
+ log_stdout: @log_stdout,
140
+ Port: port,
141
+ Host: host,
142
+ DoNotReverseLookup: true,
143
+ config: options[:config],
144
+ environment: environment,
145
+ daemonize: options[:daemon],
146
+ pid: pid,
147
+ caching: options["dev-caching"],
148
+ restart_cmd: restart_command
147
149
  }
148
150
  end
149
151
  end
150
152
 
151
153
  private
154
+ def user_supplied_options
155
+ @user_supplied_options ||= begin
156
+ # Convert incoming options array to a hash of flags
157
+ # ["-p", "3001", "-c", "foo"] # => {"-p" => true, "-c" => true}
158
+ user_flag = {}
159
+ @original_options.each_with_index { |command, i| user_flag[command] = true if i.even? }
160
+
161
+ # Collect all options that the user has explicitly defined so we can
162
+ # differentiate them from defaults
163
+ user_supplied_options = []
164
+ self.class.class_options.select do |key, option|
165
+ if option.aliases.any? { |name| user_flag[name] } || user_flag["--#{option.name}"]
166
+ name = option.name.to_sym
167
+ case name
168
+ when :port
169
+ name = :Port
170
+ when :binding
171
+ name = :Host
172
+ when :"dev-caching"
173
+ name = :caching
174
+ when :daemonize
175
+ name = :daemon
176
+ end
177
+ user_supplied_options << name
178
+ end
179
+ end
180
+ user_supplied_options << :Host if ENV["HOST"]
181
+ user_supplied_options << :Port if ENV["PORT"]
182
+ user_supplied_options.uniq
183
+ end
184
+ end
185
+
152
186
  def port
153
187
  ENV.fetch("PORT", options[:port]).to_i
154
188
  end
155
189
 
156
190
  def host
157
- ENV.fetch("HOST", options[:binding])
191
+ unless (default_host = options[:binding])
192
+ default_host = environment == "development" ? "localhost" : "0.0.0.0"
193
+ end
194
+ ENV.fetch("HOST", default_host)
158
195
  end
159
196
 
160
197
  def environment
@@ -4,8 +4,10 @@ require "rails/test_unit/minitest_plugin"
4
4
  module Rails
5
5
  module Command
6
6
  class TestCommand < Base # :nodoc:
7
- def help
8
- perform # Hand over help printing to minitest.
7
+ no_commands do
8
+ def help
9
+ perform # Hand over help printing to minitest.
10
+ end
9
11
  end
10
12
 
11
13
  def perform(*)
@@ -0,0 +1,19 @@
1
+ require "rails/generators"
2
+ require "rails/generators/rails/plugin/plugin_generator"
3
+
4
+ module Rails
5
+ class Engine
6
+ class Updater
7
+ class << self
8
+ def generator
9
+ @generator ||= Rails::Generators::PluginGenerator.new ["plugin"],
10
+ { engine: true }, destination_root: ENGINE_ROOT
11
+ end
12
+
13
+ def run(action)
14
+ generator.send(action)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -8,7 +8,7 @@ module Rails
8
8
  MAJOR = 5
9
9
  MINOR = 1
10
10
  TINY = 0
11
- PRE = "beta1"
11
+ PRE = "rc1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -63,7 +63,7 @@ module Rails
63
63
  stylesheet_engine: :css,
64
64
  scaffold_stylesheet: true,
65
65
  system_tests: nil,
66
- test_framework: false,
66
+ test_framework: nil,
67
67
  template_engine: :erb
68
68
  }
69
69
  }
@@ -280,7 +280,7 @@ module Rails
280
280
  case options[:database]
281
281
  when "mysql" then ["mysql2", [">= 0.3.18", "< 0.5"]]
282
282
  when "postgresql" then ["pg", ["~> 0.18"]]
283
- when "oracle" then ["ruby-oci8", nil]
283
+ when "oracle" then ["activerecord-oracle_enhanced-adapter", nil]
284
284
  when "frontbase" then ["ruby-frontbase", nil]
285
285
  when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
286
286
  when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
@@ -296,7 +296,6 @@ module Rails
296
296
  case options[:database]
297
297
  when "postgresql" then options[:database].replace "jdbcpostgresql"
298
298
  when "mysql" then options[:database].replace "jdbcmysql"
299
- when "oracle" then options[:database].replace "jdbc"
300
299
  when "sqlite3" then options[:database].replace "jdbcsqlite3"
301
300
  end
302
301
  end
@@ -322,7 +321,7 @@ module Rails
322
321
  return [] unless options[:webpack]
323
322
 
324
323
  comment = "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker"
325
- GemfileEntry.github "webpacker", "rails/webpacker", nil, comment
324
+ GemfileEntry.new "webpacker", nil, comment
326
325
  end
327
326
 
328
327
  def jbuilder_gemfile_entry
@@ -17,8 +17,8 @@ module Erb # :nodoc:
17
17
  :erb
18
18
  end
19
19
 
20
- def filename_with_extensions(name, format = self.format)
21
- [name, format, handler].compact.join(".")
20
+ def filename_with_extensions(name, file_format = format)
21
+ [name, file_format, handler].compact.join(".")
22
22
  end
23
23
  end
24
24
  end
@@ -1,4 +1,4 @@
1
- <%%= form_for(<%= singular_table_name %>) do |f| %>
1
+ <%%= form_with(model: <%= singular_table_name %>, local: true) do |f| %>
2
2
  <%% if <%= singular_table_name %>.errors.any? %>
3
3
  <div id="error_explanation">
4
4
  <h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
@@ -32,6 +32,14 @@ module Rails
32
32
  # This allows you to override entire operations, like the creation of the
33
33
  # Gemfile, README, or JavaScript files, without needing to know exactly
34
34
  # what those operations do so you can create another template action.
35
+ #
36
+ # class CustomAppBuilder < Rails::AppBuilder
37
+ # def test
38
+ # @generator.gem "rspec-rails", group: [:development, :test]
39
+ # run "bundle install"
40
+ # generate "rspec:install"
41
+ # end
42
+ # end
35
43
  class AppBuilder
36
44
  def rakefile
37
45
  template "Rakefile"
@@ -363,6 +371,14 @@ module Rails
363
371
  end
364
372
  end
365
373
 
374
+ def delete_new_framework_defaults
375
+ # Sprockets owns the only new default for 5.1: if it's disabled,
376
+ # we don't want the file.
377
+ unless options[:update] && !options[:skip_sprockets]
378
+ remove_file "config/initializers/new_framework_defaults_5_1.rb"
379
+ end
380
+ end
381
+
366
382
  def delete_bin_yarn_if_skip_yarn_option
367
383
  remove_file "bin/yarn" if options[:skip_yarn]
368
384
  end
@@ -34,7 +34,7 @@ group :development, :test do
34
34
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
35
35
  <%- unless options.skip_system_test? || options.api? -%>
36
36
  # Adds support for Capybara system testing and selenium driver
37
- gem 'capybara', '~> 2.7.0'
37
+ gem 'capybara', '~> 2.13.0'
38
38
  gem 'selenium-webdriver'
39
39
  <%- end -%>
40
40
  end
@@ -22,6 +22,9 @@ Bundler.require(*Rails.groups)
22
22
 
23
23
  module <%= app_const_base %>
24
24
  class Application < Rails::Application
25
+ # Initialize configuration defaults for originally generated Rails version.
26
+ config.load_defaults <%= Rails::VERSION::STRING.to_f %>
27
+
25
28
  # Settings in config/environments/* take precedence over those specified here.
26
29
  # Application configuration should go into files in config/initializers
27
30
  # -- all .rb files in that directory are automatically loaded.
@@ -1,4 +1,4 @@
1
- # Oracle/OCI 8i, 9, 10g
1
+ # Oracle/OCI 11g or higher recommended
2
2
  #
3
3
  # Requires Ruby/OCI8:
4
4
  # https://github.com/kubo/ruby-oci8
@@ -17,7 +17,7 @@
17
17
  # cursor_sharing: similar
18
18
  #
19
19
  default: &default
20
- adapter: oracle
20
+ adapter: oracle_enhanced
21
21
  pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
22
22
  username: <%= app_name %>
23
23
  password:
@@ -45,7 +45,9 @@ test:
45
45
  # On Heroku and other platform providers, you may have a full connection URL
46
46
  # available as an environment variable. For example:
47
47
  #
48
- # DATABASE_URL="oracle://myuser:mypass@localhost/somedatabase"
48
+ # DATABASE_URL="oracle-enhanced://myuser:mypass@localhost/somedatabase"
49
+ #
50
+ # Note that the adapter name uses a dash instead of an underscore.
49
51
  #
50
52
  # You can use this database configuration with:
51
53
  #
@@ -0,0 +1,13 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains migration options to ease your Rails 5.1 upgrade.
4
+ #
5
+ # Once upgraded flip defaults one by one to migrate to the new default.
6
+ #
7
+ # Read the Guide for Upgrading Ruby on Rails for more info on each option.
8
+ <%- unless options[:skip_sprockets] -%>
9
+
10
+ # Unknown asset fallback will return the path passed in when the given
11
+ # asset is not present in the asset pipeline.
12
+ # Rails.application.config.assets.unknown_asset_fallback = false
13
+ <%- end -%>
@@ -92,6 +92,7 @@ task default: :test
92
92
  opts[:api] = options.api?
93
93
  opts[:skip_listen] = true
94
94
  opts[:skip_git] = true
95
+ opts[:skip_turbolinks] = true
95
96
 
96
97
  invoke Rails::Generators::AppGenerator,
97
98
  [ File.expand_path(dummy_path, destination_root) ], opts
@@ -300,7 +301,7 @@ task default: :test
300
301
  end
301
302
 
302
303
  def engine?
303
- full? || mountable?
304
+ full? || mountable? || options[:engine]
304
305
  end
305
306
 
306
307
  def full?
@@ -432,7 +433,7 @@ end
432
433
  end
433
434
 
434
435
  def inside_application?
435
- rails_app_path && app_path =~ /^#{rails_app_path}/
436
+ rails_app_path && destination_root.start_with?(rails_app_path.to_s)
436
437
  end
437
438
 
438
439
  def relative_path
@@ -1,4 +1,5 @@
1
1
  require "yaml"
2
+ require "active_support/message_encryptor"
2
3
 
3
4
  module Rails
4
5
  # Greatly inspired by Ara T. Howard's magnificent sekrets gem. 😘
@@ -12,6 +13,7 @@ module Rails
12
13
  end
13
14
  end
14
15
 
16
+ @cipher = "aes-128-gcm"
15
17
  @read_encrypted_secrets = false
16
18
  @root = File # Wonky, but ensures `join` uses the current directory.
17
19
 
@@ -30,20 +32,19 @@ module Rails
30
32
  end
31
33
 
32
34
  def generate_key
33
- cipher = new_cipher
34
- SecureRandom.hex(cipher.key_len)[0, cipher.key_len]
35
+ SecureRandom.hex(OpenSSL::Cipher.new(@cipher).key_len)
35
36
  end
36
37
 
37
38
  def key
38
39
  ENV["RAILS_MASTER_KEY"] || read_key_file || handle_missing_key
39
40
  end
40
41
 
41
- def encrypt(text)
42
- cipher(:encrypt, text)
42
+ def encrypt(data)
43
+ encryptor.encrypt_and_sign(data)
43
44
  end
44
45
 
45
46
  def decrypt(data)
46
- cipher(:decrypt, data)
47
+ encryptor.decrypt_and_verify(data)
47
48
  end
48
49
 
49
50
  def read
@@ -97,14 +98,8 @@ module Rails
97
98
  end
98
99
  end
99
100
 
100
- def new_cipher
101
- OpenSSL::Cipher.new("aes-256-cbc")
102
- end
103
-
104
- def cipher(mode, data)
105
- cipher = new_cipher.public_send(mode)
106
- cipher.key = key
107
- cipher.update(data) << cipher.final
101
+ def encryptor
102
+ @encryptor ||= ActiveSupport::MessageEncryptor.new([ key ].pack("H*"), cipher: @cipher)
108
103
  end
109
104
  end
110
105
  end
@@ -1,6 +1,17 @@
1
1
  task "load_app" do
2
2
  namespace :app do
3
3
  load APP_RAKEFILE
4
+
5
+ desc "Update some initially generated files"
6
+ task update: [ "update:bin" ]
7
+
8
+ namespace :update do
9
+ require "rails/engine/updater"
10
+ # desc "Adds new executables to the engine bin/ directory"
11
+ task :bin do
12
+ Rails::Engine::Updater.run(:create_bin_files)
13
+ end
14
+ end
4
15
  end
5
16
  task environment: "app:environment"
6
17
 
@@ -11,10 +11,6 @@ require "rails/generators/test_case"
11
11
 
12
12
  require "active_support/testing/autorun"
13
13
 
14
- if defined?(Capbyara)
15
- require "action_dispatch/system_test_case"
16
- end
17
-
18
14
  if defined?(ActiveRecord::Base)
19
15
  ActiveRecord::Migration.maintain_test_schema!
20
16
 
@@ -48,12 +44,3 @@ class ActionDispatch::IntegrationTest
48
44
  super
49
45
  end
50
46
  end
51
-
52
- if defined? Capybara
53
- class ActionDispatch::SystemTestCase
54
- def before_setup # :nodoc:
55
- @routes = Rails.application.routes
56
- super
57
- end
58
- end
59
- end
@@ -62,9 +62,9 @@ module Minitest
62
62
  options[:patterns] = opts.order! unless run_via.rake?
63
63
  end
64
64
 
65
- def self.rake_run(patterns) # :nodoc:
65
+ def self.rake_run(patterns, exclude_patterns = []) # :nodoc:
66
66
  self.run_via = :rake unless run_via.set?
67
- ::Rails::TestRequirer.require_files(patterns)
67
+ ::Rails::TestRequirer.require_files(patterns, exclude_patterns)
68
68
  autorun
69
69
  end
70
70
 
@@ -88,7 +88,13 @@ module Minitest
88
88
  # If run via `ruby` we've been passed the files to run directly, or if run
89
89
  # via `rake` then they have already been eagerly required.
90
90
  unless run_via.ruby? || run_via.rake?
91
- ::Rails::TestRequirer.require_files(options[:patterns])
91
+ # If there are no given patterns, we can assume that the user
92
+ # simply runs the `bin/rails test` command without extra arguments.
93
+ if options[:patterns].empty?
94
+ ::Rails::TestRequirer.require_files(options[:patterns], ["test/system/**/*"])
95
+ else
96
+ ::Rails::TestRequirer.require_files(options[:patterns])
97
+ end
92
98
  end
93
99
 
94
100
  unless options[:full_backtrace] || ENV["BACKTRACE"]
@@ -4,10 +4,13 @@ require "rake/file_list"
4
4
  module Rails
5
5
  class TestRequirer # :nodoc:
6
6
  class << self
7
- def require_files(patterns)
7
+ def require_files(patterns, exclude_patterns = [])
8
8
  patterns = expand_patterns(patterns)
9
9
 
10
- Rake::FileList[patterns.compact.presence || "test/**/*_test.rb"].to_a.each do |file|
10
+ file_list = Rake::FileList[patterns.compact.presence || "test/**/*_test.rb"]
11
+ file_list.exclude(exclude_patterns)
12
+
13
+ file_list.to_a.each do |file|
11
14
  require File.expand_path(file)
12
15
  end
13
16
  end
@@ -4,15 +4,15 @@ require "rails/test_unit/minitest_plugin"
4
4
 
5
5
  task default: :test
6
6
 
7
- desc "Runs all tests in test folder"
7
+ desc "Runs all tests in test folder except system ones"
8
8
  task :test do
9
9
  $: << "test"
10
- pattern = if ENV.key?("TEST")
11
- ENV["TEST"]
10
+
11
+ if ENV.key?("TEST")
12
+ Minitest.rake_run([ENV["TEST"]])
12
13
  else
13
- "test"
14
+ Minitest.rake_run(["test"], ["test/system/**/*"])
14
15
  end
15
- Minitest.rake_run([pattern])
16
16
  end
17
17
 
18
18
  namespace :test do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railties
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0.beta1
4
+ version: 5.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-23 00:00:00.000000000 Z
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.0.beta1
19
+ version: 5.1.0.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.1.0.beta1
26
+ version: 5.1.0.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 5.1.0.beta1
33
+ version: 5.1.0.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 5.1.0.beta1
40
+ version: 5.1.0.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 5.1.0.beta1
95
+ version: 5.1.0.rc1
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 5.1.0.beta1
102
+ version: 5.1.0.rc1
103
103
  description: 'Rails internals: application bootup, plugins, generators, and rake tasks.'
104
104
  email: david@loudthinking.com
105
105
  executables:
@@ -159,6 +159,7 @@ files:
159
159
  - lib/rails/engine/commands.rb
160
160
  - lib/rails/engine/configuration.rb
161
161
  - lib/rails/engine/railties.rb
162
+ - lib/rails/engine/updater.rb
162
163
  - lib/rails/gem_version.rb
163
164
  - lib/rails/generators.rb
164
165
  - lib/rails/generators/actions.rb
@@ -241,7 +242,7 @@ files:
241
242
  - lib/rails/generators/rails/app/templates/config/initializers/filter_parameter_logging.rb
242
243
  - lib/rails/generators/rails/app/templates/config/initializers/inflections.rb
243
244
  - lib/rails/generators/rails/app/templates/config/initializers/mime_types.rb
244
- - lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt
245
+ - lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt
245
246
  - lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
246
247
  - lib/rails/generators/rails/app/templates/config/locales/en.yml
247
248
  - lib/rails/generators/rails/app/templates/config/puma.rb
@@ -1,37 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains migration options to ease your Rails 5.0 upgrade.
4
- #
5
- <%- if options[:update] -%>
6
- # Once upgraded flip defaults one by one to migrate to the new default.
7
- #
8
- <%- end -%>
9
- # Read the Guide for Upgrading Ruby on Rails for more info on each option.
10
- <%- unless options[:api] -%>
11
-
12
- # Enable per-form CSRF tokens. Previous versions had false.
13
- Rails.application.config.action_controller.per_form_csrf_tokens = <%= options[:update] ? false : true %>
14
-
15
- # Enable origin-checking CSRF mitigation. Previous versions had false.
16
- Rails.application.config.action_controller.forgery_protection_origin_check = <%= options[:update] ? false : true %>
17
- <%- end -%>
18
-
19
- # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
20
- # Previous versions had false.
21
- ActiveSupport.to_time_preserves_timezone = <%= options[:update] ? false : true %>
22
- <%- unless options[:skip_active_record] -%>
23
-
24
- # Require `belongs_to` associations by default. Previous versions had false.
25
- Rails.application.config.active_record.belongs_to_required_by_default = <%= options[:update] ? false : true %>
26
- <%- end -%>
27
- <%- unless options[:update] -%>
28
-
29
- # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
30
- Rails.application.config.ssl_options = { hsts: { subdomains: true } }
31
- <%- end -%>
32
- <%- unless options[:skip_sprockets] -%>
33
-
34
- # Unknown asset fallback will return the path passed in when the given
35
- # asset is not present in the asset pipeline.
36
- Rails.application.config.assets.unknown_asset_fallback = <%= options[:update] ? true : false %>
37
- <%- end -%>