focus-generator 0.0.1
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.
- data/Gemfile +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +109 -0
- data/Rakefile +10 -0
- data/features/fcus_authentication.feature +80 -0
- data/features/fcus_config.feature +17 -0
- data/features/fcus_layout.feature +20 -0
- data/features/fcus_scaffold.feature +80 -0
- data/features/step_definitions/common_steps.rb +62 -0
- data/features/step_definitions/rails_setup_steps.rb +6 -0
- data/features/support/env.rb +6 -0
- data/features/support/matchers.rb +7 -0
- data/lib/generators/fcus.rb +28 -0
- data/lib/generators/fcus/authentication/USAGE +50 -0
- data/lib/generators/fcus/authentication/authentication_generator.rb +154 -0
- data/lib/generators/fcus/authentication/templates/authlogic_session.rb +2 -0
- data/lib/generators/fcus/authentication/templates/controller_authentication.rb +60 -0
- data/lib/generators/fcus/authentication/templates/fixtures.yml +24 -0
- data/lib/generators/fcus/authentication/templates/migration.rb +20 -0
- data/lib/generators/fcus/authentication/templates/sessions_controller.rb +41 -0
- data/lib/generators/fcus/authentication/templates/sessions_helper.rb +2 -0
- data/lib/generators/fcus/authentication/templates/tests/rspec/sessions_controller.rb +39 -0
- data/lib/generators/fcus/authentication/templates/tests/rspec/user.rb +83 -0
- data/lib/generators/fcus/authentication/templates/tests/rspec/users_controller.rb +56 -0
- data/lib/generators/fcus/authentication/templates/tests/shoulda/sessions_controller.rb +40 -0
- data/lib/generators/fcus/authentication/templates/tests/shoulda/user.rb +85 -0
- data/lib/generators/fcus/authentication/templates/tests/shoulda/users_controller.rb +61 -0
- data/lib/generators/fcus/authentication/templates/tests/testunit/sessions_controller.rb +36 -0
- data/lib/generators/fcus/authentication/templates/tests/testunit/user.rb +88 -0
- data/lib/generators/fcus/authentication/templates/tests/testunit/users_controller.rb +53 -0
- data/lib/generators/fcus/authentication/templates/user.rb +38 -0
- data/lib/generators/fcus/authentication/templates/users_controller.rb +32 -0
- data/lib/generators/fcus/authentication/templates/users_helper.rb +2 -0
- data/lib/generators/fcus/authentication/templates/views/erb/_form.html.erb +20 -0
- data/lib/generators/fcus/authentication/templates/views/erb/edit.html.erb +3 -0
- data/lib/generators/fcus/authentication/templates/views/erb/login.html.erb +30 -0
- data/lib/generators/fcus/authentication/templates/views/erb/signup.html.erb +5 -0
- data/lib/generators/fcus/authentication/templates/views/haml/_form.html.haml +16 -0
- data/lib/generators/fcus/authentication/templates/views/haml/edit.html.haml +3 -0
- data/lib/generators/fcus/authentication/templates/views/haml/login.html.haml +26 -0
- data/lib/generators/fcus/authentication/templates/views/haml/signup.html.haml +5 -0
- data/lib/generators/fcus/config/USAGE +23 -0
- data/lib/generators/fcus/config/config_generator.rb +24 -0
- data/lib/generators/fcus/config/templates/config.yml +8 -0
- data/lib/generators/fcus/config/templates/load_config.rb +2 -0
- data/lib/generators/fcus/layout/USAGE +25 -0
- data/lib/generators/fcus/layout/layout_generator.rb +29 -0
- data/lib/generators/fcus/layout/templates/error_messages_helper.rb +23 -0
- data/lib/generators/fcus/layout/templates/layout.html.erb +19 -0
- data/lib/generators/fcus/layout/templates/layout.html.haml +21 -0
- data/lib/generators/fcus/layout/templates/layout_helper.rb +22 -0
- data/lib/generators/fcus/layout/templates/stylesheet.css +83 -0
- data/lib/generators/fcus/layout/templates/stylesheet.sass +73 -0
- data/lib/generators/fcus/scaffold/USAGE +51 -0
- data/lib/generators/fcus/scaffold/scaffold_generator.rb +318 -0
- data/lib/generators/fcus/scaffold/templates/actions/create.rb +8 -0
- data/lib/generators/fcus/scaffold/templates/actions/destroy.rb +5 -0
- data/lib/generators/fcus/scaffold/templates/actions/edit.rb +3 -0
- data/lib/generators/fcus/scaffold/templates/actions/index.rb +3 -0
- data/lib/generators/fcus/scaffold/templates/actions/new.rb +3 -0
- data/lib/generators/fcus/scaffold/templates/actions/show.rb +3 -0
- data/lib/generators/fcus/scaffold/templates/actions/update.rb +8 -0
- data/lib/generators/fcus/scaffold/templates/controller.rb +3 -0
- data/lib/generators/fcus/scaffold/templates/fixtures.yml +9 -0
- data/lib/generators/fcus/scaffold/templates/helper.rb +2 -0
- data/lib/generators/fcus/scaffold/templates/migration.rb +16 -0
- data/lib/generators/fcus/scaffold/templates/model.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/controller.rb +8 -0
- data/lib/generators/fcus/scaffold/templates/tests/rspec/model.rb +7 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/lib/generators/fcus/scaffold/templates/tests/shoulda/model.rb +7 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/controller.rb +5 -0
- data/lib/generators/fcus/scaffold/templates/tests/testunit/model.rb +7 -0
- data/lib/generators/fcus/scaffold/templates/views/erb/_form.html.erb +10 -0
- data/lib/generators/fcus/scaffold/templates/views/erb/edit.html.erb +14 -0
- data/lib/generators/fcus/scaffold/templates/views/erb/index.html.erb +29 -0
- data/lib/generators/fcus/scaffold/templates/views/erb/new.html.erb +7 -0
- data/lib/generators/fcus/scaffold/templates/views/erb/show.html.erb +20 -0
- data/lib/generators/fcus/scaffold/templates/views/haml/_form.html.haml +9 -0
- data/lib/generators/fcus/scaffold/templates/views/haml/edit.html.haml +14 -0
- data/lib/generators/fcus/scaffold/templates/views/haml/index.html.haml +25 -0
- data/lib/generators/fcus/scaffold/templates/views/haml/new.html.haml +7 -0
- data/lib/generators/fcus/scaffold/templates/views/haml/show.html.haml +20 -0
- data/rails_generators/fcus_authentication/USAGE +50 -0
- data/rails_generators/fcus_authentication/fcus_authentication_generator.rb +128 -0
- data/rails_generators/fcus_authentication/lib/insert_commands.rb +74 -0
- data/rails_generators/fcus_authentication/templates/authentication.rb +61 -0
- data/rails_generators/fcus_authentication/templates/authlogic_session.rb +2 -0
- data/rails_generators/fcus_authentication/templates/fixtures.yml +24 -0
- data/rails_generators/fcus_authentication/templates/migration.rb +20 -0
- data/rails_generators/fcus_authentication/templates/sessions_controller.rb +45 -0
- data/rails_generators/fcus_authentication/templates/sessions_helper.rb +2 -0
- data/rails_generators/fcus_authentication/templates/tests/rspec/sessions_controller.rb +39 -0
- data/rails_generators/fcus_authentication/templates/tests/rspec/user.rb +83 -0
- data/rails_generators/fcus_authentication/templates/tests/rspec/users_controller.rb +26 -0
- data/rails_generators/fcus_authentication/templates/tests/shoulda/sessions_controller.rb +40 -0
- data/rails_generators/fcus_authentication/templates/tests/shoulda/user.rb +85 -0
- data/rails_generators/fcus_authentication/templates/tests/shoulda/users_controller.rb +27 -0
- data/rails_generators/fcus_authentication/templates/tests/testunit/sessions_controller.rb +36 -0
- data/rails_generators/fcus_authentication/templates/tests/testunit/user.rb +88 -0
- data/rails_generators/fcus_authentication/templates/tests/testunit/users_controller.rb +23 -0
- data/rails_generators/fcus_authentication/templates/user.rb +42 -0
- data/rails_generators/fcus_authentication/templates/users_controller.rb +18 -0
- data/rails_generators/fcus_authentication/templates/users_helper.rb +2 -0
- data/rails_generators/fcus_authentication/templates/views/erb/login.html.erb +30 -0
- data/rails_generators/fcus_authentication/templates/views/erb/signup.html.erb +24 -0
- data/rails_generators/fcus_authentication/templates/views/haml/login.html.haml +30 -0
- data/rails_generators/fcus_authentication/templates/views/haml/signup.html.haml +24 -0
- data/rails_generators/fcus_config/USAGE +23 -0
- data/rails_generators/fcus_config/fcus_config_generator.rb +32 -0
- data/rails_generators/fcus_config/templates/config.yml +8 -0
- data/rails_generators/fcus_config/templates/load_config.rb +2 -0
- data/rails_generators/fcus_layout/USAGE +25 -0
- data/rails_generators/fcus_layout/fcus_layout_generator.rb +44 -0
- data/rails_generators/fcus_layout/templates/helper.rb +22 -0
- data/rails_generators/fcus_layout/templates/layout.html.erb +22 -0
- data/rails_generators/fcus_layout/templates/layout.html.haml +19 -0
- data/rails_generators/fcus_layout/templates/stylesheet.css +81 -0
- data/rails_generators/fcus_layout/templates/stylesheet.sass +67 -0
- data/rails_generators/fcus_scaffold/USAGE +51 -0
- data/rails_generators/fcus_scaffold/fcus_scaffold_generator.rb +232 -0
- data/rails_generators/fcus_scaffold/templates/actions/create.rb +9 -0
- data/rails_generators/fcus_scaffold/templates/actions/destroy.rb +6 -0
- data/rails_generators/fcus_scaffold/templates/actions/edit.rb +3 -0
- data/rails_generators/fcus_scaffold/templates/actions/index.rb +3 -0
- data/rails_generators/fcus_scaffold/templates/actions/new.rb +3 -0
- data/rails_generators/fcus_scaffold/templates/actions/show.rb +3 -0
- data/rails_generators/fcus_scaffold/templates/actions/update.rb +9 -0
- data/rails_generators/fcus_scaffold/templates/controller.rb +3 -0
- data/rails_generators/fcus_scaffold/templates/fixtures.yml +9 -0
- data/rails_generators/fcus_scaffold/templates/helper.rb +2 -0
- data/rails_generators/fcus_scaffold/templates/migration.rb +16 -0
- data/rails_generators/fcus_scaffold/templates/model.rb +3 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/controller.rb +8 -0
- data/rails_generators/fcus_scaffold/templates/tests/rspec/model.rb +7 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/rails_generators/fcus_scaffold/templates/tests/shoulda/model.rb +7 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/controller.rb +5 -0
- data/rails_generators/fcus_scaffold/templates/tests/testunit/model.rb +7 -0
- data/rails_generators/fcus_scaffold/templates/views/erb/_form.html.erb +10 -0
- data/rails_generators/fcus_scaffold/templates/views/erb/edit.html.erb +14 -0
- data/rails_generators/fcus_scaffold/templates/views/erb/index.html.erb +29 -0
- data/rails_generators/fcus_scaffold/templates/views/erb/new.html.erb +7 -0
- data/rails_generators/fcus_scaffold/templates/views/erb/show.html.erb +20 -0
- data/rails_generators/fcus_scaffold/templates/views/haml/_form.html.haml +10 -0
- data/rails_generators/fcus_scaffold/templates/views/haml/edit.html.haml +14 -0
- data/rails_generators/fcus_scaffold/templates/views/haml/index.html.haml +25 -0
- data/rails_generators/fcus_scaffold/templates/views/haml/new.html.haml +7 -0
- data/rails_generators/fcus_scaffold/templates/views/haml/show.html.haml +20 -0
- data/test/test_fcus_authentication_generator.rb +274 -0
- data/test/test_fcus_config_generator.rb +37 -0
- data/test/test_fcus_layout_generator.rb +42 -0
- data/test/test_fcus_scaffold_generator.rb +534 -0
- data/test/test_helper.rb +119 -0
- metadata +314 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
it "create action should render new template when model is invalid" do
|
|
2
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
3
|
+
post :create
|
|
4
|
+
response.should render_template(:new)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
it "create action should redirect when model is valid" do
|
|
8
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
9
|
+
post :create
|
|
10
|
+
response.should redirect_to(<%= item_path_for_spec('url') %>)
|
|
11
|
+
end
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
it "destroy action should destroy model and redirect to index action" do
|
|
2
|
+
<%= singular_name %> = <%= class_name %>.first
|
|
3
|
+
delete :destroy, :id => <%= singular_name %>
|
|
4
|
+
response.should redirect_to(<%= items_path('url') %>)
|
|
5
|
+
<%= class_name %>.exists?(<%= singular_name %>.id).should be_false
|
|
6
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
it "update action should render edit template when model is invalid" do
|
|
2
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
3
|
+
put :update, :id => <%= class_name %>.first
|
|
4
|
+
response.should render_template(:edit)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
it "update action should redirect when model is valid" do
|
|
8
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
9
|
+
put :update, :id => <%= class_name %>.first
|
|
10
|
+
response.should redirect_to(<%= item_path_for_spec('url') %>)
|
|
11
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
context "create action" do
|
|
2
|
+
should "render new template when model is invalid" do
|
|
3
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
4
|
+
post :create
|
|
5
|
+
assert_template 'new'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
should "redirect when model is valid" do
|
|
9
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
10
|
+
post :create
|
|
11
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
context "destroy action" do
|
|
2
|
+
should "destroy model and redirect to index action" do
|
|
3
|
+
<%= singular_name %> = <%= class_name %>.first
|
|
4
|
+
delete :destroy, :id => <%= singular_name %>
|
|
5
|
+
assert_redirected_to <%= items_path('url') %>
|
|
6
|
+
assert !<%= class_name %>.exists?(<%= singular_name %>.id)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
context "update action" do
|
|
2
|
+
should "render edit template when model is invalid" do
|
|
3
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
4
|
+
put :update, :id => <%= class_name %>.first
|
|
5
|
+
assert_template 'edit'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
should "redirect when model is valid" do
|
|
9
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
10
|
+
put :update, :id => <%= class_name %>.first
|
|
11
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
def test_create_invalid
|
|
2
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
3
|
+
post :create
|
|
4
|
+
assert_template 'new'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def test_create_valid
|
|
8
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
9
|
+
post :create
|
|
10
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
def test_update_invalid
|
|
2
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(false)
|
|
3
|
+
put :update, :id => <%= class_name %>.first
|
|
4
|
+
assert_template 'edit'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def test_update_valid
|
|
8
|
+
<%= class_name %>.any_instance.stubs(:valid?).returns(true)
|
|
9
|
+
put :update, :id => <%= class_name %>.first
|
|
10
|
+
assert_redirected_to <%= item_path_for_test('url') %>
|
|
11
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%% form_for @<%= singular_name %> do |f| %>
|
|
2
|
+
<%%= f.error_messages %>
|
|
3
|
+
<%- for attribute in attributes -%>
|
|
4
|
+
<p>
|
|
5
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
|
6
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
|
7
|
+
</p>
|
|
8
|
+
<%- end -%>
|
|
9
|
+
<p><%%= f.submit %></p>
|
|
10
|
+
<%% end %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%% title "Edit <%= singular_name.titleize %>" %>
|
|
2
|
+
|
|
3
|
+
<%= render_form %>
|
|
4
|
+
|
|
5
|
+
<%- if actions? :show, :index -%>
|
|
6
|
+
<p>
|
|
7
|
+
<%- if action? :show -%>
|
|
8
|
+
<%%= link_to "Show", @<%= singular_name %> %> |
|
|
9
|
+
<%- end -%>
|
|
10
|
+
<%- if action? :index -%>
|
|
11
|
+
<%%= link_to "View All", <%= plural_name %>_path %>
|
|
12
|
+
<%- end -%>
|
|
13
|
+
</p>
|
|
14
|
+
<%- end -%>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%% title "<%= plural_name.titleize %>" %>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<%- for attribute in attributes -%>
|
|
6
|
+
<th><%= attribute.column.human_name.titleize %></th>
|
|
7
|
+
<%- end -%>
|
|
8
|
+
</tr>
|
|
9
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
|
10
|
+
<tr>
|
|
11
|
+
<%- for attribute in attributes -%>
|
|
12
|
+
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
|
13
|
+
<%- end -%>
|
|
14
|
+
<%- if action? :show -%>
|
|
15
|
+
<td><%%= link_to "Show", <%= singular_name %> %></td>
|
|
16
|
+
<%- end -%>
|
|
17
|
+
<%- if action? :edit -%>
|
|
18
|
+
<td><%%= link_to "Edit", edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
|
19
|
+
<%- end -%>
|
|
20
|
+
<%- if action? :destroy -%>
|
|
21
|
+
<td><%%= link_to "Destroy", <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
|
22
|
+
<%- end -%>
|
|
23
|
+
</tr>
|
|
24
|
+
<%% end %>
|
|
25
|
+
</table>
|
|
26
|
+
|
|
27
|
+
<%- if action? :new -%>
|
|
28
|
+
<p><%%= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path %></p>
|
|
29
|
+
<%- end -%>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%% title "<%= singular_name.titleize %>" %>
|
|
2
|
+
|
|
3
|
+
<%- for attribute in attributes -%>
|
|
4
|
+
<p>
|
|
5
|
+
<strong><%= attribute.column.human_name.titleize %>:</strong>
|
|
6
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
|
7
|
+
</p>
|
|
8
|
+
<%- end -%>
|
|
9
|
+
|
|
10
|
+
<p>
|
|
11
|
+
<%- if action? :edit -%>
|
|
12
|
+
<%%= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
|
13
|
+
<%- end -%>
|
|
14
|
+
<%- if action? :destroy -%>
|
|
15
|
+
<%%= link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %> |
|
|
16
|
+
<%- end -%>
|
|
17
|
+
<%- if action? :index -%>
|
|
18
|
+
<%%= link_to "View All", <%= plural_name %>_path %>
|
|
19
|
+
<%- end -%>
|
|
20
|
+
</p>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
- title "Edit <%= singular_name.titleize %>"
|
|
2
|
+
|
|
3
|
+
<%= render_form %>
|
|
4
|
+
|
|
5
|
+
<%- if actions? :show, :index -%>
|
|
6
|
+
%p
|
|
7
|
+
<%- if action? :show -%>
|
|
8
|
+
= link_to "Show", <%= singular_name %>_path(@<%= singular_name %>)
|
|
9
|
+
|
|
|
10
|
+
<%- end -%>
|
|
11
|
+
<%- if action? :index -%>
|
|
12
|
+
= link_to "View All", <%= plural_name %>_path
|
|
13
|
+
<%- end -%>
|
|
14
|
+
<%- end -%>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
- title "<%= plural_name.titleize %>"
|
|
2
|
+
|
|
3
|
+
%table
|
|
4
|
+
%tr
|
|
5
|
+
<%- for attribute in attributes -%>
|
|
6
|
+
%th <%= attribute.column.human_name %>
|
|
7
|
+
<%- end -%>
|
|
8
|
+
- for <%= singular_name %> in @<%= plural_name %>
|
|
9
|
+
%tr
|
|
10
|
+
<%- for attribute in attributes -%>
|
|
11
|
+
%td= h <%= singular_name %>.<%= attribute.name %>
|
|
12
|
+
<%- end -%>
|
|
13
|
+
<%- if action? :show -%>
|
|
14
|
+
%td= link_to 'Show', <%= singular_name %>
|
|
15
|
+
<%- end -%>
|
|
16
|
+
<%- if action? :edit -%>
|
|
17
|
+
%td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
|
|
18
|
+
<%- end -%>
|
|
19
|
+
<%- if action? :destroy -%>
|
|
20
|
+
%td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
|
21
|
+
<%- end -%>
|
|
22
|
+
|
|
23
|
+
<%- if actions? :new -%>
|
|
24
|
+
%p= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path
|
|
25
|
+
<%- end -%>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
- title "<%= singular_name.titleize %>"
|
|
2
|
+
|
|
3
|
+
<%- for attribute in attributes -%>
|
|
4
|
+
%p
|
|
5
|
+
%strong <%= attribute.column.human_name.titleize %>:
|
|
6
|
+
=h @<%= singular_name %>.<%= attribute.name %>
|
|
7
|
+
<%- end -%>
|
|
8
|
+
|
|
9
|
+
%p
|
|
10
|
+
<%- if action? :edit -%>
|
|
11
|
+
= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>)
|
|
12
|
+
|
|
|
13
|
+
<%- end -%>
|
|
14
|
+
<%- if action? :destroy -%>
|
|
15
|
+
= link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
|
|
16
|
+
|
|
|
17
|
+
<%- end -%>
|
|
18
|
+
<%- if action? :index -%>
|
|
19
|
+
= link_to "View All", <%= plural_name %>_path
|
|
20
|
+
<%- end -%>
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
|
2
|
+
|
|
3
|
+
class TestFcusAuthenticationGenerator < Test::Unit::TestCase
|
|
4
|
+
include FcusGenerators::TestHelper
|
|
5
|
+
|
|
6
|
+
# Some generator-related assertions:
|
|
7
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
|
8
|
+
# assert_directory_exists(name)
|
|
9
|
+
# assert_generated_class(name, &block)
|
|
10
|
+
# assert_generated_module(name, &block)
|
|
11
|
+
# assert_generated_test_for(name, &block)
|
|
12
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
|
13
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
|
14
|
+
#
|
|
15
|
+
# Other helper methods are:
|
|
16
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
|
17
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
|
18
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
|
19
|
+
context "" do # empty context so we can use setup block
|
|
20
|
+
setup do
|
|
21
|
+
Rails.stubs(:version).returns("2.0.2")
|
|
22
|
+
Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config")
|
|
23
|
+
File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
|
|
24
|
+
f.puts "ActionController::Routing::Routes.draw do |map|\n\nend"
|
|
25
|
+
end
|
|
26
|
+
Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app")
|
|
27
|
+
Dir.mkdir("#{RAILS_ROOT}/app/controllers") unless File.exists?("#{RAILS_ROOT}/app/controllers")
|
|
28
|
+
File.open("#{RAILS_ROOT}/app/controllers/application.rb", 'w') do |f|
|
|
29
|
+
f.puts "class Application < ActionController::Base\n\nend"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
teardown do
|
|
34
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/config"
|
|
35
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/app"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "generator without arguments" do
|
|
39
|
+
rails_generator :fcus_authentication
|
|
40
|
+
should_generate_file 'app/models/user.rb'
|
|
41
|
+
should_generate_file 'app/controllers/users_controller.rb'
|
|
42
|
+
should_generate_file 'app/helpers/users_helper.rb'
|
|
43
|
+
should_generate_file 'app/views/users/new.html.erb'
|
|
44
|
+
should_generate_file 'app/controllers/sessions_controller.rb'
|
|
45
|
+
should_generate_file 'app/helpers/sessions_helper.rb'
|
|
46
|
+
should_generate_file 'app/views/sessions/new.html.erb'
|
|
47
|
+
should_generate_file 'lib/authentication.rb'
|
|
48
|
+
should_generate_file 'test/fixtures/users.yml'
|
|
49
|
+
should_generate_file 'test/unit/user_test.rb'
|
|
50
|
+
should_generate_file 'test/functional/users_controller_test.rb'
|
|
51
|
+
should_generate_file 'test/functional/sessions_controller_test.rb'
|
|
52
|
+
|
|
53
|
+
should "generate migration file" do
|
|
54
|
+
assert !Dir.glob("#{RAILS_ROOT}/db/migrate/*.rb").empty?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
should "generate routes" do
|
|
58
|
+
assert_generated_file "config/routes.rb" do |body|
|
|
59
|
+
assert_match "map.resources :sessions", body
|
|
60
|
+
assert_match "map.resources :users", body
|
|
61
|
+
assert_match "map.login 'login', :controller => 'sessions', :action => 'new'", body
|
|
62
|
+
assert_match "map.logout 'logout', :controller => 'sessions', :action => 'destroy'", body
|
|
63
|
+
assert_match "map.signup 'signup', :controller => 'users', :action => 'new'", body
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
should "include Authentication" do
|
|
68
|
+
application_controller_name = Rails.version >= '2.3.0' ? 'application_controller' : 'application'
|
|
69
|
+
assert_generated_file "app/controllers/#{application_controller_name}.rb" do |body|
|
|
70
|
+
assert_match "include Authentication", body
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context "generator with user and session names" do
|
|
76
|
+
rails_generator :fcus_authentication, "Account", "CurrentSession"
|
|
77
|
+
should_generate_file 'app/models/account.rb'
|
|
78
|
+
should_generate_file 'app/controllers/accounts_controller.rb'
|
|
79
|
+
should_generate_file 'app/helpers/accounts_helper.rb'
|
|
80
|
+
should_generate_file 'app/views/accounts/new.html.erb'
|
|
81
|
+
should_generate_file 'app/controllers/current_sessions_controller.rb'
|
|
82
|
+
should_generate_file 'app/helpers/current_sessions_helper.rb'
|
|
83
|
+
should_generate_file 'app/views/current_sessions/new.html.erb'
|
|
84
|
+
should_generate_file 'test/fixtures/accounts.yml'
|
|
85
|
+
should_generate_file 'test/unit/account_test.rb'
|
|
86
|
+
should_generate_file 'test/functional/accounts_controller_test.rb'
|
|
87
|
+
should_generate_file 'test/functional/current_sessions_controller_test.rb'
|
|
88
|
+
|
|
89
|
+
should "generate routes" do
|
|
90
|
+
assert_generated_file "config/routes.rb" do |body|
|
|
91
|
+
assert_match "map.resources :current_sessions", body
|
|
92
|
+
assert_match "map.resources :accounts", body
|
|
93
|
+
assert_match "map.login 'login', :controller => 'current_sessions', :action => 'new'", body
|
|
94
|
+
assert_match "map.logout 'logout', :controller => 'current_sessions', :action => 'destroy'", body
|
|
95
|
+
assert_match "map.signup 'signup', :controller => 'accounts', :action => 'new'", body
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
context "generator with shoulda option" do
|
|
101
|
+
rails_generator :fcus_authentication, :test_framework => :shoulda
|
|
102
|
+
|
|
103
|
+
should "have controller and model tests using shoulda syntax" do
|
|
104
|
+
assert_generated_file "test/functional/users_controller_test.rb" do |body|
|
|
105
|
+
assert_match " should ", body
|
|
106
|
+
end
|
|
107
|
+
assert_generated_file "test/functional/sessions_controller_test.rb" do |body|
|
|
108
|
+
assert_match " should ", body
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
assert_generated_file "test/unit/user_test.rb" do |body|
|
|
112
|
+
assert_match " should ", body
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
context "generator with rspec option" do
|
|
118
|
+
rails_generator :fcus_authentication, :test_framework => :rspec
|
|
119
|
+
should_generate_file 'spec/fixtures/users.yml'
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
context "with spec dir" do
|
|
123
|
+
setup do
|
|
124
|
+
Dir.mkdir("#{RAILS_ROOT}/spec") unless File.exists?("#{RAILS_ROOT}/spec")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
teardown do
|
|
128
|
+
FileUtils.rm_rf "#{RAILS_ROOT}/spec"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
context "generator without arguments" do
|
|
132
|
+
rails_generator :fcus_authentication
|
|
133
|
+
should_generate_file 'spec/fixtures/users.yml'
|
|
134
|
+
should_generate_file 'spec/models/user_spec.rb'
|
|
135
|
+
should_generate_file 'spec/controllers/users_controller_spec.rb'
|
|
136
|
+
should_generate_file 'spec/controllers/sessions_controller_spec.rb'
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
context "generator with user and session names" do
|
|
140
|
+
rails_generator :fcus_authentication, "Account", "CurrentSessions"
|
|
141
|
+
should_generate_file 'spec/fixtures/accounts.yml'
|
|
142
|
+
should_generate_file 'spec/models/account_spec.rb'
|
|
143
|
+
should_generate_file 'spec/controllers/accounts_controller_spec.rb'
|
|
144
|
+
should_generate_file 'spec/controllers/current_sessions_controller_spec.rb'
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
context "generator with testunit option" do
|
|
148
|
+
rails_generator :fcus_authentication, :test_framework => :testunit
|
|
149
|
+
should_generate_file 'test/fixtures/users.yml'
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
context "generator with haml option" do
|
|
154
|
+
rails_generator :fcus_authentication, :haml => true
|
|
155
|
+
|
|
156
|
+
should_generate_file "app/views/users/new.html.haml"
|
|
157
|
+
should_generate_file "app/views/sessions/new.html.haml"
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
context "generator with authlogic option and custom account name" do
|
|
161
|
+
rails_generator :fcus_authentication, "Account", :authlogic => true
|
|
162
|
+
should_generate_file 'app/models/account.rb'
|
|
163
|
+
should_generate_file 'app/controllers/accounts_controller.rb'
|
|
164
|
+
should_generate_file 'app/helpers/accounts_helper.rb'
|
|
165
|
+
should_generate_file 'app/views/accounts/new.html.erb'
|
|
166
|
+
should_generate_file 'app/controllers/account_sessions_controller.rb'
|
|
167
|
+
should_generate_file 'app/helpers/account_sessions_helper.rb'
|
|
168
|
+
should_generate_file 'app/views/account_sessions/new.html.erb'
|
|
169
|
+
should_generate_file 'test/fixtures/accounts.yml'
|
|
170
|
+
should_generate_file 'test/unit/account_test.rb'
|
|
171
|
+
should_generate_file 'test/functional/accounts_controller_test.rb'
|
|
172
|
+
should_generate_file 'test/functional/account_sessions_controller_test.rb'
|
|
173
|
+
should_generate_file 'lib/authentication.rb'
|
|
174
|
+
|
|
175
|
+
should "only include acts_as_authentic in account model" do
|
|
176
|
+
assert_generated_file "app/models/account.rb" do |body|
|
|
177
|
+
assert_match "acts_as_authentic", body
|
|
178
|
+
assert_no_match(/validates/, body)
|
|
179
|
+
assert_no_match(/def/, body)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
should "should generate authentication module with current_account_session method" do
|
|
184
|
+
assert_generated_file "lib/authentication.rb" do |body|
|
|
185
|
+
assert_match "def current_account_session", body
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
should "should generate AccountSession model" do
|
|
190
|
+
assert_generated_file "app/models/account_session.rb" do |body|
|
|
191
|
+
assert_match "class AccountSession < Authlogic::Session::Base", body
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
should "should generate restful style actions in sessions controller" do
|
|
196
|
+
assert_generated_file "app/controllers/account_sessions_controller.rb" do |body|
|
|
197
|
+
assert_match "AccountSession.new", body
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
should "should generate form for account session" do
|
|
202
|
+
assert_generated_file "app/views/account_sessions/new.html.erb" do |body|
|
|
203
|
+
assert_match "form_for @account_session", body
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
should "should not include tests in account since authlogic is already tested" do
|
|
208
|
+
assert_generated_file "test/unit/account_test.rb" do |body|
|
|
209
|
+
assert_no_match(/def test/, body)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
should "should handle session controller tests differently" do
|
|
214
|
+
assert_generated_file "test/functional/account_sessions_controller_test.rb" do |body|
|
|
215
|
+
assert_match "AccountSession.find", body
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
should "generate migration with authlogic columns" do
|
|
220
|
+
file = Dir.glob("#{RAILS_ROOT}/db/migrate/*.rb").first
|
|
221
|
+
assert file, "migration file doesn't exist"
|
|
222
|
+
assert_match(/[0-9]+_create_accounts.rb$/, file)
|
|
223
|
+
assert_generated_file "db/migrate/#{File.basename(file)}" do |body|
|
|
224
|
+
assert_match "class CreateAccounts", body
|
|
225
|
+
assert_match "t.string :username", body
|
|
226
|
+
assert_match "t.string :email", body
|
|
227
|
+
assert_match "t.string :crypted_password", body
|
|
228
|
+
assert_match "t.string :password_salt", body
|
|
229
|
+
assert_match "t.string :persistence_token", body
|
|
230
|
+
assert_match "t.timestamps", body
|
|
231
|
+
assert_no_match(/password_hash/, body)
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
context "generator with authlogic option and custom account and session name" do
|
|
237
|
+
rails_generator :fcus_authentication, "Account", "UserSession", :authlogic => true
|
|
238
|
+
should_generate_file 'app/controllers/user_sessions_controller.rb'
|
|
239
|
+
should_generate_file 'app/helpers/user_sessions_helper.rb'
|
|
240
|
+
should_generate_file 'app/views/user_sessions/new.html.erb'
|
|
241
|
+
should_generate_file 'test/functional/user_sessions_controller_test.rb'
|
|
242
|
+
|
|
243
|
+
should "should generate authentication module with current_user_session method" do
|
|
244
|
+
assert_generated_file "lib/authentication.rb" do |body|
|
|
245
|
+
assert_match "def current_user_session", body
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
should "should generate UserSession model" do
|
|
250
|
+
assert_generated_file "app/models/user_session.rb" do |body|
|
|
251
|
+
assert_match "class UserSession < Authlogic::Session::Base", body
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
should "should generate restful style actions in sessions controller" do
|
|
256
|
+
assert_generated_file "app/controllers/user_sessions_controller.rb" do |body|
|
|
257
|
+
assert_match "UserSession.new", body
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
should "should generate form for user session" do
|
|
262
|
+
assert_generated_file "app/views/user_sessions/new.html.erb" do |body|
|
|
263
|
+
assert_match "form_for @user_session", body
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
should "should handle session controller tests differently" do
|
|
268
|
+
assert_generated_file "test/functional/user_sessions_controller_test.rb" do |body|
|
|
269
|
+
assert_match "UserSession.find", body
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
end
|