Commit d385d518df95387cdf4164c09742a0673a602bca

Authored by Dan Croak
1 parent b6baf0ec

upgrading blitz

vendor/plugins/blitz/features/controller_generator.feature
@@ -7,7 +7,7 @@ Feature: Rails controller generator @@ -7,7 +7,7 @@ Feature: Rails controller generator
7 Given a Rails app 7 Given a Rails app
8 And the blitz plugin is installed 8 And the blitz plugin is installed
9 When I generate a "Posts" controller with "index" action 9 When I generate a "Posts" controller with "index" action
10 - And an empty "index" controller action for "posts" should be generated 10 + And a "index" controller action for "posts" should be generated
11 11
12 Scenario: Controller generator for new action 12 Scenario: Controller generator for new action
13 Given a Rails app 13 Given a Rails app
vendor/plugins/blitz/features/step_definitions/controller_steps.rb
@@ -4,60 +4,9 @@ When /^I generate a "(.*)" controller with "(.*)" action$/ do |controller, actio @@ -4,60 +4,9 @@ When /^I generate a "(.*)" controller with "(.*)" action$/ do |controller, actio
4 "cd .." 4 "cd .."
5 end 5 end
6 6
7 -Then /^a "new" controller action for "posts" should be generated$/ do 7 +Then /^a "(.*)" controller action for "posts" should be generated$/ do |action|
8 assert_generated_file("app/controllers/posts_controller.rb") do 8 assert_generated_file("app/controllers/posts_controller.rb") do
9 - " def new\n" <<  
10 - " @post = Post.new\n" <<  
11 - " end"  
12 - end  
13 -end  
14 -  
15 -Then /^a "create" controller action for "posts" should be generated$/ do  
16 - assert_generated_file("app/controllers/posts_controller.rb") do  
17 - " def create\n" <<  
18 - " @post = Post.new(params[:post])\n" <<  
19 - " @post.save\n" <<  
20 - " flash[:success] = 'Post created.'\n" <<  
21 - " redirect_to root_path\n" <<  
22 - " end"  
23 - end  
24 -end  
25 -  
26 -Then /^a "show" controller action for "posts" should be generated$/ do  
27 - assert_generated_file("app/controllers/posts_controller.rb") do  
28 - " def show\n" <<  
29 - " @post = Post.find(params[:id])\n" <<  
30 - " end"  
31 - end  
32 -end  
33 -  
34 -Then /^a "edit" controller action for "posts" should be generated$/ do  
35 - assert_generated_file("app/controllers/posts_controller.rb") do  
36 - " def edit\n" <<  
37 - " @post = Post.find(params[:id])\n" <<  
38 - " end"  
39 - end  
40 -end  
41 -  
42 -Then /^a "update" controller action for "posts" should be generated$/ do  
43 - assert_generated_file("app/controllers/posts_controller.rb") do  
44 - " def update\n" <<  
45 - " @post = Post.find(params[:id])\n" <<  
46 - " @post.update_attributes(params[:post])\n" <<  
47 - " flash[:success] = 'Post updated.'\n" <<  
48 - " redirect_to root_path\n" <<  
49 - " end"  
50 - end  
51 -end  
52 -  
53 -Then /^a "destroy" controller action for "posts" should be generated$/ do  
54 - assert_generated_file("app/controllers/posts_controller.rb") do  
55 - " def destroy\n" <<  
56 - " @post = Post.find(params[:id])\n" <<  
57 - " @post.destroy\n" <<  
58 - " flash[:success] = 'Post deleted.'\n" <<  
59 - " redirect_to root_path\n" <<  
60 - " end" 9 + " actions :#{action}"
61 end 10 end
62 end 11 end
63 12
vendor/plugins/blitz/features/step_definitions/functional_test_steps.rb
@@ -65,7 +65,7 @@ Then /^a standard &quot;edit&quot; functional test for &quot;posts&quot; should be generated$/ do @@ -65,7 +65,7 @@ Then /^a standard &quot;edit&quot; functional test for &quot;posts&quot; should be generated$/ do
65 " @post = Factory(:post)\n" << 65 " @post = Factory(:post)\n" <<
66 " get :edit, :id => @post.to_param\n" << 66 " get :edit, :id => @post.to_param\n" <<
67 " end\n\n" << 67 " end\n\n" <<
68 - " should_assign_to :post, :equals => '@post'\n" << 68 + " should_assign_to(:post) { '@post' }\n" <<
69 " should_render_template :edit\n" << 69 " should_render_template :edit\n" <<
70 " should_respond_with :success\n" << 70 " should_respond_with :success\n" <<
71 " end" 71 " end"
vendor/plugins/blitz/features/step_definitions/view_steps.rb
@@ -10,7 +10,7 @@ When /^I generate a &quot;([^\&quot;]*)&quot; view for &quot;([^\&quot;]*)&quot; with the empty option$/ do |v @@ -10,7 +10,7 @@ When /^I generate a &quot;([^\&quot;]*)&quot; view for &quot;([^\&quot;]*)&quot; with the empty option$/ do |v
10 "cd .." 10 "cd .."
11 end 11 end
12 12
13 -When /^a SemiFormal "new" view for "posts" should be generated$/ do 13 +When /^a Formtastic "new" view for "posts" should be generated$/ do
14 assert_generated_file("app/views/posts/new.html.erb") do 14 assert_generated_file("app/views/posts/new.html.erb") do
15 "<h1>New post</h1>\n\n" << 15 "<h1>New post</h1>\n\n" <<
16 "<% semantic_form_for(@post) do |form| %>\n" << 16 "<% semantic_form_for(@post) do |form| %>\n" <<
@@ -23,7 +23,7 @@ When /^a SemiFormal &quot;new&quot; view for &quot;posts&quot; should be generated$/ do @@ -23,7 +23,7 @@ When /^a SemiFormal &quot;new&quot; view for &quot;posts&quot; should be generated$/ do
23 end 23 end
24 end 24 end
25 25
26 -Then /^a SemiFormal "new" view for "posts" should be generated with fields$/ do 26 +Then /^a Formtastic "new" view for "posts" should be generated with fields$/ do
27 assert_generated_file("app/views/posts/new.html.erb") do 27 assert_generated_file("app/views/posts/new.html.erb") do
28 "<h1>New post</h1>\n\n" << 28 "<h1>New post</h1>\n\n" <<
29 "<% semantic_form_for(@post) do |form| %>\n" << 29 "<% semantic_form_for(@post) do |form| %>\n" <<
vendor/plugins/blitz/features/view_generator.feature
@@ -7,14 +7,14 @@ Feature: Rails view generator @@ -7,14 +7,14 @@ Feature: Rails view generator
7 Given a Rails app 7 Given a Rails app
8 And the blitz plugin is installed 8 And the blitz plugin is installed
9 When I generate a "new" view for "Posts" 9 When I generate a "new" view for "Posts"
10 - Then a SemiFormal "new" view for "posts" should be generated 10 + Then a Formtastic "new" view for "posts" should be generated
11 11
12 Scenario: View generator for new action 12 Scenario: View generator for new action
13 Given a Rails app 13 Given a Rails app
14 And the blitz plugin is installed 14 And the blitz plugin is installed
15 When I generate a Post model with title, body, and User 15 When I generate a Post model with title, body, and User
16 And I generate a "new" view for "Posts" 16 And I generate a "new" view for "Posts"
17 - Then a SemiFormal "new" view for "posts" should be generated with fields 17 + Then a Formtastic "new" view for "posts" should be generated with fields
18 18
19 Scenario: View generator for new action 19 Scenario: View generator for new action
20 Given a Rails app 20 Given a Rails app
vendor/plugins/blitz/generators/controller/templates/controller.rb
1 -class <%= class_name %>Controller < ApplicationController  
2 -<% if actions.include?("index") -%>  
3 - def index  
4 - end  
5 -  
6 -<% end -%>  
7 -<% if actions.include?("new") -%>  
8 - def new  
9 - @<%= resource %> = <%= resource_class %>.new  
10 - end  
11 -  
12 -<% end -%>  
13 -<% if actions.include?("create") -%>  
14 - def create  
15 - @<%= resource %> = <%= resource_class %>.new(params[:<%= resource %>])  
16 - @<%= resource %>.save  
17 - flash[:success] = '<%= resource_class %> created.'  
18 - redirect_to root_path  
19 - end  
20 -  
21 -<% end -%>  
22 -<% if actions.include?("show") -%>  
23 - def show  
24 - @<%= resource %> = <%= resource_class %>.find(params[:id])  
25 - end  
26 -  
27 -<% end -%>  
28 -<% if actions.include?("edit") -%>  
29 - def edit  
30 - @<%= resource %> = <%= resource_class %>.find(params[:id])  
31 - end  
32 -  
33 -<% end -%>  
34 -<% if actions.include?("update") -%>  
35 - def update  
36 - @<%= resource %> = <%= resource_class %>.find(params[:id])  
37 - @<%= resource %>.update_attributes(params[:<%= resource %>])  
38 - flash[:success] = '<%= resource_class %> updated.'  
39 - redirect_to root_path  
40 - end  
41 -  
42 -<% end -%>  
43 -<% if actions.include?("destroy") -%>  
44 - def destroy  
45 - @<%= resource %> = <%= resource_class %>.find(params[:id])  
46 - @<%= resource %>.destroy  
47 - flash[:success] = '<%= resource_class %> deleted.'  
48 - redirect_to root_path  
49 - end  
50 - 1 +class <%= class_name %>Controller < InheritedResources::Base
  2 +<% if actions.any? -%>
  3 + actions <%= actions.collect { |action| ":#{action}" }.join(", ") %>
51 <% end -%> 4 <% end -%>
52 end 5 end
vendor/plugins/blitz/generators/functional_test/templates/functional_test.rb
@@ -51,7 +51,7 @@ class &lt;%= class_name %&gt;ControllerTest &lt; ActionController::TestCase @@ -51,7 +51,7 @@ class &lt;%= class_name %&gt;ControllerTest &lt; ActionController::TestCase
51 get :edit, :id => @<%= resource %>.to_param 51 get :edit, :id => @<%= resource %>.to_param
52 end 52 end
53 53
54 - should_assign_to :<%= resource %>, :equals => '@<%= resource %>' 54 + should_assign_to(:<%= resource %>( { @<%= resource %> }
55 should_render_template :edit 55 should_render_template :edit
56 should_respond_with :success 56 should_respond_with :success
57 end 57 end