authorized_rails_scaffolds 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/lib/authorized_rails_scaffolds.rb +5 -1
  2. data/lib/authorized_rails_scaffolds/controller_spec_helper.rb +31 -0
  3. data/lib/authorized_rails_scaffolds/helper.rb +10 -17
  4. data/lib/authorized_rails_scaffolds/routing_spec_helper.rb +29 -0
  5. data/lib/authorized_rails_scaffolds/version.rb +1 -1
  6. data/lib/authorized_rails_scaffolds/view_spec_helper.rb +49 -0
  7. data/lib/generators/authorized_rails_scaffolds/{install_spec → install_macros}/USAGE +2 -2
  8. data/lib/generators/authorized_rails_scaffolds/{install_spec/install_spec_generator.rb → install_macros/install_macros_generator.rb} +1 -24
  9. data/lib/generators/authorized_rails_scaffolds/{install_spec → install_macros}/templates/devise_can_can/USAGE +0 -0
  10. data/lib/generators/authorized_rails_scaffolds/{install_spec → install_macros}/templates/devise_can_can/controller_macros.rb +0 -0
  11. data/lib/generators/authorized_rails_scaffolds/{install_scaffold → install_templates}/USAGE +1 -0
  12. data/lib/generators/authorized_rails_scaffolds/install_templates/install_templates_generator.rb +51 -0
  13. data/lib/generators/authorized_rails_scaffolds/{install_scaffold/templates → install_templates/templates/scaffold}/_form.html.erb +8 -4
  14. data/lib/generators/authorized_rails_scaffolds/{install_scaffold/templates → install_templates/templates/scaffold}/controller.rb +9 -4
  15. data/lib/generators/authorized_rails_scaffolds/{install_scaffold/templates → install_templates/templates/scaffold}/edit.html.erb +6 -2
  16. data/lib/generators/authorized_rails_scaffolds/{install_scaffold/templates → install_templates/templates/scaffold}/index.html.erb +8 -4
  17. data/lib/generators/authorized_rails_scaffolds/{install_scaffold/templates → install_templates/templates/scaffold}/new.html.erb +6 -2
  18. data/lib/generators/authorized_rails_scaffolds/{install_scaffold/templates → install_templates/templates/scaffold}/show.html.erb +8 -4
  19. data/lib/generators/authorized_rails_scaffolds/{install_spec/templates → install_templates/templates/spec}/controller_spec.rb +28 -23
  20. data/lib/generators/authorized_rails_scaffolds/{install_spec/templates → install_templates/templates/spec}/edit_spec.rb +16 -11
  21. data/lib/generators/authorized_rails_scaffolds/{install_spec/templates → install_templates/templates/spec}/index_spec.rb +10 -5
  22. data/lib/generators/authorized_rails_scaffolds/{install_spec/templates → install_templates/templates/spec}/model_spec.rb +0 -0
  23. data/lib/generators/authorized_rails_scaffolds/{install_spec/templates → install_templates/templates/spec}/new_spec.rb +16 -11
  24. data/lib/generators/authorized_rails_scaffolds/{install_spec/templates → install_templates/templates/spec}/routing_spec.rb +12 -22
  25. data/lib/generators/authorized_rails_scaffolds/{install_spec/templates → install_templates/templates/spec}/show_spec.rb +10 -5
  26. metadata +30 -27
  27. data/lib/generators/authorized_rails_scaffolds/install_scaffold/install_scaffold_generator.rb +0 -26
@@ -1,5 +1,4 @@
1
1
  require "authorized_rails_scaffolds/version"
2
- require "authorized_rails_scaffolds/helper"
3
2
 
4
3
  module AuthorizedRailsScaffolds
5
4
 
@@ -7,3 +6,8 @@ module AuthorizedRailsScaffolds
7
6
  @@parent_models = []
8
7
 
9
8
  end
9
+
10
+ require "authorized_rails_scaffolds/helper"
11
+ require "authorized_rails_scaffolds/controller_spec_helper"
12
+ require "authorized_rails_scaffolds/routing_spec_helper"
13
+ require "authorized_rails_scaffolds/view_spec_helper"
@@ -0,0 +1,31 @@
1
+ class AuthorizedRailsScaffolds::ControllerSpecHelper < AuthorizedRailsScaffolds::Helper
2
+
3
+ def initialize(options = {})
4
+ super options
5
+
6
+ @attributes = options[:attributes]
7
+ end
8
+
9
+ def create_factory_model
10
+ extra_params = extra_model_params
11
+ "FactoryGirl.create(:#{var_name}#{extra_params})"
12
+ end
13
+
14
+ def create_parent_model(model_name)
15
+ extra_params = extra_model_params(model_name)
16
+ "FactoryGirl.create(:#{model_name}#{extra_params})"
17
+ end
18
+
19
+ protected
20
+
21
+ def extra_model_params(model_name = nil)
22
+ argument_params = []
23
+ AuthorizedRailsScaffolds.parent_models.each do |parent_model|
24
+ attribute = parent_model.underscore
25
+ break if model_name == attribute
26
+ argument_params << ", :#{attribute} => @#{attribute}"
27
+ end
28
+ argument_params.join('')
29
+ end
30
+
31
+ end
@@ -2,20 +2,19 @@ module AuthorizedRailsScaffolds
2
2
 
3
3
  class Helper
4
4
 
5
- def initialize(class_name, singular_table_name, file_name, plural_file_name = nil)
6
- @local_class_name = class_name.split('::')[-1] # Non-Namespaced class name
7
- @var_name = file_name # Non-namespaced variable name
8
- @plural_var_name = plural_file_name || file_name.pluralize # Pluralized non-namespaced variable name
9
-
5
+ def initialize(options = {})
6
+ @local_class_name = options[:local_class_name] || options[:class_name].split('::')[-1]
7
+ @var_name = options[:var_name] || options[:file_name] # Non-namespaced variable name
8
+ @plural_var_name = options[:plural_var_name] || @var_name.pluralize # Pluralized non-namespaced variable name
10
9
  # Determine namespace prefix i.e awesome
11
- @namespace_prefix = singular_table_name[0..-(file_name.length + 2)]
10
+ @namespace_prefix = options[:namespace_prefix] || options[:singular_table_name][0..-(@var_name.length + 2)]
12
11
 
13
12
  # Determine Parent Prefix i.e. user_company
14
13
  parent_prefix = AuthorizedRailsScaffolds.parent_models.collect{ |x| x.underscore }.join('_')
15
- parent_prefix = "#{parent_prefix}_" unless parent_prefix.blank?
16
14
 
17
15
  # Route Prefix i.e. awesome_user_company
18
- @route_prefix = @namespace_prefix.blank? ? parent_prefix : "#{@namespace_prefix}_#{parent_prefix}"
16
+ route_prefix = [@namespace_prefix, parent_prefix].reject{ |x|x.blank? }.join('_')
17
+ @route_prefix = route_prefix.blank? ? '' : "#{route_prefix}_"
19
18
 
20
19
  @parent_variables = AuthorizedRailsScaffolds.parent_models.collect{ |x| "@#{x.underscore}" }.join(', ')
21
20
 
@@ -25,27 +24,21 @@ module AuthorizedRailsScaffolds
25
24
  @single_path_prefix = "#{@route_prefix}#{var_name}"
26
25
  end
27
26
 
27
+ # Non-namespaced class name (i.e. FooBar)
28
28
  def local_class_name
29
29
  @local_class_name
30
30
  end
31
31
 
32
+ # Non-namespaced variable name (i.e. foo_bar)
32
33
  def var_name
33
34
  @var_name
34
35
  end
35
36
 
37
+ # Pluralized non-namespaced variable name (i.e. foo_bars)
36
38
  def plural_var_name
37
39
  @plural_var_name
38
40
  end
39
41
 
40
- def create_model_with_attributes(attributes)
41
- extra_params = ''
42
- attribute = AuthorizedRailsScaffolds.parent_models.any? ? AuthorizedRailsScaffolds.parent_models.last.underscore : nil
43
- if attribute && attributes.collect{|a|a.name.underscore}.include?(attribute)
44
- extra_params = ", :#{attribute} => @#{attribute}"
45
- end
46
- "FactoryGirl.create(:#{var_name}#{extra_params})"
47
- end
48
-
49
42
  def form_object_array(variable = nil)
50
43
  variable ||= "@#{var_name}"
51
44
  namespace_prefix = ":#{@namespace_prefix}" unless @namespace_prefix.blank?
@@ -0,0 +1,29 @@
1
+ class AuthorizedRailsScaffolds::RoutingSpecHelper
2
+
3
+ def initialize(options = {})
4
+ @ns_table_name = options[:ns_table_name]
5
+ end
6
+
7
+ def extra_params
8
+ extra_params = ''
9
+ AuthorizedRailsScaffolds.parent_models.each_with_index do |model, model_index|
10
+ extra_params += ", :#{model.underscore}_id => \"#{model_index + 2}\""
11
+ end
12
+ extra_params
13
+ end
14
+
15
+ def request_path
16
+ # Remove last part of the path
17
+ parts = @ns_table_name.split('/')[0..-2] || []
18
+
19
+ AuthorizedRailsScaffolds.parent_models.each_with_index do |model, model_index|
20
+ parts << model.underscore.pluralize
21
+ parts << model_index + 2
22
+ end
23
+
24
+ # Add Final Part
25
+ parts << @ns_table_name.split('/')[-1]
26
+ parts.join('/')
27
+ end
28
+
29
+ end
@@ -1,3 +1,3 @@
1
1
  module AuthorizedRailsScaffolds
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -0,0 +1,49 @@
1
+ class AuthorizedRailsScaffolds::ViewSpecHelper < AuthorizedRailsScaffolds::Helper
2
+
3
+ def initialize(options = {})
4
+ super options
5
+
6
+ @attributes = options[:attributes]
7
+ end
8
+
9
+ def output_attributes
10
+ @output_attributes ||= @attributes.reject{|attribute| [:timestamp].include? attribute.type }
11
+ end
12
+
13
+ def references_attributes
14
+ @references_attributes ||= @attributes.reject{|attribute| ![:references].include? attribute.type }
15
+ end
16
+
17
+ def standard_attributes
18
+ @standard_attributes ||= @attributes.reject{|attribute| [:time, :date, :datetime].include? attribute.type }
19
+ end
20
+
21
+ def datetime_attributes
22
+ @datetime_attributes ||= @attributes.reject{|attribute| ![:time, :date, :datetime].include? attribute.type }
23
+ end
24
+
25
+ def date_select_year_value(date_string)
26
+ DateTime.parse(date_string).strftime('%Y')
27
+ end
28
+
29
+ def date_select_month_value(date_string)
30
+ DateTime.parse(date_string).strftime('%-m')
31
+ end
32
+
33
+ def date_select_month_text(date_string)
34
+ DateTime.parse(date_string).strftime('%B')
35
+ end
36
+
37
+ def date_select_day_value(date_string)
38
+ DateTime.parse(date_string).strftime('%-d')
39
+ end
40
+
41
+ def date_select_hour_value(date_string)
42
+ DateTime.parse(date_string).strftime('%H')
43
+ end
44
+
45
+ def date_select_minute_value(date_string)
46
+ DateTime.parse(date_string).strftime('%M')
47
+ end
48
+
49
+ end
@@ -2,8 +2,8 @@ Description:
2
2
  Installs rspec templates that offer better coverage than the default rspec templates
3
3
 
4
4
  Example:
5
- rails generate authorized_rails_scaffolds:install_spec
5
+ rails generate authorized_rails_scaffolds:install_macros
6
6
 
7
7
  This will create:
8
- RSpec controller and view spec templates in lib/rspec/scaffold
8
+ Controller spec macros in spec/support
9
9
 
@@ -1,22 +1,9 @@
1
- class AuthorizedRailsScaffolds::InstallSpecGenerator < Rails::Generators::Base
1
+ class AuthorizedRailsScaffolds::InstallMacrosGenerator < Rails::Generators::Base
2
2
  source_root File.expand_path('../templates', __FILE__)
3
3
 
4
4
  class_option :authentication, :type => 'string', :default => 'devise', :desc => "Authentication Provider (Devise)"
5
5
  class_option :authorization, :type => 'string', :default => 'can_can', :desc => "Authorization Provider (CanCan)"
6
6
 
7
- def create_model_templates
8
- copy_model_template 'model_spec.rb'
9
- end
10
-
11
- def create_scaffold_templates
12
- copy_scaffold_template 'controller_spec.rb'
13
- copy_scaffold_template 'edit_spec.rb'
14
- copy_scaffold_template 'index_spec.rb'
15
- copy_scaffold_template 'new_spec.rb'
16
- copy_scaffold_template 'show_spec.rb'
17
- copy_scaffold_template 'routing_spec.rb'
18
- end
19
-
20
7
  def create_controller_macros
21
8
  parts = []
22
9
  parts << options[:authentication].underscore unless options[:authentication].nil?
@@ -27,14 +14,4 @@ class AuthorizedRailsScaffolds::InstallSpecGenerator < Rails::Generators::Base
27
14
  readme [template_file, 'USAGE'].join('/')
28
15
  end
29
16
 
30
- protected
31
-
32
- def copy_model_template(template_name)
33
- copy_file template_name, "lib/templates/rspec/model/#{template_name}"
34
- end
35
-
36
- def copy_scaffold_template(template_name)
37
- copy_file template_name, "lib/templates/rspec/scaffold/#{template_name}"
38
- end
39
-
40
17
  end
@@ -7,3 +7,4 @@ Example:
7
7
  This will create:
8
8
  ERB view templates in lib/erb/scaffold
9
9
  Scaffold controller templates in lib/rails/scaffold_controller
10
+ RSpec controller and view spec templates in lib/rspec/scaffold
@@ -0,0 +1,51 @@
1
+ class AuthorizedRailsScaffolds::InstallTemplatesGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def copy_rails_templates
5
+ # Controller Templates
6
+ copy_rails_scaffold_controller 'controller.rb'
7
+
8
+ # View Templates (erb)
9
+ copy_erb_scaffold_template '_form.html.erb'
10
+ copy_erb_scaffold_template 'edit.html.erb'
11
+ copy_erb_scaffold_template 'index.html.erb'
12
+ copy_erb_scaffold_template 'new.html.erb'
13
+ copy_erb_scaffold_template 'show.html.erb'
14
+ end
15
+
16
+ def create_spec_templates
17
+ # Controller Spec Templates
18
+ copy_rspec_scaffold_template 'controller_spec.rb'
19
+
20
+ # Model Spec Templates
21
+ copy_rspec_model_template 'model_spec.rb'
22
+
23
+ # Routing Spec Templates
24
+ copy_rspec_scaffold_template 'routing_spec.rb'
25
+
26
+ # View Spec Templates
27
+ copy_rspec_scaffold_template 'edit_spec.rb'
28
+ copy_rspec_scaffold_template 'index_spec.rb'
29
+ copy_rspec_scaffold_template 'new_spec.rb'
30
+ copy_rspec_scaffold_template 'show_spec.rb'
31
+ end
32
+
33
+ protected
34
+
35
+ def copy_erb_scaffold_template(template_name)
36
+ copy_file "scaffold/#{template_name}", "lib/templates/erb/scaffold/#{template_name}"
37
+ end
38
+
39
+ def copy_rails_scaffold_controller(template_name)
40
+ copy_file "scaffold/#{template_name}", "lib/templates/rails/scaffold_controller/#{template_name}"
41
+ end
42
+
43
+ def copy_rspec_model_template(template_name)
44
+ copy_file "spec/#{template_name}", "lib/templates/rspec/model/#{template_name}"
45
+ end
46
+
47
+ def copy_rspec_scaffold_template(template_name)
48
+ copy_file "spec/#{template_name}", "lib/templates/rspec/scaffold/#{template_name}"
49
+ end
50
+
51
+ end
@@ -1,10 +1,14 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
3
+ t_helper = AuthorizedRailsScaffolds::Helper.new(
4
+ :class_name => class_name,
5
+ :singular_table_name => singular_table_name,
6
+ :file_name => file_name
7
+ )
4
8
 
5
- local_class_name = file_name.classify # Non-Namespaced class name
6
- var_name = file_name # Non-namespaced variable name
7
- plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
9
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
10
+ var_name = t_helper.var_name # Non-namespaced variable name
11
+ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
8
12
 
9
13
  -%>
10
14
  <%%= simple_form_for(<%= t_helper.form_object_array %>, :html => { class: 'form-horizontal' }) do |f| %>
@@ -4,12 +4,17 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
4
4
  <% end -%>
5
5
  <%-
6
6
 
7
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
7
+ t_helper = AuthorizedRailsScaffolds::Helper.new(
8
+ :class_name => class_name,
9
+ :singular_table_name => singular_table_name,
10
+ :file_name => file_name
11
+ )
8
12
 
9
- local_class_name = local_class_name = class_name.split("::")[-1] # Non-Namespaced class name
10
- var_name = file_name # Non-namespaced variable name
11
- plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
13
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
14
+ var_name = t_helper.var_name # Non-namespaced variable name
15
+ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
12
16
 
17
+ # Override default orm instance
13
18
  orm_instance = Rails::Generators::ActiveModel.new var_name
14
19
 
15
20
  -%>
@@ -1,8 +1,12 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
3
+ t_helper = AuthorizedRailsScaffolds::Helper.new(
4
+ :class_name => class_name,
5
+ :singular_table_name => singular_table_name,
6
+ :file_name => file_name
7
+ )
4
8
 
5
- local_class_name = file_name.classify # Non-Namespaced class name
9
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
6
10
 
7
11
  -%>
8
12
  <%%- model_class = <%= local_class_name %> -%>
@@ -1,10 +1,14 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
3
+ t_helper = AuthorizedRailsScaffolds::Helper.new(
4
+ :class_name => class_name,
5
+ :singular_table_name => singular_table_name,
6
+ :file_name => file_name
7
+ )
4
8
 
5
- local_class_name = file_name.classify # Non-Namespaced class name
6
- var_name = file_name # Non-namespaced variable name
7
- plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
9
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
10
+ var_name = t_helper.var_name # Non-namespaced variable name
11
+ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
8
12
 
9
13
  -%>
10
14
  <%%- model_class = <%= local_class_name %> -%>
@@ -1,8 +1,12 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
3
+ t_helper = AuthorizedRailsScaffolds::Helper.new(
4
+ :class_name => class_name,
5
+ :singular_table_name => singular_table_name,
6
+ :file_name => file_name
7
+ )
4
8
 
5
- local_class_name = file_name.classify # Non-Namespaced class name
9
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
6
10
 
7
11
  -%>
8
12
  <%%- model_class = <%= local_class_name %> -%>
@@ -1,10 +1,14 @@
1
1
  <%-
2
2
 
3
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
3
+ t_helper = AuthorizedRailsScaffolds::Helper.new(
4
+ :class_name => class_name,
5
+ :singular_table_name => singular_table_name,
6
+ :file_name => file_name
7
+ )
4
8
 
5
- local_class_name = file_name.classify # Non-Namespaced class name
6
- var_name = file_name # Non-namespaced variable name
7
- plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
9
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
10
+ var_name = t_helper.var_name # Non-namespaced variable name
11
+ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
8
12
 
9
13
  -%>
10
14
  <%%- model_class = <%= local_class_name %> -%>
@@ -21,11 +21,16 @@ require 'spec_helper'
21
21
  <% module_namespacing do -%>
22
22
  <%-
23
23
 
24
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
24
+ t_helper = AuthorizedRailsScaffolds::ControllerSpecHelper.new(
25
+ :class_name => class_name,
26
+ :singular_table_name => singular_table_name,
27
+ :file_name => file_name,
28
+ :attributes => attributes
29
+ )
25
30
 
26
- local_class_name = class_name.split('::')[-1] # Non-Namespaced class name
27
- var_name = file_name # Non-namespaced variable name
28
- plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
31
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
32
+ var_name = t_helper.var_name # Non-namespaced variable name
33
+ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
29
34
 
30
35
  -%>
31
36
  describe <%= controller_class_name %>Controller do
@@ -45,7 +50,7 @@ describe <%= controller_class_name %>Controller do
45
50
  <%- if AuthorizedRailsScaffolds.parent_models.any? -%>
46
51
  before(:each) do
47
52
  <%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
48
- @<%= model.underscore %> = FactoryGirl.create(:<%= model.underscore %>)
53
+ @<%= model.underscore %> = <%= t_helper.create_parent_model model.underscore %>
49
54
  <%- end -%>
50
55
  end
51
56
 
@@ -55,7 +60,7 @@ describe <%= controller_class_name %>Controller do
55
60
  context 'without a user' do
56
61
  describe 'with valid request' do
57
62
  before(:each) do
58
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
63
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
59
64
  get :index, {<%= t_helper.index_action_params_prefix %>}
60
65
  end
61
66
  it { should redirect_to(new_user_session_path) }
@@ -66,7 +71,7 @@ describe <%= controller_class_name %>Controller do
66
71
  login_unauthorized_user
67
72
  describe 'with valid request' do
68
73
  before(:each) do
69
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
74
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
70
75
  get :index, {<%= t_helper.index_action_params_prefix %>}
71
76
  end
72
77
  it { should redirect_to(root_url) }
@@ -77,7 +82,7 @@ describe <%= controller_class_name %>Controller do
77
82
  login_user_with_ability :read, <%= local_class_name %>
78
83
  describe 'with valid request' do
79
84
  before(:each) do
80
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
85
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
81
86
  get :index, {<%= t_helper.index_action_params_prefix %>}
82
87
  end
83
88
  it { should respond_with(:success) }
@@ -95,7 +100,7 @@ describe <%= controller_class_name %>Controller do
95
100
  context 'without a user' do
96
101
  describe 'with valid request' do
97
102
  before(:each) do
98
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
103
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
99
104
  get :show, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
100
105
  end
101
106
  it { should redirect_to(new_user_session_path) }
@@ -106,7 +111,7 @@ describe <%= controller_class_name %>Controller do
106
111
  login_unauthorized_user
107
112
  describe 'with valid request' do
108
113
  before(:each) do
109
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
114
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
110
115
  get :show, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
111
116
  end
112
117
  it { should redirect_to(<%= t_helper.controller_index_route %>) }
@@ -117,7 +122,7 @@ describe <%= controller_class_name %>Controller do
117
122
  login_user_with_ability :read, <%= local_class_name %>
118
123
  describe 'with valid request' do
119
124
  before(:each) do
120
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
125
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
121
126
  get :show, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
122
127
  end
123
128
  it { should respond_with(:success) }
@@ -170,7 +175,7 @@ describe <%= controller_class_name %>Controller do
170
175
  context 'without a user' do
171
176
  describe 'with valid request' do
172
177
  before(:each) do
173
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
178
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
174
179
  get :edit, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
175
180
  end
176
181
  it { should redirect_to(new_user_session_path) }
@@ -181,7 +186,7 @@ describe <%= controller_class_name %>Controller do
181
186
  login_unauthorized_user
182
187
  describe 'with valid request' do
183
188
  before(:each) do
184
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
189
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
185
190
  get :edit, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
186
191
  end
187
192
  it { should redirect_to(<%= t_helper.controller_index_route %>) }
@@ -192,7 +197,7 @@ describe <%= controller_class_name %>Controller do
192
197
  login_user_with_ability :update, <%= local_class_name %>
193
198
  describe 'with valid request' do
194
199
  before(:each) do
195
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
200
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
196
201
  get :edit, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
197
202
  end
198
203
  it { should respond_with(:success) }
@@ -265,7 +270,7 @@ describe <%= controller_class_name %>Controller do
265
270
  context 'without a user' do
266
271
  describe 'with valid params' do
267
272
  before(:each) do
268
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
273
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
269
274
  put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => valid_update_attributes}
270
275
  end
271
276
  it { should redirect_to(new_user_session_path) }
@@ -276,7 +281,7 @@ describe <%= controller_class_name %>Controller do
276
281
  login_unauthorized_user
277
282
  describe "with valid params" do
278
283
  before(:each) do
279
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
284
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
280
285
  put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => valid_update_attributes}
281
286
  end
282
287
  it { should redirect_to(<%= t_helper.controller_index_route %>) }
@@ -287,7 +292,7 @@ describe <%= controller_class_name %>Controller do
287
292
  login_user_with_ability :update, <%= local_class_name %>
288
293
  describe "with valid params" do
289
294
  it "updates the requested <%= var_name %>" do
290
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
295
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
291
296
  # Assuming there are no other <%= var_name %> in the database, this
292
297
  # specifies that the <%= local_class_name %> created on the previous line
293
298
  # receives the :update_attributes message with whatever params are
@@ -302,7 +307,7 @@ describe <%= controller_class_name %>Controller do
302
307
  end
303
308
  describe "with valid params" do
304
309
  before(:each) do
305
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
310
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
306
311
  put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => valid_update_attributes}
307
312
  end
308
313
  it "assigns the requested <%= var_name %> as @<%= var_name %>" do
@@ -314,7 +319,7 @@ describe <%= controller_class_name %>Controller do
314
319
  end
315
320
  describe "with invalid params" do
316
321
  before(:each) do
317
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
322
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
318
323
  # Trigger the behavior that occurs when invalid params are submitted
319
324
  <%= local_class_name %>.any_instance.stub(:save).and_return(false)
320
325
  put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => <%= formatted_hash(example_invalid_attributes) %>}
@@ -332,7 +337,7 @@ describe <%= controller_class_name %>Controller do
332
337
  context 'without a user' do
333
338
  describe 'with valid request' do
334
339
  before(:each) do
335
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
340
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
336
341
  delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
337
342
  end
338
343
  it { should redirect_to(new_user_session_path) }
@@ -343,7 +348,7 @@ describe <%= controller_class_name %>Controller do
343
348
  login_unauthorized_user
344
349
  describe "with valid request" do
345
350
  before(:each) do
346
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
351
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
347
352
  delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
348
353
  end
349
354
  it { should redirect_to(<%= t_helper.controller_index_route %>) }
@@ -353,14 +358,14 @@ describe <%= controller_class_name %>Controller do
353
358
  context 'as user with destroy ability' do
354
359
  login_user_with_ability :destroy, <%= local_class_name %>
355
360
  it "destroys the requested <%= var_name %>" do
356
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
361
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
357
362
  expect {
358
363
  delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
359
364
  }.to change(<%= local_class_name %>, :count).by(-1)
360
365
  end
361
366
  describe 'with valid request' do
362
367
  before(:each) do
363
- @<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
368
+ @<%= var_name %> = <%= t_helper.create_factory_model %>
364
369
  delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
365
370
  end
366
371
  it "redirects to the <%= var_name %> list" do
@@ -2,14 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  <%-
4
4
 
5
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
5
+ t_helper = AuthorizedRailsScaffolds::ViewSpecHelper.new(
6
+ :class_name => class_name,
7
+ :singular_table_name => singular_table_name,
8
+ :file_name => file_name,
9
+ :attributes => attributes
10
+ )
6
11
 
7
- local_class_name = class_name.split('::')[-1] # Non-Namespaced class name
8
- var_name = file_name # Non-namespaced variable name
12
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
13
+ var_name = t_helper.var_name # Non-namespaced variable name
9
14
 
10
- output_attributes = attributes.reject{|attribute| [:timestamp].include? attribute.type }
11
- standard_attributes = attributes.reject{|attribute| [:time, :date, :datetime].include? attribute.type }
12
- datetime_attributes = attributes.reject{|attribute| ![:time, :date, :datetime].include? attribute.type }
15
+ output_attributes = t_helper.output_attributes
16
+ standard_attributes = t_helper.standard_attributes
17
+ datetime_attributes = t_helper.datetime_attributes
13
18
 
14
19
  -%>
15
20
  describe "<%= ns_table_name %>/edit" do
@@ -76,21 +81,21 @@ describe "<%= ns_table_name %>/edit" do
76
81
  # <%= attribute.name %> values
77
82
  <%- if [:date, :datetime].include? attribute.type -%>
78
83
  assert_select "select#<%= var_name %>_<%= attribute.name %>_1i[name=?]", "<%= var_name %>[<%= attribute.name %>(1i)]" do
79
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%Y').dump %>, :count => 1
84
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_year_value attribute.default %>", :count => 1
80
85
  end
81
86
  assert_select "select#<%= var_name %>_<%= attribute.name %>_2i[name=?]", "<%= var_name %>[<%= attribute.name %>(2i)]" do
82
- assert_select "option[selected=selected][value=?]", <%= DateTime.parse(attribute.default).strftime('%-m').dump %>, :text => <%= DateTime.parse(attribute.default).strftime('%B').dump %>, :count => 1
87
+ assert_select "option[selected=selected][value=?]", "<%= t_helper.date_select_month_value attribute.default %>", :text => "<%= t_helper.date_select_month_text attribute.default %>", :count => 1
83
88
  end
84
89
  assert_select "select#<%= var_name %>_<%= attribute.name %>_3i[name=?]", "<%= var_name %>[<%= attribute.name %>(3i)]" do
85
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%d').dump %>, :count => 1
90
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_day_value attribute.default %>", :count => 1
86
91
  end
87
92
  <%- end -%>
88
93
  <%- if [:time, :datetime].include? attribute.type -%>
89
94
  assert_select "select#<%= var_name %>_<%= attribute.name %>_4i[name=?]", "<%= var_name %>[<%= attribute.name %>(4i)]" do
90
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%H').dump %>, :count => 1
95
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_hour_value attribute.default %>", :count => 1
91
96
  end
92
97
  assert_select "select#<%= var_name %>_<%= attribute.name %>_5i[name=?]", "<%= var_name %>[<%= attribute.name %>(5i)]" do
93
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%M').dump %>, :count => 1
98
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_minute_value attribute.default %>", :count => 1
94
99
  end
95
100
  <%- end -%>
96
101
  <% end -%>
@@ -2,13 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  <%-
4
4
 
5
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
5
+ t_helper = AuthorizedRailsScaffolds::ViewSpecHelper.new(
6
+ :class_name => class_name,
7
+ :singular_table_name => singular_table_name,
8
+ :file_name => file_name,
9
+ :attributes => attributes
10
+ )
6
11
 
7
- local_class_name = class_name.split('::')[-1] # Non-Namespaced class name
8
- var_name = file_name # Non-namespaced variable name
9
- plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
12
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
13
+ var_name = t_helper.var_name # Non-namespaced variable name
14
+ plural_var_name = t_helper.plural_var_name # Pluralized non-namespaced variable name
10
15
 
11
- output_attributes = attributes.reject{|attribute| [:timestamp].include? attribute.type }
16
+ output_attributes = t_helper.output_attributes
12
17
 
13
18
  -%>
14
19
  describe "<%= ns_table_name %>/index" do
@@ -2,14 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  <%-
4
4
 
5
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
5
+ t_helper = AuthorizedRailsScaffolds::ViewSpecHelper.new(
6
+ :class_name => class_name,
7
+ :singular_table_name => singular_table_name,
8
+ :file_name => file_name,
9
+ :attributes => attributes
10
+ )
6
11
 
7
- local_class_name = class_name.split('::')[-1] # Non-Namespaced class name
8
- var_name = file_name # Non-namespaced variable name
12
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
13
+ var_name = t_helper.var_name # Non-namespaced variable name
9
14
 
10
- output_attributes = attributes.reject{|attribute| [:timestamp].include? attribute.type }
11
- standard_attributes = attributes.reject{|attribute| [:time, :date, :datetime].include? attribute.type }
12
- datetime_attributes = attributes.reject{|attribute| ![:time, :date, :datetime].include? attribute.type }
15
+ output_attributes = t_helper.output_attributes
16
+ standard_attributes = t_helper.standard_attributes
17
+ datetime_attributes = t_helper.datetime_attributes
13
18
 
14
19
  -%>
15
20
  describe "<%= ns_table_name %>/new" do
@@ -75,21 +80,21 @@ describe "<%= ns_table_name %>/new" do
75
80
  # <%= attribute.name %> values
76
81
  <%- if [:date, :datetime].include? attribute.type -%>
77
82
  assert_select "select#<%= var_name %>_<%= attribute.name %>_1i[name=?]", "<%= var_name %>[<%= attribute.name %>(1i)]" do
78
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%Y').dump %>, :count => 1
83
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_year_value attribute.default %>", :count => 1
79
84
  end
80
85
  assert_select "select#<%= var_name %>_<%= attribute.name %>_2i[name=?]", "<%= var_name %>[<%= attribute.name %>(2i)]" do
81
- assert_select "option[selected=selected][value=?]", <%= DateTime.parse(attribute.default).strftime('%-m').dump %>, :text => <%= DateTime.parse(attribute.default).strftime('%B').dump %>, :count => 1
86
+ assert_select "option[selected=selected][value=?]", "<%= t_helper.date_select_month_value attribute.default %>", :text => "<%= t_helper.date_select_month_text attribute.default %>", :count => 1
82
87
  end
83
88
  assert_select "select#<%= var_name %>_<%= attribute.name %>_3i[name=?]", "<%= var_name %>[<%= attribute.name %>(3i)]" do
84
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%d').dump %>, :count => 1
89
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_day_value attribute.default %>", :count => 1
85
90
  end
86
91
  <%- end -%>
87
92
  <%- if [:time, :datetime].include? attribute.type -%>
88
93
  assert_select "select#<%= var_name %>_<%= attribute.name %>_4i[name=?]", "<%= var_name %>[<%= attribute.name %>(4i)]" do
89
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%H').dump %>, :count => 1
94
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_hour_value attribute.default %>", :count => 1
90
95
  end
91
96
  assert_select "select#<%= var_name %>_<%= attribute.name %>_5i[name=?]", "<%= var_name %>[<%= attribute.name %>(5i)]" do
92
- assert_select "option[selected=selected]", :text => <%= DateTime.parse(attribute.default).strftime('%M').dump %>, :count => 1
97
+ assert_select "option[selected=selected]", :text => "<%= t_helper.date_select_minute_value attribute.default %>", :count => 1
93
98
  end
94
99
  <%- end -%>
95
100
  <% end -%>
@@ -3,22 +3,12 @@ require "spec_helper"
3
3
  <% module_namespacing do -%>
4
4
  <%-
5
5
 
6
- parts = ns_table_name.split('/')[0..-2] || []
6
+ t_helper = AuthorizedRailsScaffolds::RoutingSpecHelper.new(
7
+ ns_table_name: ns_table_name
8
+ )
7
9
 
8
- AuthorizedRailsScaffolds.parent_models.each_with_index do |model, model_index|
9
- parts << model.underscore.pluralize
10
- parts << model_index + 2
11
- end
12
-
13
- parts << ns_table_name.split('/')[-1]
14
- request_path = parts.join('/')
15
-
16
- extra_arguments = ''
17
- if AuthorizedRailsScaffolds.parent_models.any?
18
- AuthorizedRailsScaffolds.parent_models.each_with_index do |model, model_index|
19
- extra_arguments += ", :#{model.underscore}_id => \"#{model_index + 2}\""
20
- end
21
- end
10
+ request_path = t_helper.request_path
11
+ extra_params = t_helper.extra_params
22
12
 
23
13
  -%>
24
14
  describe <%= controller_class_name %>Controller do
@@ -26,32 +16,32 @@ describe <%= controller_class_name %>Controller do
26
16
 
27
17
  <% unless options[:singleton] -%>
28
18
  it "routes to #index" do
29
- get("/<%= request_path %>").should route_to("<%= ns_table_name %>#index"<%= extra_arguments %>)
19
+ get("/<%= request_path %>").should route_to("<%= ns_table_name %>#index"<%= extra_params %>)
30
20
  end
31
21
 
32
22
  <% end -%>
33
23
  it "routes to #new" do
34
- get("/<%= request_path %>/new").should route_to("<%= ns_table_name %>#new"<%= extra_arguments %>)
24
+ get("/<%= request_path %>/new").should route_to("<%= ns_table_name %>#new"<%= extra_params %>)
35
25
  end
36
26
 
37
27
  it "routes to #show" do
38
- get("/<%= request_path %>/1").should route_to("<%= ns_table_name %>#show"<%= extra_arguments %>, :id => "1")
28
+ get("/<%= request_path %>/1").should route_to("<%= ns_table_name %>#show"<%= extra_params %>, :id => "1")
39
29
  end
40
30
 
41
31
  it "routes to #edit" do
42
- get("/<%= request_path %>/1/edit").should route_to("<%= ns_table_name %>#edit"<%= extra_arguments %>, :id => "1")
32
+ get("/<%= request_path %>/1/edit").should route_to("<%= ns_table_name %>#edit"<%= extra_params %>, :id => "1")
43
33
  end
44
34
 
45
35
  it "routes to #create" do
46
- post("/<%= request_path %>").should route_to("<%= ns_table_name %>#create"<%= extra_arguments %>)
36
+ post("/<%= request_path %>").should route_to("<%= ns_table_name %>#create"<%= extra_params %>)
47
37
  end
48
38
 
49
39
  it "routes to #update" do
50
- put("/<%= request_path %>/1").should route_to("<%= ns_table_name %>#update"<%= extra_arguments %>, :id => "1")
40
+ put("/<%= request_path %>/1").should route_to("<%= ns_table_name %>#update"<%= extra_params %>, :id => "1")
51
41
  end
52
42
 
53
43
  it "routes to #destroy" do
54
- delete("/<%= request_path %>/1").should route_to("<%= ns_table_name %>#destroy"<%= extra_arguments %>, :id => "1")
44
+ delete("/<%= request_path %>/1").should route_to("<%= ns_table_name %>#destroy"<%= extra_params %>, :id => "1")
55
45
  end
56
46
 
57
47
  end
@@ -2,13 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  <%-
4
4
 
5
- t_helper = AuthorizedRailsScaffolds::Helper.new(class_name, singular_table_name, file_name)
5
+ t_helper = AuthorizedRailsScaffolds::ViewSpecHelper.new(
6
+ :class_name => class_name,
7
+ :singular_table_name => singular_table_name,
8
+ :file_name => file_name,
9
+ :attributes => attributes
10
+ )
6
11
 
7
- local_class_name = class_name.split('::')[-1] # Non-Namespaced class name
8
- var_name = file_name # Non-namespaced variable name
12
+ local_class_name = t_helper.local_class_name # Non-Namespaced class name
13
+ var_name = t_helper.var_name # Non-namespaced variable name
9
14
 
10
- output_attributes = attributes.reject{|attribute| [:timestamp, :references].include? attribute.type }
11
- references_attributes = attributes.reject{|attribute| ![:references].include? attribute.type }
15
+ output_attributes = t_helper.output_attributes
16
+ references_attributes = t_helper.references_attributes
12
17
 
13
18
  -%>
14
19
  describe "<%= ns_table_name %>/show" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authorized_rails_scaffolds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-26 00:00:00.000000000Z
12
+ date: 2013-04-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70121345852780 !ruby/object:Gem::Requirement
16
+ requirement: &70235954660960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70121345852780
24
+ version_requirements: *70235954660960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70121345852280 !ruby/object:Gem::Requirement
27
+ requirement: &70235954660460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.3'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70121345852280
35
+ version_requirements: *70235954660460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70121345851900 !ruby/object:Gem::Requirement
38
+ requirement: &70235954660080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70121345851900
46
+ version_requirements: *70235954660080
47
47
  description: Creates scaffolds for Twitter Bootstrap with generated RSpec coverage
48
48
  email:
49
49
  - bemo56@hotmail.com
@@ -58,27 +58,30 @@ files:
58
58
  - Rakefile
59
59
  - authorized_rails_scaffolds.gemspec
60
60
  - lib/authorized_rails_scaffolds.rb
61
+ - lib/authorized_rails_scaffolds/controller_spec_helper.rb
61
62
  - lib/authorized_rails_scaffolds/helper.rb
63
+ - lib/authorized_rails_scaffolds/routing_spec_helper.rb
62
64
  - lib/authorized_rails_scaffolds/version.rb
63
- - lib/generators/authorized_rails_scaffolds/install_scaffold/USAGE
64
- - lib/generators/authorized_rails_scaffolds/install_scaffold/install_scaffold_generator.rb
65
- - lib/generators/authorized_rails_scaffolds/install_scaffold/templates/_form.html.erb
66
- - lib/generators/authorized_rails_scaffolds/install_scaffold/templates/controller.rb
67
- - lib/generators/authorized_rails_scaffolds/install_scaffold/templates/edit.html.erb
68
- - lib/generators/authorized_rails_scaffolds/install_scaffold/templates/index.html.erb
69
- - lib/generators/authorized_rails_scaffolds/install_scaffold/templates/new.html.erb
70
- - lib/generators/authorized_rails_scaffolds/install_scaffold/templates/show.html.erb
71
- - lib/generators/authorized_rails_scaffolds/install_spec/USAGE
72
- - lib/generators/authorized_rails_scaffolds/install_spec/install_spec_generator.rb
73
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/controller_spec.rb
74
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/devise_can_can/USAGE
75
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/devise_can_can/controller_macros.rb
76
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/edit_spec.rb
77
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/index_spec.rb
78
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/model_spec.rb
79
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/new_spec.rb
80
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/routing_spec.rb
81
- - lib/generators/authorized_rails_scaffolds/install_spec/templates/show_spec.rb
65
+ - lib/authorized_rails_scaffolds/view_spec_helper.rb
66
+ - lib/generators/authorized_rails_scaffolds/install_macros/USAGE
67
+ - lib/generators/authorized_rails_scaffolds/install_macros/install_macros_generator.rb
68
+ - lib/generators/authorized_rails_scaffolds/install_macros/templates/devise_can_can/USAGE
69
+ - lib/generators/authorized_rails_scaffolds/install_macros/templates/devise_can_can/controller_macros.rb
70
+ - lib/generators/authorized_rails_scaffolds/install_templates/USAGE
71
+ - lib/generators/authorized_rails_scaffolds/install_templates/install_templates_generator.rb
72
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/_form.html.erb
73
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/controller.rb
74
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/edit.html.erb
75
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/index.html.erb
76
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/new.html.erb
77
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/scaffold/show.html.erb
78
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/controller_spec.rb
79
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/edit_spec.rb
80
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/index_spec.rb
81
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/model_spec.rb
82
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/new_spec.rb
83
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/routing_spec.rb
84
+ - lib/generators/authorized_rails_scaffolds/install_templates/templates/spec/show_spec.rb
82
85
  homepage: https://github.com/bmorrall/authorized_rails_scaffolds
83
86
  licenses:
84
87
  - MIT
@@ -1,26 +0,0 @@
1
- class AuthorizedRailsScaffolds::InstallScaffoldGenerator < Rails::Generators::Base
2
- source_root File.expand_path('../templates', __FILE__)
3
-
4
- def create_erb_templates
5
- copy_erb_template '_form.html.erb'
6
- copy_erb_template 'edit.html.erb'
7
- copy_erb_template 'index.html.erb'
8
- copy_erb_template 'new.html.erb'
9
- copy_erb_template 'show.html.erb'
10
- end
11
-
12
- def copy_rails_templates
13
- copy_rails_template 'controller.rb'
14
- end
15
-
16
- protected
17
-
18
- def copy_erb_template(template_name)
19
- copy_file template_name, "lib/templates/erb/scaffold/#{template_name}"
20
- end
21
-
22
- def copy_rails_template(template_name)
23
- copy_file template_name, "lib/templates/rails/scaffold_controller/#{template_name}"
24
- end
25
-
26
- end