Commit 5306b580be70c0f9299420e1df76dc86259d18a5
1 parent
ff03e98b
Exists in
master
and in
1 other branch
new view generators for show and index action
Showing
5 changed files
with
24 additions
and
6 deletions
Show diff stats
vendor/plugins/blitz/features/step_definitions/view_steps.rb
@@ -41,7 +41,7 @@ Then /^a SemiFormal "new" view for "posts" should be generated with fields$/ do | @@ -41,7 +41,7 @@ Then /^a SemiFormal "new" view for "posts" should be generated with fields$/ do | ||
41 | end | 41 | end |
42 | end | 42 | end |
43 | 43 | ||
44 | -Then /^an empty "new" view for "posts" should be generated$/ do | ||
45 | - assert_generated_empty_file("app/views/posts/new.html.erb") | 44 | +Then /^an empty "(.*)" view for "posts" should be generated$/ do |view| |
45 | + assert_generated_empty_file("app/views/posts/#{view}.html.erb") | ||
46 | end | 46 | end |
47 | 47 |
vendor/plugins/blitz/features/view_generator.feature
@@ -23,3 +23,15 @@ Feature: Rails view generator | @@ -23,3 +23,15 @@ Feature: Rails view generator | ||
23 | When I generate a "new" view for "Posts" with the empty option | 23 | When I generate a "new" view for "Posts" with the empty option |
24 | Then an empty "new" view for "posts" should be generated | 24 | Then an empty "new" view for "posts" should be generated |
25 | 25 | ||
26 | + Scenario: View generator for show action | ||
27 | + Given a Rails app | ||
28 | + And the blitz plugin is installed | ||
29 | + When I generate a "show" view for "Posts" with the empty option | ||
30 | + Then an empty "show" view for "posts" should be generated | ||
31 | + | ||
32 | + Scenario: View generator for index action | ||
33 | + Given a Rails app | ||
34 | + And the blitz plugin is installed | ||
35 | + When I generate a "index" view for "Posts" with the empty option | ||
36 | + Then an empty "index" view for "posts" should be generated | ||
37 | + |
vendor/plugins/blitz/generators/view/templates/index.html.erb
0 → 100644
vendor/plugins/blitz/generators/view/templates/view_show.html.erb
vendor/plugins/blitz/generators/view/view_generator.rb
@@ -14,6 +14,12 @@ class ViewGenerator < Rails::Generator::NamedBase | @@ -14,6 +14,12 @@ class ViewGenerator < Rails::Generator::NamedBase | ||
14 | else | 14 | else |
15 | m.template 'new.html.erb', path | 15 | m.template 'new.html.erb', path |
16 | end | 16 | end |
17 | + elsif %w(index show).any? { |action| actions.include?(action) } | ||
18 | + actions.each do |action| | ||
19 | + path = File.join('app/views', class_path, file_name, | ||
20 | + "#{action}.html.erb") | ||
21 | + m.file 'empty.html.erb', path | ||
22 | + end | ||
17 | end | 23 | end |
18 | end | 24 | end |
19 | end | 25 | end |