rails 1.1.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +267 -2
- data/MIT-LICENSE +1 -1
- data/README +62 -63
- data/Rakefile +26 -15
- data/bin/process/inspector +3 -0
- data/configs/databases/frontbase.yml +28 -0
- data/configs/databases/mysql.yml +3 -2
- data/configs/databases/oracle.yml +10 -1
- data/configs/databases/sqlite3.yml +3 -0
- data/configs/lighttpd.conf +1 -0
- data/configs/routes.rb +1 -0
- data/environments/boot.rb +4 -3
- data/environments/environment.rb +9 -2
- data/environments/production.rb +1 -1
- data/helpers/application.rb +5 -2
- data/html/404.html +27 -5
- data/html/500.html +27 -5
- data/html/javascripts/controls.js +41 -23
- data/html/javascripts/dragdrop.js +105 -76
- data/html/javascripts/effects.js +293 -163
- data/html/javascripts/prototype.js +897 -389
- data/lib/breakpoint.rb +31 -1
- data/lib/breakpoint_client.rb +5 -5
- data/lib/code_statistics.rb +1 -1
- data/lib/commands/performance/profiler.rb +25 -9
- data/lib/commands/plugin.rb +69 -23
- data/lib/commands/process/inspector.rb +68 -0
- data/lib/commands/process/reaper.rb +88 -69
- data/lib/commands/process/spawner.rb +148 -33
- data/lib/commands/runner.rb +27 -6
- data/lib/commands/server.rb +18 -9
- data/lib/commands/servers/base.rb +19 -0
- data/lib/commands/servers/lighttpd.rb +20 -18
- data/lib/commands/servers/mongrel.rb +65 -0
- data/lib/console_sandbox.rb +2 -2
- data/lib/dispatcher.rb +67 -11
- data/lib/fcgi_handler.rb +52 -34
- data/lib/initializer.rb +190 -111
- data/lib/rails/version.rb +2 -2
- data/lib/rails_generator/base.rb +82 -24
- data/lib/rails_generator/commands.rb +87 -25
- data/lib/rails_generator/generated_attribute.rb +42 -0
- data/lib/rails_generator/generators/applications/app/app_generator.rb +13 -10
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +1 -2
- data/lib/rails_generator/generators/components/mailer/mailer_generator.rb +10 -8
- data/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +1 -1
- data/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +4 -4
- data/lib/rails_generator/generators/components/mailer/templates/view.rhtml +1 -1
- data/lib/rails_generator/generators/components/migration/templates/migration.rb +1 -1
- data/lib/rails_generator/generators/components/model/USAGE +19 -12
- data/lib/rails_generator/generators/components/model/model_generator.rb +4 -0
- data/lib/rails_generator/generators/components/model/templates/fixtures.yml +8 -2
- data/lib/rails_generator/generators/components/model/templates/migration.rb +3 -1
- data/lib/rails_generator/generators/components/observer/USAGE +15 -0
- data/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
- data/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
- data/lib/rails_generator/generators/components/observer/templates/unit_test.rb +10 -0
- data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +4 -0
- data/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +76 -0
- data/lib/rails_generator/generators/components/resource/templates/USAGE +18 -0
- data/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/fixtures.yml +11 -0
- data/lib/rails_generator/generators/components/resource/templates/functional_test.rb +20 -0
- data/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/migration.rb +13 -0
- data/lib/rails_generator/generators/components/resource/templates/model.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/unit_test.rb +10 -0
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +10 -1
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +11 -7
- data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +5 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +2 -2
- data/lib/rails_generator/generators/components/scaffold_resource/USAGE +29 -0
- data/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +92 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb +79 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/fixtures.yml +11 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/functional_test.rb +57 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml +17 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/migration.rb +13 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/model.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/style.css +74 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/unit_test.rb +10 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml +19 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_index.rhtml +24 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml +18 -0
- data/lib/rails_generator/generators/components/scaffold_resource/templates/view_show.rhtml +10 -0
- data/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +7 -1
- data/lib/rails_generator/generators/components/session_migration/templates/migration.rb +5 -4
- data/lib/rails_generator/lookup.rb +1 -2
- data/lib/rails_generator/options.rb +6 -3
- data/lib/tasks/databases.rake +46 -20
- data/lib/tasks/documentation.rake +1 -0
- data/lib/tasks/framework.rake +1 -3
- data/lib/tasks/pre_namespace_aliases.rake +34 -27
- data/lib/tasks/rails.rb +2 -2
- data/lib/tasks/statistics.rake +6 -5
- data/lib/tasks/testing.rake +28 -13
- data/lib/tasks/tmp.rake +8 -1
- data/lib/test_help.rb +3 -2
- data/lib/webrick_server.rb +6 -8
- metadata +50 -9
@@ -29,8 +29,7 @@ class ControllerGenerator < Rails::Generator::NamedBase
|
|
29
29
|
# View template for each action.
|
30
30
|
actions.each do |action|
|
31
31
|
path = File.join('app/views', class_path, file_name, "#{action}.rhtml")
|
32
|
-
m.template 'view.rhtml',
|
33
|
-
path,
|
32
|
+
m.template 'view.rhtml', path,
|
34
33
|
:assigns => { :action => action, :path => path }
|
35
34
|
end
|
36
35
|
end
|
@@ -6,9 +6,9 @@ class MailerGenerator < Rails::Generator::NamedBase
|
|
6
6
|
|
7
7
|
# Mailer, view, test, and fixture directories.
|
8
8
|
m.directory File.join('app/models', class_path)
|
9
|
-
m.directory File.join('app/views',
|
9
|
+
m.directory File.join('app/views', file_path)
|
10
10
|
m.directory File.join('test/unit', class_path)
|
11
|
-
m.directory File.join('test/fixtures',
|
11
|
+
m.directory File.join('test/fixtures', file_path)
|
12
12
|
|
13
13
|
# Mailer class and unit test.
|
14
14
|
m.template "mailer.rb", File.join('app/models',
|
@@ -20,12 +20,14 @@ class MailerGenerator < Rails::Generator::NamedBase
|
|
20
20
|
|
21
21
|
# View template and fixture for each action.
|
22
22
|
actions.each do |action|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
:assigns => { :action => action }
|
23
|
+
relative_path = File.join(file_path, action)
|
24
|
+
view_path = File.join('app/views', "#{relative_path}.rhtml")
|
25
|
+
fixture_path = File.join('test/fixtures', relative_path)
|
26
|
+
|
27
|
+
m.template "view.rhtml", view_path,
|
28
|
+
:assigns => { :action => action, :path => view_path }
|
29
|
+
m.template "fixture.rhtml", fixture_path,
|
30
|
+
:assigns => { :action => action, :path => view_path }
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
2
|
-
require '<%= file_name %>'
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
|
3
2
|
|
4
3
|
class <%= class_name %>Test < Test::Unit::TestCase
|
5
|
-
FIXTURES_PATH = File.dirname(__FILE__) + '
|
4
|
+
FIXTURES_PATH = File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../fixtures'
|
6
5
|
CHARSET = "utf-8"
|
7
6
|
|
8
7
|
include ActionMailer::Quoting
|
@@ -14,6 +13,7 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
|
14
13
|
|
15
14
|
@expected = TMail::Mail.new
|
16
15
|
@expected.set_content_type "text", "plain", { "charset" => CHARSET }
|
16
|
+
@expected.mime_version = '1.0'
|
17
17
|
end
|
18
18
|
|
19
19
|
<% for action in actions -%>
|
@@ -28,7 +28,7 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
|
28
28
|
<% end -%>
|
29
29
|
private
|
30
30
|
def read_fixture(action)
|
31
|
-
IO.readlines("#{FIXTURES_PATH}/<%=
|
31
|
+
IO.readlines("#{FIXTURES_PATH}/<%= file_path %>/#{action}")
|
32
32
|
end
|
33
33
|
|
34
34
|
def encode(subject)
|
@@ -1,19 +1,26 @@
|
|
1
1
|
Description:
|
2
2
|
The model generator creates stubs for a new model.
|
3
3
|
|
4
|
-
The generator takes a model name as its argument. The model name may be
|
5
|
-
|
4
|
+
The generator takes a model name as its argument. The model name may be given in CamelCase or under_score and
|
5
|
+
should not be suffixed with 'Model'.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
As additional parameters, the generator will take attribute pairs described by name and type. These attributes will
|
8
|
+
be used to prepopulate the migration to create the table for the model and give you a set of predefined fixture.
|
9
|
+
You don't have to think up all attributes up front, but it's a good idea of adding just the baseline of what's
|
10
|
+
needed to start really working with the resource.
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
The generator creates a model class in app/models, a test suite in test/unit, test fixtures in
|
13
|
+
test/fixtures/singular_name.yml, and a migration in db/migrate.
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
Test: test/unit/account_test.rb
|
17
|
-
Fixtures: test/fixtures/accounts.yml
|
18
|
-
Migration: db/migrate/XXX_add_accounts.rb
|
15
|
+
Examples:
|
16
|
+
./script/generate model account
|
19
17
|
|
18
|
+
This will create an Account model:
|
19
|
+
Model: app/models/account.rb
|
20
|
+
Test: test/unit/account_test.rb
|
21
|
+
Fixtures: test/fixtures/accounts.yml
|
22
|
+
Migration: db/migrate/XXX_add_accounts.rb
|
23
|
+
|
24
|
+
./script/generate model post title:string created_on:date body:text published:boolean
|
25
|
+
|
26
|
+
Creates post model with predefined attributes.
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
|
2
|
+
one:
|
3
3
|
id: 1
|
4
|
-
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
<%= attribute.name %>: <%= attribute.default %>
|
6
|
+
<% end -%>
|
7
|
+
two:
|
5
8
|
id: 2
|
9
|
+
<% for attribute in attributes -%>
|
10
|
+
<%= attribute.name %>: <%= attribute.default %>
|
11
|
+
<% end -%>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Description:
|
2
|
+
The observer generator creates stubs for a new observer.
|
3
|
+
|
4
|
+
The generator takes a observer name as its argument. The observer name may be
|
5
|
+
given in CamelCase or under_score and should not be suffixed with 'Observer'.
|
6
|
+
|
7
|
+
The generator creates a observer class in app/models and a test suite in
|
8
|
+
test/unit.
|
9
|
+
|
10
|
+
Example:
|
11
|
+
./script/generate observer Account
|
12
|
+
|
13
|
+
This will create an Account observer:
|
14
|
+
Observer: app/models/account_observer.rb
|
15
|
+
Test: test/unit/account_observer_test.rb
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ObserverGenerator < Rails::Generator::NamedBase
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
# Check for class naming collisions.
|
5
|
+
m.class_collisions class_path, "#{class_name}Observer", "#{class_name}ObserverTest"
|
6
|
+
|
7
|
+
# Observer, and test directories.
|
8
|
+
m.directory File.join('app/models', class_path)
|
9
|
+
m.directory File.join('test/unit', class_path)
|
10
|
+
|
11
|
+
# Observer class and unit test fixtures.
|
12
|
+
m.template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
|
13
|
+
m.template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
|
2
|
+
|
3
|
+
class <%= class_name %>ObserverTest < Test::Unit::TestCase
|
4
|
+
fixtures :<%= table_name %>
|
5
|
+
|
6
|
+
# Replace this with your real tests.
|
7
|
+
def test_truth
|
8
|
+
assert true
|
9
|
+
end
|
10
|
+
end
|
@@ -9,6 +9,9 @@ class PluginGenerator < Rails::Generator::NamedBase
|
|
9
9
|
|
10
10
|
def manifest
|
11
11
|
record do |m|
|
12
|
+
# Check for class naming collisions.
|
13
|
+
m.class_collisions class_path, class_name
|
14
|
+
|
12
15
|
m.directory "#{plugin_path}/lib"
|
13
16
|
m.directory "#{plugin_path}/tasks"
|
14
17
|
m.directory "#{plugin_path}/test"
|
@@ -17,6 +20,7 @@ class PluginGenerator < Rails::Generator::NamedBase
|
|
17
20
|
m.template 'Rakefile', "#{plugin_path}/Rakefile"
|
18
21
|
m.template 'init.rb', "#{plugin_path}/init.rb"
|
19
22
|
m.template 'install.rb', "#{plugin_path}/install.rb"
|
23
|
+
m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb"
|
20
24
|
m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb"
|
21
25
|
m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake"
|
22
26
|
m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb"
|
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
@@ -0,0 +1,76 @@
|
|
1
|
+
class ResourceGenerator < Rails::Generator::NamedBase
|
2
|
+
attr_reader :controller_name,
|
3
|
+
:controller_class_path,
|
4
|
+
:controller_file_path,
|
5
|
+
:controller_class_nesting,
|
6
|
+
:controller_class_nesting_depth,
|
7
|
+
:controller_class_name,
|
8
|
+
:controller_singular_name,
|
9
|
+
:controller_plural_name
|
10
|
+
alias_method :controller_file_name, :controller_singular_name
|
11
|
+
alias_method :controller_table_name, :controller_plural_name
|
12
|
+
|
13
|
+
def initialize(runtime_args, runtime_options = {})
|
14
|
+
super
|
15
|
+
|
16
|
+
@controller_name = @name.pluralize
|
17
|
+
|
18
|
+
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
19
|
+
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
|
20
|
+
|
21
|
+
if @controller_class_nesting.empty?
|
22
|
+
@controller_class_name = @controller_class_name_without_nesting
|
23
|
+
else
|
24
|
+
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def manifest
|
29
|
+
record do |m|
|
30
|
+
# Check for class naming collisions.
|
31
|
+
m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
|
32
|
+
m.class_collisions(class_path, "#{class_name}")
|
33
|
+
|
34
|
+
# Controller, helper, views, and test directories.
|
35
|
+
m.directory(File.join('app/models', class_path))
|
36
|
+
m.directory(File.join('app/controllers', controller_class_path))
|
37
|
+
m.directory(File.join('app/helpers', controller_class_path))
|
38
|
+
m.directory(File.join('app/views', controller_class_path, controller_file_name))
|
39
|
+
m.directory(File.join('test/functional', controller_class_path))
|
40
|
+
m.directory(File.join('test/unit', class_path))
|
41
|
+
|
42
|
+
m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb"))
|
43
|
+
|
44
|
+
m.template(
|
45
|
+
'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
|
46
|
+
)
|
47
|
+
|
48
|
+
m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
|
49
|
+
m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
|
50
|
+
m.template('unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb"))
|
51
|
+
m.template('fixtures.yml', File.join('test/fixtures', "#{table_name}.yml"))
|
52
|
+
|
53
|
+
unless options[:skip_migration]
|
54
|
+
m.migration_template(
|
55
|
+
'migration.rb', 'db/migrate',
|
56
|
+
:assigns => {
|
57
|
+
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}",
|
58
|
+
:attributes => attributes
|
59
|
+
},
|
60
|
+
:migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
m.route_resources controller_file_name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
def banner
|
70
|
+
"Usage: #{$0} resource ModelName [field:type, field:type]"
|
71
|
+
end
|
72
|
+
|
73
|
+
def model_name
|
74
|
+
class_name.demodulize
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Description:
|
2
|
+
The resource generator creates an empty model and controller for use in a REST-friendly, resource-oriented
|
3
|
+
application. Say you want to a resource called post. Normally, you could just call "script/generate model post" and
|
4
|
+
"script/generate controller posts". This generator basically just collapses these two generators into one step.
|
5
|
+
|
6
|
+
The generator takes the name of the model as its first argument. This model name is then pluralized to get the
|
7
|
+
controller name. So "resource post" will generate a Post model and a PostsController and will be intended
|
8
|
+
for URLs like /posts and /posts/45.
|
9
|
+
|
10
|
+
As additional parameters, the generator will take attribute pairs described by name and type. These attributes will
|
11
|
+
be used to prepopulate the migration to create the table for the model and give you a set of predefined fixture.
|
12
|
+
You don't have to think up all attributes up front, but it's a good idea of adding just the baseline of what's
|
13
|
+
needed to start really working with the resource.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
./script/generate resource post
|
17
|
+
./script/generate resource post title:string created_on:date body:text published:boolean
|
18
|
+
./script/generate resource purchase order_id:integer created_at:datetime amount:decimal
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
one:
|
3
|
+
id: 1
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
<%= attribute.name %>: <%= attribute.default %>
|
6
|
+
<% end -%>
|
7
|
+
two:
|
8
|
+
id: 2
|
9
|
+
<% for attribute in attributes -%>
|
10
|
+
<%= attribute.name %>: <%= attribute.default %>
|
11
|
+
<% end -%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../test_helper'
|
2
|
+
require '<%= controller_file_path %>_controller'
|
3
|
+
|
4
|
+
# Re-raise errors caught by the controller.
|
5
|
+
class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
|
6
|
+
|
7
|
+
class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
8
|
+
fixtures :<%= table_name %>
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@controller = <%= controller_class_name %>Controller.new
|
12
|
+
@request = ActionController::TestRequest.new
|
13
|
+
@response = ActionController::TestResponse.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# Replace this with your real tests.
|
17
|
+
def test_truth
|
18
|
+
assert true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= table_name %> do |t|
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
t.column :<%= attribute.name %>, :<%= attribute.type %>
|
6
|
+
<% end -%>
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.down
|
11
|
+
drop_table :<%= table_name %>
|
12
|
+
end
|
13
|
+
end
|
@@ -30,6 +30,10 @@ class ActionView::Helpers::InstanceTag
|
|
30
30
|
def to_datetime_select_tag(options = {})
|
31
31
|
"<%= datetime_select '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+ options.inspect} %>"
|
32
32
|
end
|
33
|
+
|
34
|
+
def to_time_select_tag(options = {})
|
35
|
+
"<%= time_select '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+ options.inspect} %>"
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
class ScaffoldGenerator < Rails::Generator::NamedBase
|
@@ -70,6 +74,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
70
74
|
m.directory File.join('app/controllers', controller_class_path)
|
71
75
|
m.directory File.join('app/helpers', controller_class_path)
|
72
76
|
m.directory File.join('app/views', controller_class_path, controller_file_name)
|
77
|
+
m.directory File.join('app/views/layouts', controller_class_path)
|
73
78
|
m.directory File.join('test/functional', controller_class_path)
|
74
79
|
|
75
80
|
# Depend on model generator but skip if the model exists.
|
@@ -115,7 +120,11 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
115
120
|
"#{controller_file_name}_helper.rb")
|
116
121
|
|
117
122
|
# Layout and stylesheet.
|
118
|
-
m.template 'layout.rhtml',
|
123
|
+
m.template 'layout.rhtml',
|
124
|
+
File.join('app/views/layouts',
|
125
|
+
controller_class_path,
|
126
|
+
"#{controller_file_name}.rhtml")
|
127
|
+
|
119
128
|
m.template 'style.css', 'public/stylesheets/scaffold.css'
|
120
129
|
|
121
130
|
|
@@ -11,6 +11,8 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
|
11
11
|
@controller = <%= controller_class_name %>Controller.new
|
12
12
|
@request = ActionController::TestRequest.new
|
13
13
|
@response = ActionController::TestResponse.new
|
14
|
+
|
15
|
+
@first_id = <%= plural_name %>(:first).id
|
14
16
|
end
|
15
17
|
|
16
18
|
<% for action in unscaffolded_actions -%>
|
@@ -39,7 +41,7 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def test_show<%= suffix %>
|
42
|
-
get :show<%= suffix %>, :id =>
|
44
|
+
get :show<%= suffix %>, :id => @first_id
|
43
45
|
|
44
46
|
assert_response :success
|
45
47
|
assert_template 'show'
|
@@ -69,7 +71,7 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
|
69
71
|
end
|
70
72
|
|
71
73
|
def test_edit<%= suffix %>
|
72
|
-
get :edit<%= suffix %>, :id =>
|
74
|
+
get :edit<%= suffix %>, :id => @first_id
|
73
75
|
|
74
76
|
assert_response :success
|
75
77
|
assert_template 'edit<%= suffix %>'
|
@@ -79,20 +81,22 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
|
79
81
|
end
|
80
82
|
|
81
83
|
def test_update<%= suffix %>
|
82
|
-
post :update<%= suffix %>, :id =>
|
84
|
+
post :update<%= suffix %>, :id => @first_id
|
83
85
|
assert_response :redirect
|
84
|
-
assert_redirected_to :action => 'show<%= suffix %>', :id =>
|
86
|
+
assert_redirected_to :action => 'show<%= suffix %>', :id => @first_id
|
85
87
|
end
|
86
88
|
|
87
89
|
def test_destroy<%= suffix %>
|
88
|
-
|
90
|
+
assert_nothing_raised {
|
91
|
+
<%= model_name %>.find(@first_id)
|
92
|
+
}
|
89
93
|
|
90
|
-
post :destroy, :id =>
|
94
|
+
post :destroy, :id => @first_id
|
91
95
|
assert_response :redirect
|
92
96
|
assert_redirected_to :action => 'list<%= suffix %>'
|
93
97
|
|
94
98
|
assert_raise(ActiveRecord::RecordNotFound) {
|
95
|
-
<%= model_name %>.find(
|
99
|
+
<%= model_name %>.find(@first_id)
|
96
100
|
}
|
97
101
|
end
|
98
102
|
end
|