railties 4.0.0.beta1 → 4.0.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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +120 -27
  3. data/RDOC_MAIN.rdoc +73 -0
  4. data/bin/rails +3 -1
  5. data/lib/rails/api/task.rb +158 -0
  6. data/lib/rails/app_rails_loader.rb +44 -20
  7. data/lib/rails/application.rb +55 -32
  8. data/lib/rails/application/configuration.rb +9 -7
  9. data/lib/rails/commands.rb +2 -0
  10. data/lib/rails/commands/console.rb +3 -1
  11. data/lib/rails/commands/server.rb +6 -2
  12. data/lib/rails/engine.rb +4 -3
  13. data/lib/rails/generators/actions.rb +1 -1
  14. data/lib/rails/generators/app_base.rb +52 -30
  15. data/lib/rails/generators/erb/scaffold/templates/_form.html.erb +10 -1
  16. data/lib/rails/generators/erb/scaffold/templates/index.html.erb +9 -9
  17. data/lib/rails/generators/erb/scaffold/templates/show.html.erb +1 -2
  18. data/lib/rails/generators/generated_attribute.rb +4 -0
  19. data/lib/rails/generators/named_base.rb +2 -1
  20. data/lib/rails/generators/rails/app/templates/Gemfile +9 -4
  21. data/lib/rails/generators/rails/app/templates/config.ru +1 -1
  22. data/lib/rails/generators/rails/app/templates/config/application.rb +3 -2
  23. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +2 -0
  24. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +2 -2
  25. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -1
  26. data/lib/rails/generators/rails/app/templates/config/initializers/secret_token.rb.tt +1 -1
  27. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +1 -1
  28. data/lib/rails/generators/rails/app/templates/config/routes.rb +1 -1
  29. data/lib/rails/generators/rails/app/templates/public/404.html +41 -10
  30. data/lib/rails/generators/rails/app/templates/public/422.html +42 -10
  31. data/lib/rails/generators/rails/app/templates/public/500.html +41 -10
  32. data/lib/rails/generators/rails/app/templates/test/test_helper.rb +1 -1
  33. data/lib/rails/generators/rails/model/USAGE +16 -10
  34. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +9 -5
  35. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +0 -3
  36. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +0 -8
  37. data/lib/rails/generators/rails/plugin_new/templates/rails/boot.rb +4 -8
  38. data/lib/rails/generators/rails/plugin_new/templates/rails/javascripts.js +13 -0
  39. data/lib/rails/generators/rails/plugin_new/templates/rails/stylesheets.css +13 -0
  40. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +1 -0
  41. data/lib/rails/generators/rails/scaffold_controller/templates/controller.rb +1 -1
  42. data/lib/rails/generators/test_case.rb +6 -211
  43. data/lib/rails/generators/test_unit/model/templates/fixtures.yml +7 -9
  44. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +5 -1
  45. data/lib/rails/generators/testing/assertions.rb +121 -0
  46. data/lib/rails/generators/testing/behaviour.rb +106 -0
  47. data/lib/rails/generators/testing/setup_and_teardown.rb +18 -0
  48. data/lib/rails/info.rb +2 -2
  49. data/lib/rails/tasks/documentation.rake +2 -46
  50. data/lib/rails/templates/rails/welcome/index.html.erb +1 -1
  51. data/lib/rails/test_unit/railtie.rb +4 -0
  52. data/lib/rails/test_unit/sub_test_task.rb +78 -1
  53. data/lib/rails/test_unit/testing.rake +32 -42
  54. data/lib/rails/version.rb +3 -3
  55. metadata +15 -23
  56. data/lib/rails/generators/rails/app/templates/app/assets/images/rails.png +0 -0
@@ -13,8 +13,17 @@
13
13
 
14
14
  <% attributes.each do |attribute| -%>
15
15
  <div class="field">
16
- <%%= f.label :<%= attribute.name %> %><br />
16
+ <% if attribute.password_digest? -%>
17
+ <%%= f.label :password %><br>
18
+ <%%= f.password_field :password %>
19
+ </div>
20
+ <div>
21
+ <%%= f.label :password_confirmation %><br>
22
+ <%%= f.password_field :password_confirmation %>
23
+ <% else -%>
24
+ <%%= f.label :<%= attribute.name %> %><br>
17
25
  <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
26
+ <% end -%>
18
27
  </div>
19
28
  <% end -%>
20
29
  <div class="actions">
@@ -3,7 +3,7 @@
3
3
  <table>
4
4
  <thead>
5
5
  <tr>
6
- <% attributes.each do |attribute| -%>
6
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
7
7
  <th><%= attribute.human_name %></th>
8
8
  <% end -%>
9
9
  <th></th>
@@ -14,18 +14,18 @@
14
14
 
15
15
  <tbody>
16
16
  <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
17
- <tr>
18
- <% attributes.each do |attribute| -%>
19
- <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
+ <tr>
18
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
19
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
20
20
  <% end -%>
21
- <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
22
- <td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
23
- <td><%%= link_to 'Destroy', <%= singular_table_name %>, method: :delete, data: { confirm: 'Are you sure?' } %></td>
24
- </tr>
21
+ <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
22
+ <td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
23
+ <td><%%= link_to 'Destroy', <%= singular_table_name %>, method: :delete, data: { confirm: 'Are you sure?' } %></td>
24
+ </tr>
25
25
  <%% end %>
26
26
  </tbody>
27
27
  </table>
28
28
 
29
- <br />
29
+ <br>
30
30
 
31
31
  <%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
@@ -1,12 +1,11 @@
1
1
  <p id="notice"><%%= notice %></p>
2
2
 
3
- <% attributes.each do |attribute| -%>
3
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
4
4
  <p>
5
5
  <strong><%= attribute.human_name %>:</strong>
6
6
  <%%= @<%= singular_table_name %>.<%= attribute.name %> %>
7
7
  </p>
8
8
 
9
9
  <% end -%>
10
-
11
10
  <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
12
11
  <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -130,6 +130,10 @@ module Rails
130
130
  @has_uniq_index
131
131
  end
132
132
 
133
+ def password_digest?
134
+ name == 'password' && type == :digest
135
+ end
136
+
133
137
  def inject_options
134
138
  "".tap { |s| @attr_options.each { |k,v| s << ", #{k}: #{v.inspect}" } }
135
139
  end
@@ -40,7 +40,7 @@ module Rails
40
40
 
41
41
  def indent(content, multiplier = 2)
42
42
  spaces = " " * multiplier
43
- content = content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
43
+ content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
44
44
  end
45
45
 
46
46
  def wrap_with_namespace(content)
@@ -163,6 +163,7 @@ module Rails
163
163
  def attributes_names
164
164
  @attributes_names ||= attributes.each_with_object([]) do |a, names|
165
165
  names << a.column_name
166
+ names << 'password_confirmation' if a.password_digest?
166
167
  names << "#{a.name}_type" if a.polymorphic?
167
168
  end
168
169
  end
@@ -12,16 +12,21 @@ source 'https://rubygems.org'
12
12
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
13
13
  gem 'jbuilder', '~> 1.0.1'
14
14
 
15
- # To use ActiveModel has_secure_password
15
+ group :doc do
16
+ # bundle exec rake doc:rails generates the API under doc/api.
17
+ gem 'sdoc', require: false
18
+ end
19
+
20
+ # Use ActiveModel has_secure_password
16
21
  # gem 'bcrypt-ruby', '~> 3.0.0'
17
22
 
18
23
  # Use unicorn as the app server
19
24
  # gem 'unicorn'
20
25
 
21
- # Deploy with Capistrano
26
+ # Use Capistrano for deployment
22
27
  # gem 'capistrano', group: :development
23
28
 
24
29
  <% unless defined?(JRUBY_VERSION) -%>
25
- # To use debugger
26
- # gem 'debugger'
30
+ # Use debugger
31
+ # gem 'debugger', group: [:development, :test]
27
32
  <% end -%>
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
3
  require ::File.expand_path('../config/environment', __FILE__)
4
- run <%= app_const %>
4
+ run Rails.application
@@ -11,8 +11,9 @@ require "action_mailer/railtie"
11
11
  <%= comment_if :skip_test_unit %>require "rails/test_unit/railtie"
12
12
  <% end -%>
13
13
 
14
- # Assets should be precompiled for production (so we don't need the gems loaded then)
15
- Bundler.require(*Rails.groups(assets: %w(development test)))
14
+ # Require the gems listed in Gemfile, including any gems
15
+ # you've limited to :test, :development, or :production.
16
+ Bundler.require(:default, Rails.env)
16
17
 
17
18
  module <%= app_const_base %>
18
19
  class Application < Rails::Application
@@ -26,6 +26,8 @@
26
26
 
27
27
  <%- unless options.skip_sprockets? -%>
28
28
  # Debug mode disables concatenation and preprocessing of assets.
29
+ # This option may cause significant delays in view rendering with a large
30
+ # number of complex assets.
29
31
  config.assets.debug = true
30
32
  <%- end -%>
31
33
  end
@@ -24,10 +24,10 @@
24
24
 
25
25
  <%- unless options.skip_sprockets? -%>
26
26
  # Compress JavaScripts and CSS.
27
- config.assets.js_compressor = :uglifier
27
+ config.assets.js_compressor = :uglifier
28
28
  # config.assets.css_compressor = :sass
29
29
 
30
- # Whether to fallback to assets pipeline if a precompiled asset is missed.
30
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
31
31
  config.assets.compile = false
32
32
 
33
33
  # Generate digests for assets URLs.
@@ -13,7 +13,7 @@
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
16
+ config.serve_static_assets = true
17
17
  config.static_cache_control = "public, max-age=3600"
18
18
 
19
19
  # Show full error reports and disable caching.
@@ -1,6 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Your secret key for verifying the integrity of signed cookies.
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
 
6
6
  # Make sure the secret is at least 30 characters and all random,
@@ -1,3 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- <%= app_const %>.config.session_store :encrypted_cookie_store, key: <%= "'_#{app_name}_session'" %>
3
+ <%= app_const %>.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %>
@@ -3,7 +3,7 @@
3
3
  # See how all your routes lay out with "rake routes".
4
4
 
5
5
  # You can have the root of your site routed with "root"
6
- # root to: 'welcome#index'
6
+ # root 'welcome#index'
7
7
 
8
8
  # Example of regular route:
9
9
  # get 'products/:id' => 'catalog#view'
@@ -3,16 +3,47 @@
3
3
  <head>
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
5
  <style>
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -3,16 +3,47 @@
3
3
  <head>
4
4
  <title>The change you wanted was rejected (422)</title>
5
5
  <style>
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -22,5 +53,6 @@
22
53
  <h1>The change you wanted was rejected.</h1>
23
54
  <p>Maybe you tried to change something you didn't have access to.</p>
24
55
  </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
25
57
  </body>
26
58
  </html>
@@ -3,16 +3,47 @@
3
3
  <head>
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
5
  <style>
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -1,4 +1,4 @@
1
- ENV["RAILS_ENV"] = "test"
1
+ ENV["RAILS_ENV"] ||= "test"
2
2
  require File.expand_path('../../config/environment', __FILE__)
3
3
  require 'rails/test_help'
4
4
 
@@ -52,20 +52,26 @@ Available field types:
52
52
 
53
53
  `rails generate model product supplier:references{polymorphic}`
54
54
 
55
- You can also specify some options just after the field type. You can use the
56
- following options:
55
+ For integer, string, text and binary fields an integer in curly braces will
56
+ be set as the limit:
57
57
 
58
- limit Set the maximum size of the field giving a number between curly braces
59
- default Set a default value for the field
60
- precision Defines the precision for the decimal fields
61
- scale Defines the scale for the decimal fields
62
- uniq Defines the field values as unique
63
- index Will add an index on the field
58
+ `rails generate model user pseudo:string{30}`
64
59
 
65
- Examples:
60
+ For decimal two integers separated by a comma in curly braces will be used
61
+ for precision and scale:
62
+
63
+ `rails generate model product price:decimal{10,2}`
64
+
65
+ You can add a `:uniq` or `:index` suffix for unique or standard indexes
66
+ respectively:
66
67
 
67
- `rails generate model user pseudo:string{30}`
68
68
  `rails generate model user pseudo:string:uniq`
69
+ `rails generate model user pseudo:string:index`
70
+
71
+ You can combine any single curly brace option with the index options:
72
+
73
+ `rails generate model user username:string{30}:uniq`
74
+ `rails generate model product supplier:references{polymorphic}:index`
69
75
 
70
76
 
71
77
  Examples:
@@ -94,6 +94,11 @@ task default: :test
94
94
  end
95
95
  end
96
96
 
97
+ def test_dummy_assets
98
+ template "rails/javascripts.js", "#{dummy_path}/app/assets/javascripts/application.js", force: true
99
+ template "rails/stylesheets.css", "#{dummy_path}/app/assets/stylesheets/application.css", force: true
100
+ end
101
+
97
102
  def test_dummy_clean
98
103
  inside dummy_path do
99
104
  remove_file ".gitignore"
@@ -101,8 +106,6 @@ task default: :test
101
106
  remove_file "doc"
102
107
  remove_file "Gemfile"
103
108
  remove_file "lib/tasks"
104
- remove_file "app/assets/images/rails.png"
105
- remove_file "public/index.html"
106
109
  remove_file "public/robots.txt"
107
110
  remove_file "README"
108
111
  remove_file "test"
@@ -112,7 +115,7 @@ task default: :test
112
115
 
113
116
  def stylesheets
114
117
  if mountable?
115
- copy_file "#{app_templates_dir}/app/assets/stylesheets/application.css",
118
+ copy_file "rails/stylesheets.css",
116
119
  "app/assets/stylesheets/#{name}/application.css"
117
120
  elsif full?
118
121
  empty_directory_with_keep_file "app/assets/stylesheets/#{name}"
@@ -123,8 +126,8 @@ task default: :test
123
126
  return if options.skip_javascript?
124
127
 
125
128
  if mountable?
126
- template "#{app_templates_dir}/app/assets/javascripts/application.js.tt",
127
- "app/assets/javascripts/#{name}/application.js"
129
+ template "rails/javascripts.js",
130
+ "app/assets/javascripts/#{name}/application.js"
128
131
  elsif full?
129
132
  empty_directory_with_keep_file "app/assets/javascripts/#{name}"
130
133
  end
@@ -263,6 +266,7 @@ task default: :test
263
266
  build(:generate_test_dummy)
264
267
  store_application_definition!
265
268
  build(:test_dummy_config)
269
+ build(:test_dummy_assets)
266
270
  build(:test_dummy_clean)
267
271
  # ensure that bin/rails has proper dummy_path
268
272
  build(:bin, true)