view_mapper 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -2
- data/VERSION +1 -1
- data/generators/scaffold_for_view/scaffold_for_view_generator.rb +2 -6
- data/generators/view_for/view_for_generator.rb +1 -5
- data/lib/view_mapper/{has_many_view.rb → has_many_child_models.rb} +33 -37
- data/lib/view_mapper/model_info.rb +8 -0
- data/lib/view_mapper/view_mapper.rb +15 -2
- data/lib/view_mapper/views/auto_complete/auto_complete_view.rb +77 -0
- data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/controller.rb +3 -1
- data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/layout.html.erb +0 -0
- data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/view_edit.html.erb +1 -1
- data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/view_new.html.erb +1 -1
- data/lib/view_mapper/views/has_many/has_many_view.rb +28 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/helper.rb +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/layout.html.erb +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/model.rb +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/nested_attributes.js +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/style.css +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_child_form.html.erb +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_edit.html.erb +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_form.html.erb +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_new.html.erb +0 -0
- data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_show.html.erb +0 -0
- data/lib/view_mapper/{paperclip_view.rb → views/paperclip/paperclip_view.rb} +6 -2
- data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/migration.rb +1 -1
- data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/model.rb +0 -0
- data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/view_edit.html.erb +0 -0
- data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/view_new.html.erb +0 -0
- data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/view_show.html.erb +0 -0
- data/lib/view_mapper.rb +4 -3
- data/test/{fake → generators/fake}/fake_generator.rb +0 -0
- data/test/generators/fake/templates/fake_template1.html.erb +1 -0
- data/test/generators/fake/templates/fake_template2.html.erb +1 -0
- data/test/{scaffold_for_view_generator_test.rb → generators/scaffold_for_view/scaffold_for_view_generator_test.rb} +2 -2
- data/test/{view_for_generator_test.rb → generators/view_for/view_for_generator_test.rb} +0 -0
- data/test/model_info_test.rb +12 -3
- data/test/test_helper.rb +12 -8
- data/test/view_mapper_test.rb +13 -2
- data/test/{auto_complete_test.rb → views/auto_complete/auto_complete_test.rb} +63 -40
- data/test/{expected_templates/auto_complete/index.html.erb → views/auto_complete/expected_templates/actual_index} +2 -0
- data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/edit.html.erb +7 -3
- data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/expected_routes.rb +0 -0
- data/test/{expected_templates/paperclip → views/auto_complete/expected_templates}/index.html.erb +3 -1
- data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/new.html.erb +7 -3
- data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/show.html.erb +6 -1
- data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/standard_routes.rb +0 -0
- data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/testies.html.erb +0 -0
- data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/testies_controller.rb +2 -1
- data/test/views/fake/fake_view.rb +7 -0
- data/test/views/fake/templates/fake_template1.html.erb +1 -0
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/_form.html.erb +0 -0
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/_person.html.erb +4 -0
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/create_parents.rb +4 -3
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/edit.html.erb +0 -0
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/index.html.erb +1 -1
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/new.html.erb +0 -0
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/parent.rb +2 -1
- data/test/{expected_templates/has_many → views/has_many/expected_templates}/show.html.erb +4 -0
- data/test/{has_many_view_test.rb → views/has_many/has_many_view_test.rb} +17 -17
- data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/create_testies.rb +4 -3
- data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/edit.html.erb +4 -0
- data/test/views/paperclip/expected_templates/index.html.erb +26 -0
- data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/new.html.erb +4 -0
- data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/show.html.erb +5 -0
- data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/testy.rb +0 -0
- data/test/{paperclip_view_test.rb → views/paperclip/paperclip_view_test.rb} +17 -9
- data/view_mapper.gemspec +77 -124
- metadata +72 -120
- data/lib/view_mapper/auto_complete_templates/functional_test.rb +0 -45
- data/lib/view_mapper/auto_complete_templates/helper.rb +0 -2
- data/lib/view_mapper/auto_complete_templates/helper_test.rb +0 -4
- data/lib/view_mapper/auto_complete_templates/style.css +0 -54
- data/lib/view_mapper/auto_complete_templates/view_index.html.erb +0 -24
- data/lib/view_mapper/auto_complete_templates/view_show.html.erb +0 -10
- data/lib/view_mapper/auto_complete_view.rb +0 -44
- data/lib/view_mapper/has_many_templates/controller.rb +0 -85
- data/lib/view_mapper/has_many_templates/fixtures.yml +0 -19
- data/lib/view_mapper/has_many_templates/functional_test.rb +0 -45
- data/lib/view_mapper/has_many_templates/helper_test.rb +0 -4
- data/lib/view_mapper/has_many_templates/migration.rb +0 -16
- data/lib/view_mapper/has_many_templates/unit_test.rb +0 -8
- data/lib/view_mapper/has_many_templates/view_index.html.erb +0 -24
- data/lib/view_mapper/paperclip_templates/controller.rb +0 -85
- data/lib/view_mapper/paperclip_templates/fixtures.yml +0 -19
- data/lib/view_mapper/paperclip_templates/functional_test.rb +0 -45
- data/lib/view_mapper/paperclip_templates/helper.rb +0 -2
- data/lib/view_mapper/paperclip_templates/helper_test.rb +0 -4
- data/lib/view_mapper/paperclip_templates/layout.html.erb +0 -17
- data/lib/view_mapper/paperclip_templates/style.css +0 -54
- data/lib/view_mapper/paperclip_templates/unit_test.rb +0 -8
- data/lib/view_mapper/paperclip_templates/view_index.html.erb +0 -24
- data/test/database.yml +0 -3
- data/test/fake_view.rb +0 -7
- data/test/rails_generator/base.rb +0 -266
- data/test/rails_generator/commands.rb +0 -621
- data/test/rails_generator/generated_attribute.rb +0 -46
- data/test/rails_generator/generators/components/model/model_generator.rb +0 -45
- data/test/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -102
- data/test/rails_generator/lookup.rb +0 -249
- data/test/rails_generator/manifest.rb +0 -53
- data/test/rails_generator/options.rb +0 -150
- data/test/rails_generator/scripts/destroy.rb +0 -29
- data/test/rails_generator/scripts/generate.rb +0 -7
- data/test/rails_generator/scripts/update.rb +0 -12
- data/test/rails_generator/scripts.rb +0 -89
- data/test/rails_generator/secret_key_generator.rb +0 -24
- data/test/rails_generator/simple_logger.rb +0 -46
- data/test/rails_generator/spec.rb +0 -44
@@ -1,44 +0,0 @@
|
|
1
|
-
module ViewMapper
|
2
|
-
module AutoCompleteView
|
3
|
-
|
4
|
-
def source_root_for_view
|
5
|
-
File.dirname(__FILE__) + "/auto_complete_templates"
|
6
|
-
end
|
7
|
-
|
8
|
-
def manifest
|
9
|
-
manifest = super
|
10
|
-
if @valid
|
11
|
-
manifest.route :name => 'connect',
|
12
|
-
:path => auto_complete_for_method,
|
13
|
-
:controller => controller_file_name,
|
14
|
-
:action => auto_complete_for_method
|
15
|
-
end
|
16
|
-
manifest
|
17
|
-
end
|
18
|
-
|
19
|
-
def auto_complete_for_method
|
20
|
-
"auto_complete_for_#{singular_name}_#{auto_complete_attribute}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def auto_complete_attribute
|
24
|
-
view_param
|
25
|
-
end
|
26
|
-
|
27
|
-
def validate
|
28
|
-
super
|
29
|
-
@valid &&= validate_auto_complete_attribute
|
30
|
-
end
|
31
|
-
|
32
|
-
def validate_auto_complete_attribute
|
33
|
-
if auto_complete_attribute.nil?
|
34
|
-
logger.error "No auto_complete attribute specified."
|
35
|
-
return false
|
36
|
-
elsif attributes.find { |a| a.name == auto_complete_attribute }.nil?
|
37
|
-
logger.error "Field '#{auto_complete_attribute}' does not exist."
|
38
|
-
return false
|
39
|
-
end
|
40
|
-
true
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
-
# GET /<%= table_name %>
|
3
|
-
# GET /<%= table_name %>.xml
|
4
|
-
def index
|
5
|
-
@<%= table_name %> = <%= class_name %>.all
|
6
|
-
|
7
|
-
respond_to do |format|
|
8
|
-
format.html # index.html.erb
|
9
|
-
format.xml { render :xml => @<%= table_name %> }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# GET /<%= table_name %>/1
|
14
|
-
# GET /<%= table_name %>/1.xml
|
15
|
-
def show
|
16
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
17
|
-
|
18
|
-
respond_to do |format|
|
19
|
-
format.html # show.html.erb
|
20
|
-
format.xml { render :xml => @<%= file_name %> }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# GET /<%= table_name %>/new
|
25
|
-
# GET /<%= table_name %>/new.xml
|
26
|
-
def new
|
27
|
-
@<%= file_name %> = <%= class_name %>.new
|
28
|
-
|
29
|
-
respond_to do |format|
|
30
|
-
format.html # new.html.erb
|
31
|
-
format.xml { render :xml => @<%= file_name %> }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# GET /<%= table_name %>/1/edit
|
36
|
-
def edit
|
37
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
38
|
-
end
|
39
|
-
|
40
|
-
# POST /<%= table_name %>
|
41
|
-
# POST /<%= table_name %>.xml
|
42
|
-
def create
|
43
|
-
@<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
|
44
|
-
|
45
|
-
respond_to do |format|
|
46
|
-
if @<%= file_name %>.save
|
47
|
-
flash[:notice] = '<%= class_name %> was successfully created.'
|
48
|
-
format.html { redirect_to(@<%= file_name %>) }
|
49
|
-
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
|
50
|
-
else
|
51
|
-
format.html { render :action => "new" }
|
52
|
-
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# PUT /<%= table_name %>/1
|
58
|
-
# PUT /<%= table_name %>/1.xml
|
59
|
-
def update
|
60
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
61
|
-
|
62
|
-
respond_to do |format|
|
63
|
-
if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
|
64
|
-
flash[:notice] = '<%= class_name %> was successfully updated.'
|
65
|
-
format.html { redirect_to(@<%= file_name %>) }
|
66
|
-
format.xml { head :ok }
|
67
|
-
else
|
68
|
-
format.html { render :action => "edit" }
|
69
|
-
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# DELETE /<%= table_name %>/1
|
75
|
-
# DELETE /<%= table_name %>/1.xml
|
76
|
-
def destroy
|
77
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
78
|
-
@<%= file_name %>.destroy
|
79
|
-
|
80
|
-
respond_to do |format|
|
81
|
-
format.html { redirect_to(<%= table_name %>_url) }
|
82
|
-
format.xml { head :ok }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
|
3
|
-
<% unless attributes.empty? -%>
|
4
|
-
one:
|
5
|
-
<% for attribute in attributes -%>
|
6
|
-
<%= attribute.name %>: <%= attribute.default %>
|
7
|
-
<% end -%>
|
8
|
-
|
9
|
-
two:
|
10
|
-
<% for attribute in attributes -%>
|
11
|
-
<%= attribute.name %>: <%= attribute.default %>
|
12
|
-
<% end -%>
|
13
|
-
<% else -%>
|
14
|
-
# one:
|
15
|
-
# column: value
|
16
|
-
#
|
17
|
-
# two:
|
18
|
-
# column: value
|
19
|
-
<% end -%>
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
4
|
-
test "should get index" do
|
5
|
-
get :index
|
6
|
-
assert_response :success
|
7
|
-
assert_not_nil assigns(:<%= table_name %>)
|
8
|
-
end
|
9
|
-
|
10
|
-
test "should get new" do
|
11
|
-
get :new
|
12
|
-
assert_response :success
|
13
|
-
end
|
14
|
-
|
15
|
-
test "should create <%= file_name %>" do
|
16
|
-
assert_difference('<%= class_name %>.count') do
|
17
|
-
post :create, :<%= file_name %> => { }
|
18
|
-
end
|
19
|
-
|
20
|
-
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
21
|
-
end
|
22
|
-
|
23
|
-
test "should show <%= file_name %>" do
|
24
|
-
get :show, :id => <%= table_name %>(:one).to_param
|
25
|
-
assert_response :success
|
26
|
-
end
|
27
|
-
|
28
|
-
test "should get edit" do
|
29
|
-
get :edit, :id => <%= table_name %>(:one).to_param
|
30
|
-
assert_response :success
|
31
|
-
end
|
32
|
-
|
33
|
-
test "should update <%= file_name %>" do
|
34
|
-
put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
|
35
|
-
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
36
|
-
end
|
37
|
-
|
38
|
-
test "should destroy <%= file_name %>" do
|
39
|
-
assert_difference('<%= class_name %>.count', -1) do
|
40
|
-
delete :destroy, :id => <%= table_name %>(:one).to_param
|
41
|
-
end
|
42
|
-
|
43
|
-
assert_redirected_to <%= table_name %>_path
|
44
|
-
end
|
45
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :<%= table_name %> do |t|
|
4
|
-
<% for attribute in attributes -%>
|
5
|
-
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
-
<% end -%>
|
7
|
-
<% unless options[:skip_timestamps] %>
|
8
|
-
t.timestamps
|
9
|
-
<% end -%>
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.down
|
14
|
-
drop_table :<%= table_name %>
|
15
|
-
end
|
16
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<h1>Listing <%= plural_name %></h1>
|
2
|
-
|
3
|
-
<table>
|
4
|
-
<tr>
|
5
|
-
<% for attribute in attributes -%>
|
6
|
-
<th><%= attribute.column.human_name %></th>
|
7
|
-
<% end -%>
|
8
|
-
</tr>
|
9
|
-
|
10
|
-
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
|
11
|
-
<tr>
|
12
|
-
<% for attribute in attributes -%>
|
13
|
-
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
|
-
<% end -%>
|
15
|
-
<td><%%= link_to 'Show', <%= singular_name %> %></td>
|
16
|
-
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
17
|
-
<td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
18
|
-
</tr>
|
19
|
-
<%% end %>
|
20
|
-
</table>
|
21
|
-
|
22
|
-
<br />
|
23
|
-
|
24
|
-
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
@@ -1,85 +0,0 @@
|
|
1
|
-
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
-
# GET /<%= table_name %>
|
3
|
-
# GET /<%= table_name %>.xml
|
4
|
-
def index
|
5
|
-
@<%= table_name %> = <%= class_name %>.all
|
6
|
-
|
7
|
-
respond_to do |format|
|
8
|
-
format.html # index.html.erb
|
9
|
-
format.xml { render :xml => @<%= table_name %> }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# GET /<%= table_name %>/1
|
14
|
-
# GET /<%= table_name %>/1.xml
|
15
|
-
def show
|
16
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
17
|
-
|
18
|
-
respond_to do |format|
|
19
|
-
format.html # show.html.erb
|
20
|
-
format.xml { render :xml => @<%= file_name %> }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# GET /<%= table_name %>/new
|
25
|
-
# GET /<%= table_name %>/new.xml
|
26
|
-
def new
|
27
|
-
@<%= file_name %> = <%= class_name %>.new
|
28
|
-
|
29
|
-
respond_to do |format|
|
30
|
-
format.html # new.html.erb
|
31
|
-
format.xml { render :xml => @<%= file_name %> }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# GET /<%= table_name %>/1/edit
|
36
|
-
def edit
|
37
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
38
|
-
end
|
39
|
-
|
40
|
-
# POST /<%= table_name %>
|
41
|
-
# POST /<%= table_name %>.xml
|
42
|
-
def create
|
43
|
-
@<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
|
44
|
-
|
45
|
-
respond_to do |format|
|
46
|
-
if @<%= file_name %>.save
|
47
|
-
flash[:notice] = '<%= class_name %> was successfully created.'
|
48
|
-
format.html { redirect_to(@<%= file_name %>) }
|
49
|
-
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
|
50
|
-
else
|
51
|
-
format.html { render :action => "new" }
|
52
|
-
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# PUT /<%= table_name %>/1
|
58
|
-
# PUT /<%= table_name %>/1.xml
|
59
|
-
def update
|
60
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
61
|
-
|
62
|
-
respond_to do |format|
|
63
|
-
if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
|
64
|
-
flash[:notice] = '<%= class_name %> was successfully updated.'
|
65
|
-
format.html { redirect_to(@<%= file_name %>) }
|
66
|
-
format.xml { head :ok }
|
67
|
-
else
|
68
|
-
format.html { render :action => "edit" }
|
69
|
-
format.xml { render :xml => @<%= file_name %>.errors, :status => :unprocessable_entity }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# DELETE /<%= table_name %>/1
|
75
|
-
# DELETE /<%= table_name %>/1.xml
|
76
|
-
def destroy
|
77
|
-
@<%= file_name %> = <%= class_name %>.find(params[:id])
|
78
|
-
@<%= file_name %>.destroy
|
79
|
-
|
80
|
-
respond_to do |format|
|
81
|
-
format.html { redirect_to(<%= table_name %>_url) }
|
82
|
-
format.xml { head :ok }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
|
3
|
-
<% unless attributes.empty? -%>
|
4
|
-
one:
|
5
|
-
<% for attribute in attributes -%>
|
6
|
-
<%= attribute.name %>: <%= attribute.default %>
|
7
|
-
<% end -%>
|
8
|
-
|
9
|
-
two:
|
10
|
-
<% for attribute in attributes -%>
|
11
|
-
<%= attribute.name %>: <%= attribute.default %>
|
12
|
-
<% end -%>
|
13
|
-
<% else -%>
|
14
|
-
# one:
|
15
|
-
# column: value
|
16
|
-
#
|
17
|
-
# two:
|
18
|
-
# column: value
|
19
|
-
<% end -%>
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
4
|
-
test "should get index" do
|
5
|
-
get :index
|
6
|
-
assert_response :success
|
7
|
-
assert_not_nil assigns(:<%= table_name %>)
|
8
|
-
end
|
9
|
-
|
10
|
-
test "should get new" do
|
11
|
-
get :new
|
12
|
-
assert_response :success
|
13
|
-
end
|
14
|
-
|
15
|
-
test "should create <%= file_name %>" do
|
16
|
-
assert_difference('<%= class_name %>.count') do
|
17
|
-
post :create, :<%= file_name %> => { }
|
18
|
-
end
|
19
|
-
|
20
|
-
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
21
|
-
end
|
22
|
-
|
23
|
-
test "should show <%= file_name %>" do
|
24
|
-
get :show, :id => <%= table_name %>(:one).to_param
|
25
|
-
assert_response :success
|
26
|
-
end
|
27
|
-
|
28
|
-
test "should get edit" do
|
29
|
-
get :edit, :id => <%= table_name %>(:one).to_param
|
30
|
-
assert_response :success
|
31
|
-
end
|
32
|
-
|
33
|
-
test "should update <%= file_name %>" do
|
34
|
-
put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
|
35
|
-
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
36
|
-
end
|
37
|
-
|
38
|
-
test "should destroy <%= file_name %>" do
|
39
|
-
assert_difference('<%= class_name %>.count', -1) do
|
40
|
-
delete :destroy, :id => <%= table_name %>(:one).to_param
|
41
|
-
end
|
42
|
-
|
43
|
-
assert_redirected_to <%= table_name %>_path
|
44
|
-
end
|
45
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
|
4
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
-
<head>
|
6
|
-
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
-
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
8
|
-
<%%= stylesheet_link_tag 'scaffold' %>
|
9
|
-
</head>
|
10
|
-
<body>
|
11
|
-
|
12
|
-
<p style="color: green"><%%= flash[:notice] %></p>
|
13
|
-
|
14
|
-
<%%= yield %>
|
15
|
-
|
16
|
-
</body>
|
17
|
-
</html>
|
@@ -1,54 +0,0 @@
|
|
1
|
-
body { background-color: #fff; color: #333; }
|
2
|
-
|
3
|
-
body, p, ol, ul, td {
|
4
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
-
font-size: 13px;
|
6
|
-
line-height: 18px;
|
7
|
-
}
|
8
|
-
|
9
|
-
pre {
|
10
|
-
background-color: #eee;
|
11
|
-
padding: 10px;
|
12
|
-
font-size: 11px;
|
13
|
-
}
|
14
|
-
|
15
|
-
a { color: #000; }
|
16
|
-
a:visited { color: #666; }
|
17
|
-
a:hover { color: #fff; background-color:#000; }
|
18
|
-
|
19
|
-
.fieldWithErrors {
|
20
|
-
padding: 2px;
|
21
|
-
background-color: red;
|
22
|
-
display: table;
|
23
|
-
}
|
24
|
-
|
25
|
-
#errorExplanation {
|
26
|
-
width: 400px;
|
27
|
-
border: 2px solid red;
|
28
|
-
padding: 7px;
|
29
|
-
padding-bottom: 12px;
|
30
|
-
margin-bottom: 20px;
|
31
|
-
background-color: #f0f0f0;
|
32
|
-
}
|
33
|
-
|
34
|
-
#errorExplanation h2 {
|
35
|
-
text-align: left;
|
36
|
-
font-weight: bold;
|
37
|
-
padding: 5px 5px 5px 15px;
|
38
|
-
font-size: 12px;
|
39
|
-
margin: -7px;
|
40
|
-
background-color: #c00;
|
41
|
-
color: #fff;
|
42
|
-
}
|
43
|
-
|
44
|
-
#errorExplanation p {
|
45
|
-
color: #333;
|
46
|
-
margin-bottom: 0;
|
47
|
-
padding: 5px;
|
48
|
-
}
|
49
|
-
|
50
|
-
#errorExplanation ul li {
|
51
|
-
font-size: 12px;
|
52
|
-
list-style: square;
|
53
|
-
}
|
54
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
<h1>Listing <%= plural_name %></h1>
|
2
|
-
|
3
|
-
<table>
|
4
|
-
<tr>
|
5
|
-
<% for attribute in attributes -%>
|
6
|
-
<th><%= attribute.column.human_name %></th>
|
7
|
-
<% end -%>
|
8
|
-
</tr>
|
9
|
-
|
10
|
-
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
|
11
|
-
<tr>
|
12
|
-
<% for attribute in attributes -%>
|
13
|
-
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
|
-
<% end -%>
|
15
|
-
<td><%%= link_to 'Show', <%= singular_name %> %></td>
|
16
|
-
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
17
|
-
<td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
18
|
-
</tr>
|
19
|
-
<%% end %>
|
20
|
-
</table>
|
21
|
-
|
22
|
-
<br />
|
23
|
-
|
24
|
-
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
data/test/database.yml
DELETED