admin-panel 0.1.1 → 0.1.2

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +3 -3
  4. data/admin-panel.gemspec +20 -20
  5. data/lib/admin-panel/version.rb +1 -1
  6. data/lib/generators/admin_panel/install/install_generator.rb +43 -43
  7. data/lib/generators/admin_panel/install/templates/controllers/admin/dashboard_controller.rb +1 -1
  8. data/lib/generators/admin_panel/install/templates/controllers/admin/passwords_controller.rb +2 -2
  9. data/lib/generators/admin_panel/install/templates/controllers/admin/sessions_controller.rb +2 -2
  10. data/lib/generators/admin_panel/install/templates/controllers/concerns/administrable.rb +6 -6
  11. data/lib/generators/admin_panel/install/templates/helpers/admin_helper.rb +15 -15
  12. data/lib/generators/admin_panel/install/templates/layouts/admin/_messages.html.erb +6 -6
  13. data/lib/generators/admin_panel/install/templates/layouts/admin/_navigation.html.erb +17 -17
  14. data/lib/generators/admin_panel/install/templates/layouts/admin/application.html.erb +15 -15
  15. data/lib/generators/admin_panel/install/templates/views/admin/passwords/new.html.erb +0 -2
  16. data/lib/generators/admin_panel/install/templates/views/admin/sessions/new.html.erb +2 -2
  17. data/lib/generators/admin_panel/scaffold/scaffold_generator.rb +160 -159
  18. data/lib/generators/admin_panel/scaffold/templates/views/erb/edit.html.erb.erb +8 -8
  19. data/lib/generators/admin_panel/scaffold/templates/views/erb/index.html.erb.erb +28 -28
  20. data/lib/generators/admin_panel/scaffold/templates/views/erb/new.html.erb.erb +8 -8
  21. data/lib/generators/admin_panel/scaffold/templates/views/erb/show.html.erb.erb +13 -13
  22. data/spec/dummy/bin/rails +5 -5
  23. data/spec/dummy/config/routes.rb +1 -1
  24. data/spec/generators/admin_panel/install/install_generator_spec.rb +54 -54
  25. data/spec/generators/admin_panel/scaffold/scaffold_generator_spec.rb +21 -21
  26. data/spec/spec_helper.rb +5 -5
  27. metadata +1 -2
  28. data/lib/generators/admin_panel/scaffold/templates/tests/test_unit/functional_test.rb.erb +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c96a278ce1dccbb7d6fda1287e6f781f03ef4c1f
4
- data.tar.gz: d530c33c41257ab358903d449cbb981ec8cd3274
3
+ metadata.gz: 2bbe264a8f0f9ce2982096d8dc4b8873c1cdf736
4
+ data.tar.gz: 3bb81974a0670450b6530da533311a6325dd5edb
5
5
  SHA512:
6
- metadata.gz: 181503a3fce3ae206b4e07916ed74a03d260d708aa70ca22773d5b130b095b05c42946a303d5319d6574f1307df3d89fc800db61c319d77adb9bc328f33753da
7
- data.tar.gz: 5c3bac9ec7cf6d4370cc628006c5d9d75badec9ad3a1337ce18c52989c14aec8d17bf1531750f403b1c3615e9b0965405d5a9f62e8bbc7792eca5c28382723fc
6
+ metadata.gz: bf8e131f97cc7c676133a242eff4c57a49627f8ad229f2d783fbe86ce5429d4b48bb8444d818127c56307ef6b6e827216b5a788dfdc5eaa5d56bd9562a2e8b7b
7
+ data.tar.gz: 4ad86baa443f5c7c2e6cbf594f3dc11270cc833b316fae60c34b1aabc43fb6b5d3432fa285ba95bb439138d99ea37464c6de032e4c0e695f628dde3929bba142
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- admin-panel (0.1.0)
4
+ admin-panel (0.1.2)
5
5
  bootstrap-sass (~> 3.1)
6
6
  devise (~> 3.2)
7
7
  railties (>= 4.0.0)
data/README.md CHANGED
@@ -9,13 +9,13 @@ Installation
9
9
  Start with adding these gems to your Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'admin-panel', '~> 0.1.0'
12
+ gem 'admin-panel', '~> 0.1.1'
13
13
  gem 'devise', '~> 3.2'
14
14
  gem 'simple_form', '3.1.0.rc1'
15
15
  gem 'bootstrap-sass', '~> 3.1'
16
16
  ```
17
17
 
18
- Then do @bundle install@ and run the installer:
18
+ Then do `bundle install` and run the installer:
19
19
 
20
20
  ```bash
21
21
  $ rails generate admin_panel:install
@@ -33,7 +33,7 @@ $ rails generate admin_panel:scaffold NAME [field:type field:type ...]
33
33
  Running tests
34
34
  -------------
35
35
 
36
- Tests can be run using @rake spec@. They are written using rspec and [ammeter](https://github.com/alexrothenberg/ammeter)
36
+ Tests can be run using `rake spec`. They are written using rspec and [ammeter](https://github.com/alexrothenberg/ammeter).
37
37
 
38
38
  Thanks
39
39
  ------
@@ -2,28 +2,28 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
  require 'admin-panel/version'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
- spec.name = 'admin-panel'
6
- spec.version = AdminPanel::VERSION
5
+ spec.name = 'admin-panel'
6
+ spec.version = AdminPanel::VERSION
7
7
 
8
- spec.authors = ['Michał Matyas']
9
- spec.email = ['michal@higher.lv']
10
- spec.summary = 'Generates Twitter Bootstrap based admin panel with scaffolder'
11
- spec.description = 'Generates Twitter Bootstrap based admin panel with scaffolder. Project is quite opinionated, requires Rails 4, SASS, SimpleForm and Devise.'
12
- spec.homepage = 'https://github.com/d4rky-pl/admin-panel'
13
- spec.license = 'MIT'
8
+ spec.authors = ['Michał Matyas']
9
+ spec.email = ['michal@higher.lv']
10
+ spec.summary = 'Generates Twitter Bootstrap based admin panel with scaffolder'
11
+ spec.description = 'Generates Twitter Bootstrap based admin panel with scaffolder. Project is quite opinionated, requires Rails 4, SASS, SimpleForm and Devise.'
12
+ spec.homepage = 'https://github.com/d4rky-pl/admin-panel'
13
+ spec.license = 'MIT'
14
14
 
15
- spec.files = `git ls-files`.split($/)
16
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
- spec.require_paths = ["lib"]
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
18
 
19
- spec.add_development_dependency 'bundler', '~> 1.5'
20
- spec.add_development_dependency 'rake', '~> 10.0'
21
- spec.add_development_dependency 'rspec', '~> 3.0'
22
- spec.add_development_dependency 'ammeter', '~> 1.0'
19
+ spec.add_development_dependency 'bundler', '~> 1.5'
20
+ spec.add_development_dependency 'rake', '~> 10.0'
21
+ spec.add_development_dependency 'rspec', '~> 3.0'
22
+ spec.add_development_dependency 'ammeter', '~> 1.0'
23
23
 
24
- spec.add_runtime_dependency 'railties', '>= 4.0.0'
25
- spec.add_runtime_dependency 'sass-rails', '>= 4.0.0'
26
- spec.add_runtime_dependency 'bootstrap-sass', '~> 3.1'
27
- spec.add_runtime_dependency 'simple_form', '>= 3.1.0.rc1'
28
- spec.add_runtime_dependency 'devise', '~> 3.2'
24
+ spec.add_runtime_dependency 'railties', '>= 4.0.0'
25
+ spec.add_runtime_dependency 'sass-rails', '>= 4.0.0'
26
+ spec.add_runtime_dependency 'bootstrap-sass', '~> 3.1'
27
+ spec.add_runtime_dependency 'simple_form', '>= 3.1.0.rc1'
28
+ spec.add_runtime_dependency 'devise', '~> 3.2'
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module AdminPanel
2
- VERSION = "0.1.1"
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,56 +1,56 @@
1
1
  require 'rails/generators'
2
2
 
3
3
  module AdminPanel
4
- module Generators
5
- class InstallGenerator < ::Rails::Generators::Base
6
- desc 'Generate basic admin panel with authentication namespaced as Admin'
7
- source_root ::File.expand_path('../templates', __FILE__)
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ desc 'Generate basic admin panel with authentication namespaced as Admin'
7
+ source_root ::File.expand_path('../templates', __FILE__)
8
8
 
9
- class_option :template_engine
9
+ class_option :template_engine
10
10
 
11
- def install_devise
12
- invoke 'devise:install'
13
- end
11
+ def install_devise
12
+ invoke 'devise:install'
13
+ end
14
14
 
15
- def install_simple_form
16
- invoke 'simple_form:install', [], ['--bootstrap']
17
- end
15
+ def install_simple_form
16
+ invoke 'simple_form:install', [], ['--bootstrap']
17
+ end
18
18
 
19
- attr_reader :app_name
19
+ attr_reader :app_name
20
20
 
21
- def copy_layout
22
- @app_name = ::Rails.application.class.to_s.split("::").first.humanize
23
- extension = "html.#{options[:template_engine]}"
21
+ def copy_layout
22
+ @app_name = ::Rails.application.class.to_s.split("::").first.humanize
23
+ extension = "html.#{options[:template_engine]}"
24
24
 
25
- template "layouts/admin/application.#{extension}", "app/views/layouts/admin/application.#{extension}"
26
- [ '_messages', '_navigation'].each do |file|
27
- filename = "#{file}.#{extension}"
28
- copy_file "layouts/admin/#{filename}", "app/views/layouts/admin/#{filename}"
29
- end
30
- end
25
+ template "layouts/admin/application.#{extension}", "app/views/layouts/admin/application.#{extension}"
26
+ ['_messages', '_navigation'].each do |file|
27
+ filename = "#{file}.#{extension}"
28
+ copy_file "layouts/admin/#{filename}", "app/views/layouts/admin/#{filename}"
29
+ end
30
+ end
31
31
 
32
- def copy_assets
33
- directory 'assets', 'app/assets'
34
- end
32
+ def copy_assets
33
+ directory 'assets', 'app/assets'
34
+ end
35
35
 
36
- def copy_helpers
37
- directory 'helpers', 'app/helpers'
38
- end
36
+ def copy_helpers
37
+ directory 'helpers', 'app/helpers'
38
+ end
39
39
 
40
- def copy_scaffold
41
- directory 'controllers', 'app/controllers'
42
- directory 'views', 'app/views'
43
- end
40
+ def copy_scaffold
41
+ directory 'controllers', 'app/controllers'
42
+ directory 'views', 'app/views'
43
+ end
44
44
 
45
- def create_admin_model
46
- invoke 'active_record:devise', ['admin'], ['--routes', false]
47
- append_to_file 'db/seeds.rb', %Q(
45
+ def create_admin_model
46
+ invoke 'active_record:devise', ['admin'], ['--routes', false]
47
+ append_to_file 'db/seeds.rb', %Q(
48
48
  Admin.create!({ email: 'admin@example.com', password: 'administrator' })
49
49
  )
50
- end
50
+ end
51
51
 
52
- def create_routes
53
- route %Q(
52
+ def create_routes
53
+ route %Q(
54
54
  devise_for :admin,
55
55
  :only => [:sessions, :passwords],
56
56
  :controllers => { :sessions => 'admin/sessions', :passwords => 'admin/passwords' }
@@ -59,11 +59,11 @@ Admin.create!({ email: 'admin@example.com', password: 'administrator' })
59
59
  get '/', to: 'dashboard#index', as: :dashboard
60
60
  end
61
61
  )
62
- end
62
+ end
63
63
 
64
- def show_install_message
65
- readme "README"
66
- end
67
- end
68
- end
64
+ def show_install_message
65
+ readme "README"
66
+ end
67
+ end
68
+ end
69
69
  end
@@ -1,3 +1,3 @@
1
1
  class Admin::DashboardController < ApplicationController
2
- include Administrable
2
+ include Administrable
3
3
  end
@@ -1,4 +1,4 @@
1
1
  class Admin::PasswordsController < Devise::PasswordsController
2
- helper AdminHelper
3
- layout 'admin/application'
2
+ helper AdminHelper
3
+ layout 'admin/application'
4
4
  end
@@ -1,4 +1,4 @@
1
1
  class Admin::SessionsController < Devise::SessionsController
2
- helper AdminHelper
3
- layout 'admin/application'
2
+ helper AdminHelper
3
+ layout 'admin/application'
4
4
  end
@@ -1,9 +1,9 @@
1
1
  module Administrable
2
- extend ActiveSupport::Concern
2
+ extend ActiveSupport::Concern
3
3
 
4
- included do
5
- before_filter :authenticate_admin!
6
- helper AdminHelper
7
- layout 'admin/application'
8
- end
4
+ included do
5
+ before_filter :authenticate_admin!
6
+ helper AdminHelper
7
+ layout 'admin/application'
8
+ end
9
9
  end
@@ -1,19 +1,19 @@
1
1
  module AdminHelper
2
- def admin_pages
3
- # TODO: something more elegant
4
- non_scaffold_pages = %w(dashboard sessions passwords)
2
+ def admin_pages
3
+ # TODO: something more elegant
4
+ non_scaffold_pages = %w(dashboard sessions passwords)
5
5
 
6
- Dir.glob(Rails.root.join('app', 'controllers', 'admin', '*.rb')).map do |path|
7
- filename = File.basename(path)
8
- resource_name = filename.sub(/_controller\.rb$/, '')
6
+ Dir.glob(Rails.root.join('app', 'controllers', 'admin', '*.rb')).map do |path|
7
+ filename = File.basename(path)
8
+ resource_name = filename.sub(/_controller\.rb$/, '')
9
9
 
10
- unless non_scaffold_pages.include? resource_name
11
- {
12
- name: resource_name.humanize,
13
- controller: "#{resource_name}",
14
- url: self.send("admin_#{resource_name}_path")
15
- }
16
- end
17
- end.compact
18
- end
10
+ unless non_scaffold_pages.include? resource_name
11
+ {
12
+ name: resource_name.humanize,
13
+ controller: "#{resource_name}",
14
+ url: self.send("admin_#{resource_name}_path")
15
+ }
16
+ end
17
+ end.compact
18
+ end
19
19
  end
@@ -1,8 +1,8 @@
1
1
  <% flash.each do |name, msg| %>
2
- <% if msg.is_a?(String) %>
3
- <div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
4
- <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
5
- <%= content_tag :div, msg, :id => "flash_#{name}" %>
6
- </div>
7
- <% end %>
2
+ <% if msg.is_a?(String) %>
3
+ <div class="alert alert-<%= name.to_s == 'notice' ? 'success' : 'danger' %>">
4
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
5
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
6
+ </div>
7
+ <% end %>
8
8
  <% end %>
@@ -1,20 +1,20 @@
1
1
  <nav class="navbar navbar-default" role="navigation">
2
- <div class="container-fluid">
3
- <div class="navbar-header">
4
- <a class="navbar-brand" href="<%= admin_dashboard_path %>">App name</a>
5
- </div>
2
+ <div class="container-fluid">
3
+ <div class="navbar-header">
4
+ <a class="navbar-brand" href="<%= admin_dashboard_path %>">App name</a>
5
+ </div>
6
6
 
7
- <% if admin_signed_in? %>
8
- <ul class="nav navbar-nav">
9
- <% admin_pages.each do |page| %>
10
- <li class="<%= controller_name == page[:controller] ? 'active' : '' %>">
11
- <a href="<%= page[:url] %>"><%= page[:name] %></a>
12
- </li>
13
- <% end %>
14
- </ul>
15
- <ul class="nav navbar-nav navbar-right">
16
- <li><%= link_to 'Sign out', destroy_admin_session_path, method: :delete %></li>
17
- </ul>
18
- <% end %>
19
- </div>
7
+ <% if admin_signed_in? %>
8
+ <ul class="nav navbar-nav">
9
+ <% admin_pages.each do |page| %>
10
+ <li class="<%= controller_name == page[:controller] ? 'active' : '' %>">
11
+ <a href="<%= page[:url] %>"><%= page[:name] %></a>
12
+ </li>
13
+ <% end %>
14
+ </ul>
15
+ <ul class="nav navbar-nav navbar-right">
16
+ <li><%= link_to 'Sign out', destroy_admin_session_path, method: :delete %></li>
17
+ </ul>
18
+ <% end %>
19
+ </div>
20
20
  </nav>
@@ -1,22 +1,22 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
- <title><%%= content_for?(:title) ? yield(:title) : "<%= app_name.underscore.titleize %>" %></title>
6
- <meta name="description" content="<%%= content_for?(:description) ? yield(:description) : "<%= app_name.underscore.titleize %>" %>">
7
- <%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
8
- <%%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
9
- <%%= csrf_meta_tags %>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
+ <title><%%= content_for?(:title) ? yield(:title) : "<%= app_name.underscore.titleize %>" %></title>
6
+ <meta name="description" content="<%%= content_for?(:description) ? yield(:description) : "<%= app_name.underscore.titleize %>" %>">
7
+ <%%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
8
+ <%%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
9
+ <%%= csrf_meta_tags %>
10
10
  </head>
11
11
  <body>
12
- <header>
13
- <%%= render partial: 'layouts/admin/navigation' %>
14
- </header>
15
- <main role="main">
16
- <div class="container">
17
- <%%= render partial: 'layouts/admin/messages' %>
18
- <%%= yield %>
19
- </div>
20
- </main>
12
+ <header>
13
+ <%%= render partial: 'layouts/admin/navigation' %>
14
+ </header>
15
+ <main role="main">
16
+ <div class="container">
17
+ <%%= render partial: 'layouts/admin/messages' %>
18
+ <%%= yield %>
19
+ </div>
20
+ </main>
21
21
  </body>
22
22
  </html>
@@ -11,5 +11,3 @@
11
11
  <%= f.button :submit, "Send me reset password instructions" %>
12
12
  </div>
13
13
  <% end %>
14
-
15
- <%= render "devise/shared/links" %>
@@ -12,6 +12,6 @@
12
12
  </div>
13
13
  <% end %>
14
14
 
15
- <%- if devise_mapping.recoverable? %>
16
- <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
15
+ <%- if devise_mapping.recoverable? %>
16
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
17
17
  <% end -%>
@@ -3,166 +3,167 @@ require 'rails/generators/named_base'
3
3
  require 'rails/generators/resource_helpers'
4
4
 
5
5
  module AdminPanel
6
- module Generators
7
- class ScaffoldGenerator < Rails::Generators::NamedBase
8
- include Rails::Generators::ResourceHelpers
6
+ module Generators
7
+ class ScaffoldGenerator < Rails::Generators::NamedBase
8
+ include Rails::Generators::ResourceHelpers
9
+
10
+ source_root File.expand_path('../templates', __FILE__)
9
11
 
10
- source_root File.expand_path('../templates', __FILE__)
12
+ class_option :template_engine, desc: 'Template engine to be invoked (erb or haml).'
13
+ class_option :test_framework, desc: 'Test framework to be used.'
11
14
 
12
- class_option :template_engine, desc: 'Template engine to be invoked (erb or haml).'
15
+ check_class_collision suffix: "Controller"
16
+ check_class_collision suffix: "ControllerTest"
17
+ check_class_collision suffix: "Helper"
13
18
 
14
- check_class_collision suffix: "Controller"
15
- check_class_collision suffix: "ControllerTest"
16
- check_class_collision suffix: "Helper"
17
-
18
- class_option :orm, banner: "NAME", type: :string, required: true,
19
- desc: "ORM to generate the controller for"
20
-
21
- class_option :parent_controller, banner: "admin", type: :string, default: "application",
22
- desc: "Define the parent controller"
23
-
24
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
25
-
26
- def initialize(args, *options) #:nodoc:
27
- super
28
- end
29
-
30
- hook_for :resource_route, in: :rails do |resource_route|
31
- invoke resource_route, [prefixed_class_name]
32
- end
33
-
34
- def create_model
35
- # There is no sane way of converting Rails::Generators::GeneratedAttribute back to string
36
- attributes_string = attributes.map do |attr|
37
- index = (attr.instance_variable_get("@has_uniq_index") && ':uniq') ||
38
- (attr.instance_variable_get("@has_index") && ':index') ||
39
- ''
40
- "#{attr.name}:#{attr.type}#{index}"
41
- end
42
- generate 'model', class_name, *attributes_string
43
- end
44
-
45
- def create_controller_files
46
- template "controllers/controller.rb.erb", File.join('app/controllers', prefix, class_path, "#{controller_file_name}_controller.rb")
47
- end
48
-
49
- def create_test_files
50
- template "tests/test_unit/functional_test.rb.erb", File.join("test/controllers", prefix, controller_class_path, "#{controller_file_name}_controller_test.rb")
51
- end
52
-
53
- hook_for :helper, in: :rails do |helper|
54
- invoke helper, [prefixed_controller_class_name]
55
- end
56
-
57
- def create_root_folder
58
- empty_directory File.join("app/views", prefix, controller_file_path)
59
- end
60
-
61
- def copy_view_files
62
- available_views.each do |view|
63
- filename = filename_with_extensions(view)
64
- template "views/#{handler}/#{filename}.erb", File.join("app/views", prefix, controller_file_path, filename)
65
- end
66
- end
67
-
68
- hook_for :assets, in: :rails do |assets|
69
- invoke assets, [prefixed_class_name]
70
- end
71
-
72
- protected
73
-
74
- def prefix
75
- 'admin'
76
- end
77
-
78
- def prefixed_class_name
79
- "#{prefix.capitalize}::#{class_name}"
80
- end
81
-
82
- def prefixed_controller_class_name
83
- "#{prefix.capitalize}::#{controller_class_name}"
84
- end
85
-
86
- def parent_controller_class_name
87
- options[:parent_controller].capitalize
88
- end
89
-
90
- def prefixed_route_url
91
- "/#{prefix}#{route_url}"
92
- end
93
-
94
- def prefixed_plain_model_url
95
- "#{prefix}_#{singular_table_name}"
96
- end
97
-
98
- def prefixed_index_helper
99
- "#{prefix}_#{index_helper}"
100
- end
101
-
102
- def available_views
103
- %w(index edit show new _form)
104
- end
105
-
106
- def format
107
- :html
108
- end
109
-
110
- def handler
111
- options[:template_engine]
112
- end
113
-
114
- def filename_with_extensions(name)
115
- [name, format, handler].compact.join(".")
116
- end
117
-
118
- # Add a class collisions name to be checked on class initialization. You
119
- # can supply a hash with a :prefix or :suffix to be tested.
120
- #
121
- # ==== Examples
122
- #
123
- # check_class_collision suffix: "Decorator"
124
- #
125
- # If the generator is invoked with class name Admin, it will check for
126
- # the presence of "AdminDecorator".
127
- #
128
- def self.check_class_collision(options={})
129
- define_method :check_class_collision do
130
- name = if self.respond_to?(:prefixed_controller_class_name) # for ScaffoldBase
131
- prefixed_controller_class_name
132
- elsif self.respond_to?(:prefixed_controller_class_name) # for ScaffoldBase
133
- controller_class_name
134
- else
135
- class_name
136
- end
137
-
138
- class_collisions "#{options[:prefix]}#{name}#{options[:suffix]}"
139
- end
140
- end
141
-
142
- def attributes_hash
143
- return if attributes_names.empty?
144
-
145
- attributes_names.map do |name|
146
- if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
147
- "#{name}: 'secret'"
148
- else
149
- "#{name}: @#{singular_table_name}.#{name}"
150
- end
151
- end.sort.join(', ')
152
- end
153
-
154
- def attributes_list_with_timestamps
155
- attributes_list(attributes_names + %w(created_at updated_at))
156
- end
157
-
158
- def attributes_list(attributes = attributes_names)
159
- if self.attributes.any? { |attr| attr.name == 'password' && attr.type == :digest }
160
- attributes = attributes.reject { |name| %w(password password_confirmation).include? name }
161
- end
162
-
163
- attributes.map { |a| ":#{a}" } * ', '
164
- end
165
-
166
- end
167
- end
19
+ class_option :orm, banner: "NAME", type: :string, required: true,
20
+ desc: "ORM to generate the controller for"
21
+
22
+ class_option :parent_controller, banner: "admin", type: :string, default: "application",
23
+ desc: "Define the parent controller"
24
+
25
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
26
+
27
+ def initialize(args, *options) #:nodoc:
28
+ super
29
+ end
30
+
31
+ hook_for :resource_route, in: :rails do |resource_route|
32
+ invoke resource_route, [prefixed_class_name]
33
+ end
34
+
35
+ def create_model
36
+ # There is no sane way of converting Rails::Generators::GeneratedAttribute back to string
37
+ attributes_string = attributes.map do |attr|
38
+ index = (attr.instance_variable_get("@has_uniq_index") && ':uniq') ||
39
+ (attr.instance_variable_get("@has_index") && ':index') ||
40
+ ''
41
+ "#{attr.name}:#{attr.type}#{index}"
42
+ end
43
+ generate 'model', class_name, *attributes_string
44
+ end
45
+
46
+ def create_controller_files
47
+ template "controllers/controller.rb.erb", File.join('app/controllers', prefix, class_path, "#{controller_file_name}_controller.rb")
48
+ end
49
+
50
+ hook_for :test_framework, in: :rails do |helper|
51
+ invoke helper, [prefixed_controller_class_name]
52
+ end
53
+
54
+ hook_for :helper, in: :rails do |helper|
55
+ invoke helper, [prefixed_controller_class_name]
56
+ end
57
+
58
+ def create_root_folder
59
+ empty_directory File.join("app/views", prefix, controller_file_path)
60
+ end
61
+
62
+ def copy_view_files
63
+ available_views.each do |view|
64
+ filename = filename_with_extensions(view)
65
+ template "views/#{handler}/#{filename}.erb", File.join("app/views", prefix, controller_file_path, filename)
66
+ end
67
+ end
68
+
69
+ hook_for :assets, in: :rails do |assets|
70
+ invoke assets, [prefixed_class_name]
71
+ end
72
+
73
+ protected
74
+
75
+ def prefix
76
+ 'admin'
77
+ end
78
+
79
+ def prefixed_class_name
80
+ "#{prefix.capitalize}::#{class_name}"
81
+ end
82
+
83
+ def prefixed_controller_class_name
84
+ "#{prefix.capitalize}::#{controller_class_name}"
85
+ end
86
+
87
+ def parent_controller_class_name
88
+ options[:parent_controller].capitalize
89
+ end
90
+
91
+ def prefixed_route_url
92
+ "/#{prefix}#{route_url}"
93
+ end
94
+
95
+ def prefixed_plain_model_url
96
+ "#{prefix}_#{singular_table_name}"
97
+ end
98
+
99
+ def prefixed_index_helper
100
+ "#{prefix}_#{index_helper}"
101
+ end
102
+
103
+ def available_views
104
+ %w(index edit show new _form)
105
+ end
106
+
107
+ def format
108
+ :html
109
+ end
110
+
111
+ def handler
112
+ options[:template_engine]
113
+ end
114
+
115
+ def filename_with_extensions(name)
116
+ [name, format, handler].compact.join(".")
117
+ end
118
+
119
+ # Add a class collisions name to be checked on class initialization. You
120
+ # can supply a hash with a :prefix or :suffix to be tested.
121
+ #
122
+ # ==== Examples
123
+ #
124
+ # check_class_collision suffix: "Decorator"
125
+ #
126
+ # If the generator is invoked with class name Admin, it will check for
127
+ # the presence of "AdminDecorator".
128
+ #
129
+ def self.check_class_collision(options={})
130
+ define_method :check_class_collision do
131
+ name = if self.respond_to?(:prefixed_controller_class_name) # for ScaffoldBase
132
+ prefixed_controller_class_name
133
+ elsif self.respond_to?(:prefixed_controller_class_name) # for ScaffoldBase
134
+ controller_class_name
135
+ else
136
+ class_name
137
+ end
138
+
139
+ class_collisions "#{options[:prefix]}#{name}#{options[:suffix]}"
140
+ end
141
+ end
142
+
143
+ def attributes_hash
144
+ return if attributes_names.empty?
145
+
146
+ attributes_names.map do |name|
147
+ if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
148
+ "#{name}: 'secret'"
149
+ else
150
+ "#{name}: @#{singular_table_name}.#{name}"
151
+ end
152
+ end.sort.join(', ')
153
+ end
154
+
155
+ def attributes_list_with_timestamps
156
+ attributes_list(attributes_names + %w(created_at updated_at))
157
+ end
158
+
159
+ def attributes_list(attributes = attributes_names)
160
+ if self.attributes.any? { |attr| attr.name == 'password' && attr.type == :digest }
161
+ attributes = attributes.reject { |name| %w(password password_confirmation).include? name }
162
+ end
163
+
164
+ attributes.map { |a| ":#{a}" } * ', '
165
+ end
166
+
167
+ end
168
+ end
168
169
  end
@@ -1,12 +1,12 @@
1
1
  <div class="page-header">
2
- <div class="row">
3
- <div class="col-md-8">
4
- <h2>Editing <%= singular_table_name %></h2>
5
- </div>
6
- <div class="col-md-4 text-right">
7
- <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
8
- </div>
9
- </div>
2
+ <div class="row">
3
+ <div class="col-md-8">
4
+ <h2>Editing <%= singular_table_name %></h2>
5
+ </div>
6
+ <div class="col-md-4 text-right">
7
+ <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
8
+ </div>
9
+ </div>
10
10
  </div>
11
11
 
12
12
  <%%= render 'form' %>
@@ -1,37 +1,37 @@
1
1
  <div class="page-header">
2
- <div class="row">
3
- <div class="col-md-8">
4
- <h2>Listing <%= plural_table_name %></h2>
5
- </div>
6
- <div class="col-md-4 text-right">
7
- <%%= link_to 'New <%= human_name %>', new_<%= prefixed_plain_model_url %>_path, class: 'btn btn-success'%>
8
- </div>
9
- </div>
2
+ <div class="row">
3
+ <div class="col-md-8">
4
+ <h2>Listing <%= plural_table_name %></h2>
5
+ </div>
6
+ <div class="col-md-4 text-right">
7
+ <%%= link_to 'New <%= human_name %>', new_<%= prefixed_plain_model_url %>_path, class: 'btn btn-success'%>
8
+ </div>
9
+ </div>
10
10
  </div>
11
11
 
12
12
  <table class="table table-striped">
13
- <thead>
14
- <tr>
13
+ <thead>
14
+ <tr>
15
15
  <% attributes.reject(&:password_digest?).each do |attribute| -%>
16
- <th><%= attribute.human_name %></th>
16
+ <th><%= attribute.human_name %></th>
17
17
  <% end -%>
18
- <th class="text-right">Actions</th>
19
- </tr>
20
- </thead>
18
+ <th class="text-right">Actions</th>
19
+ </tr>
20
+ </thead>
21
21
 
22
- <tbody>
23
- <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
24
- <tr>
25
- <% attributes.reject(&:password_digest?).each do |attribute| -%>
26
- <td><%%= link_to <%= singular_table_name %>.<%= attribute.name %>, <%= "[:#{prefix}, #{singular_table_name}]" %> %></td>
27
- <% end -%>
28
- <td class="text-right">
29
- <%%= link_to 'Show', <%= "[:#{prefix}, #{singular_table_name}]" %>, class: 'btn btn-default' %>
30
- <%%= link_to 'Edit', edit_<%= prefixed_plain_model_url %>_path(<%= singular_table_name %>), class: 'btn btn-primary' %>
31
- <%%= link_to 'Destroy', <%= "[:#{prefix}, #{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
32
- </td>
33
- </tr>
34
- <%% end %>
35
- </tbody>
22
+ <tbody>
23
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
24
+ <tr>
25
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
26
+ <td><%%= link_to <%= singular_table_name %>.<%= attribute.name %>, <%= "[:#{prefix}, #{singular_table_name}]" %> %></td>
27
+ <% end -%>
28
+ <td class="text-right">
29
+ <%%= link_to 'Show', <%= "[:#{prefix}, #{singular_table_name}]" %>, class: 'btn btn-default' %>
30
+ <%%= link_to 'Edit', edit_<%= prefixed_plain_model_url %>_path(<%= singular_table_name %>), class: 'btn btn-primary' %>
31
+ <%%= link_to 'Destroy', <%= "[:#{prefix}, #{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
32
+ </td>
33
+ </tr>
34
+ <%% end %>
35
+ </tbody>
36
36
  </table>
37
37
 
@@ -1,12 +1,12 @@
1
1
  <div class="page-header">
2
- <div class="row">
3
- <div class="col-md-8">
4
- <h2>New <%= singular_table_name %></h2>
5
- </div>
6
- <div class="col-md-4 text-right">
7
- <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
8
- </div>
9
- </div>
2
+ <div class="row">
3
+ <div class="col-md-8">
4
+ <h2>New <%= singular_table_name %></h2>
5
+ </div>
6
+ <div class="col-md-4 text-right">
7
+ <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
8
+ </div>
9
+ </div>
10
10
  </div>
11
11
 
12
12
 
@@ -2,21 +2,21 @@
2
2
 
3
3
  <table class="table table-striped">
4
4
  <tbody>
5
- <% attributes.reject(&:password_digest?).each do |attribute| -%>
6
- <tr>
7
- <td><strong><%= attribute.human_name %>:</strong></td>
8
- <td><%%= @<%= singular_table_name %>.<%= attribute.name %> %></td>
9
- </tr>
10
- <% end -%>
5
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
6
+ <tr>
7
+ <td><strong><%= attribute.human_name %>:</strong></td>
8
+ <td><%%= @<%= singular_table_name %>.<%= attribute.name %> %></td>
9
+ </tr>
10
+ <% end -%>
11
11
  </tbody>
12
12
  </table>
13
13
 
14
14
  <div class="row">
15
- <div class="col-md-6">
16
- <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
17
- </div
18
- <div class="col-md-6 text-right">
19
- <%%= link_to 'Edit', edit_<%= prefixed_plain_model_url %>_path(@<%= singular_table_name %>), class: 'btn btn-primary' %>
20
- <%%= link_to 'Destroy', <%= "[:#{prefix}, @#{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
21
- </div>
15
+ <div class="col-md-6">
16
+ <%%= link_to 'Back', <%= prefixed_index_helper %>_path, class: 'btn btn-default' %>
17
+ </div
18
+ <div class="col-md-6 text-right">
19
+ <%%= link_to 'Edit', edit_<%= prefixed_plain_model_url %>_path(@<%= singular_table_name %>), class: 'btn btn-primary' %>
20
+ <%%= link_to 'Destroy', <%= "[:#{prefix}, @#{singular_table_name}]" %>, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %>
21
+ </div>
22
22
  </div>
@@ -2,10 +2,10 @@ require 'fileutils'
2
2
 
3
3
  # This code only makes sure that invoke method in scaffold generator has been run correctly
4
4
  if ARGV[0] == "generate" && ARGV[1] == "model"
5
- root_path = File.expand_path('../../', __FILE__)
6
- models_path = File.join(root_path, 'app', 'models')
7
- filename = ARGV[2]
5
+ root_path = File.expand_path('../../', __FILE__)
6
+ models_path = File.join(root_path, 'app', 'models')
7
+ filename = ARGV[2]
8
8
 
9
- FileUtils.mkdir_p models_path
10
- FileUtils.touch File.join(models_path, "#{filename.downcase}.rb")
9
+ FileUtils.mkdir_p models_path
10
+ FileUtils.touch File.join(models_path, "#{filename.downcase}.rb")
11
11
  end
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
-
2
+
3
3
  end
@@ -2,68 +2,68 @@ require 'spec_helper'
2
2
  require 'generators/admin_panel/install/install_generator'
3
3
 
4
4
  describe AdminPanel::Generators::InstallGenerator do
5
- destination File.expand_path('../../../../../tmp', __FILE__)
5
+ destination File.expand_path('../../../../../tmp', __FILE__)
6
6
 
7
- before do
8
- prepare_destination
9
- prepare_rails_dummy
10
- end
7
+ before do
8
+ prepare_destination
9
+ prepare_rails_dummy
10
+ end
11
11
 
12
- describe 'installer' do
13
- before { run_generator }
14
- describe 'devise:install' do
15
- it_should_exist 'config/initializers/devise.rb'
16
- end
12
+ describe 'installer' do
13
+ before { run_generator }
14
+ describe 'devise:install' do
15
+ it_should_exist 'config/initializers/devise.rb'
16
+ end
17
17
 
18
- describe 'simple_form:install' do
19
- it_should_exist 'config/initializers/simple_form.rb'
20
- end
18
+ describe 'simple_form:install' do
19
+ it_should_exist 'config/initializers/simple_form.rb'
20
+ end
21
21
 
22
- describe 'copying layout' do
23
- it_should_exist 'app/views/layouts/admin/application.html.erb'
24
- it_should_exist 'app/views/layouts/admin/_messages.html.erb'
25
- it_should_exist 'app/views/layouts/admin/_navigation.html.erb'
26
- end
22
+ describe 'copying layout' do
23
+ it_should_exist 'app/views/layouts/admin/application.html.erb'
24
+ it_should_exist 'app/views/layouts/admin/_messages.html.erb'
25
+ it_should_exist 'app/views/layouts/admin/_navigation.html.erb'
26
+ end
27
27
 
28
- describe 'copying assets' do
29
- it_should_exist 'app/assets/javascripts/admin.js'
30
- it_should_exist 'app/assets/stylesheets/admin.css.scss'
31
- end
28
+ describe 'copying assets' do
29
+ it_should_exist 'app/assets/javascripts/admin.js'
30
+ it_should_exist 'app/assets/stylesheets/admin.css.scss'
31
+ end
32
32
 
33
- describe 'copying helper' do
34
- it_should_exist 'app/helpers/admin_helper.rb'
35
- end
33
+ describe 'copying helper' do
34
+ it_should_exist 'app/helpers/admin_helper.rb'
35
+ end
36
36
 
37
- describe 'copying controllers' do
38
- it_should_exist 'app/controllers/admin/dashboard_controller.rb'
39
- it_should_exist 'app/controllers/admin/passwords_controller.rb'
40
- it_should_exist 'app/controllers/admin/sessions_controller.rb'
41
- end
37
+ describe 'copying controllers' do
38
+ it_should_exist 'app/controllers/admin/dashboard_controller.rb'
39
+ it_should_exist 'app/controllers/admin/passwords_controller.rb'
40
+ it_should_exist 'app/controllers/admin/sessions_controller.rb'
41
+ end
42
42
 
43
- describe 'copying views' do
44
- it_should_exist 'app/views/admin/dashboard/index.html.erb'
45
- it_should_exist 'app/views/admin/passwords/edit.html.erb'
46
- it_should_exist 'app/views/admin/passwords/new.html.erb'
47
- it_should_exist 'app/views/admin/sessions/new.html.erb'
48
- end
43
+ describe 'copying views' do
44
+ it_should_exist 'app/views/admin/dashboard/index.html.erb'
45
+ it_should_exist 'app/views/admin/passwords/edit.html.erb'
46
+ it_should_exist 'app/views/admin/passwords/new.html.erb'
47
+ it_should_exist 'app/views/admin/sessions/new.html.erb'
48
+ end
49
49
 
50
- describe 'active_record:devise' do
51
- it_should_exist 'app/models/admin.rb'
52
- end
50
+ describe 'active_record:devise' do
51
+ it_should_exist 'app/models/admin.rb'
52
+ end
53
53
 
54
- describe 'seeding default admin user' do
55
- describe 'seeds.rb' do
56
- subject { file('db/seeds.rb')}
57
- it { should exist }
58
- it { should contain %Q(Admin.create!({ email: 'admin@example.com', password: 'administrator' })) }
59
- end
60
- end
54
+ describe 'seeding default admin user' do
55
+ describe 'seeds.rb' do
56
+ subject { file('db/seeds.rb') }
57
+ it { should exist }
58
+ it { should contain %Q(Admin.create!({ email: 'admin@example.com', password: 'administrator' })) }
59
+ end
60
+ end
61
61
 
62
- describe 'routing generation' do
63
- describe 'routes.rb' do
64
- subject { file('config/routes.rb') }
65
- it { should exist }
66
- it { should contain %Q(
62
+ describe 'routing generation' do
63
+ describe 'routes.rb' do
64
+ subject { file('config/routes.rb') }
65
+ it { should exist }
66
+ it { should contain %Q(
67
67
  devise_for :admin,
68
68
  :only => [:sessions, :passwords],
69
69
  :controllers => { :sessions => 'admin/sessions', :passwords => 'admin/passwords' }
@@ -73,7 +73,7 @@ describe AdminPanel::Generators::InstallGenerator do
73
73
  end
74
74
  ) }
75
75
 
76
- end
77
- end
78
- end
76
+ end
77
+ end
78
+ end
79
79
  end
@@ -2,30 +2,30 @@ require 'spec_helper'
2
2
  require 'generators/admin_panel/scaffold/scaffold_generator'
3
3
 
4
4
  describe AdminPanel::Generators::ScaffoldGenerator do
5
- destination File.expand_path('../../../../../tmp', __FILE__)
5
+ destination File.expand_path('../../../../../tmp', __FILE__)
6
6
 
7
- before do
8
- prepare_destination
9
- prepare_rails_dummy
10
- end
7
+ before do
8
+ prepare_destination
9
+ prepare_rails_dummy
10
+ end
11
11
 
12
- describe 'scaffolder' do
13
- before { run_generator(%w(post title:string description:text public:boolean)) }
14
- # @see spec/dummy/bin/rails
15
- it_should_exist 'app/models/post.rb'
12
+ describe 'scaffolder' do
13
+ before { run_generator(%w(post title:string description:text public:boolean)) }
14
+ # @see spec/dummy/bin/rails
15
+ it_should_exist 'app/models/post.rb'
16
16
 
17
- describe 'posts controller' do
18
- subject { file('app/controllers/admin/posts_controller.rb')}
19
- it { should exist }
20
- it { should contain 'include Administrable' }
21
- it { should contain '@posts = Post.all' }
22
- end
17
+ describe 'posts controller' do
18
+ subject { file('app/controllers/admin/posts_controller.rb') }
19
+ it { should exist }
20
+ it { should contain 'include Administrable' }
21
+ it { should contain '@posts = Post.all' }
22
+ end
23
23
 
24
- it_should_exist 'app/views/admin/posts/index.html.erb'
25
- it_should_exist 'app/views/admin/posts/edit.html.erb'
26
- it_should_exist 'app/views/admin/posts/show.html.erb'
27
- it_should_exist 'app/views/admin/posts/new.html.erb'
28
- it_should_exist 'app/views/admin/posts/_form.html.erb'
24
+ it_should_exist 'app/views/admin/posts/index.html.erb'
25
+ it_should_exist 'app/views/admin/posts/edit.html.erb'
26
+ it_should_exist 'app/views/admin/posts/show.html.erb'
27
+ it_should_exist 'app/views/admin/posts/new.html.erb'
28
+ it_should_exist 'app/views/admin/posts/_form.html.erb'
29
29
 
30
- end
30
+ end
31
31
  end
@@ -6,12 +6,12 @@ require 'fileutils'
6
6
  require 'ammeter/init'
7
7
 
8
8
  def prepare_rails_dummy
9
- FileUtils.cp_r('spec/dummy/.', destination_root)
9
+ FileUtils.cp_r('spec/dummy/.', destination_root)
10
10
  end
11
11
 
12
12
  def it_should_exist(path)
13
- describe "file #{File.basename(path)}" do
14
- subject { file(path)}
15
- it { should exist }
16
- end
13
+ describe "file #{File.basename(path)}" do
14
+ subject { file(path) }
15
+ it { should exist }
16
+ end
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin-panel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Matyas
@@ -170,7 +170,6 @@ files:
170
170
  - lib/generators/admin_panel/install/templates/views/admin/sessions/new.html.erb
171
171
  - lib/generators/admin_panel/scaffold/scaffold_generator.rb
172
172
  - lib/generators/admin_panel/scaffold/templates/controllers/controller.rb.erb
173
- - lib/generators/admin_panel/scaffold/templates/tests/test_unit/functional_test.rb.erb
174
173
  - lib/generators/admin_panel/scaffold/templates/views/erb/_form.html.erb.erb
175
174
  - lib/generators/admin_panel/scaffold/templates/views/erb/edit.html.erb.erb
176
175
  - lib/generators/admin_panel/scaffold/templates/views/erb/index.html.erb.erb
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
-
3
- <% module_namespacing do -%>
4
- class <%= prefixed_controller_class_name %>ControllerTest < ActionController::TestCase
5
- setup do
6
- @<%= singular_table_name %> = <%= table_name %>(:one)
7
- end
8
-
9
- test "should get index" do
10
- get :index
11
- assert_response :success
12
- assert_not_nil assigns(:<%= table_name %>)
13
- end
14
-
15
- test "should get new" do
16
- get :new
17
- assert_response :success
18
- end
19
-
20
- test "should create <%= singular_table_name %>" do
21
- assert_difference('<%= class_name %>.count') do
22
- post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
23
- end
24
-
25
- assert_redirected_to <%= prefixed_plain_model_url %>_path(assigns(:<%= singular_table_name %>))
26
- end
27
-
28
- test "should show <%= singular_table_name %>" do
29
- get :show, id: <%= "@#{singular_table_name}" %>
30
- assert_response :success
31
- end
32
-
33
- test "should get edit" do
34
- get :edit, id: <%= "@#{singular_table_name}" %>
35
- assert_response :success
36
- end
37
-
38
- test "should update <%= singular_table_name %>" do
39
- patch :update, id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
40
- assert_redirected_to <%= prefixed_plain_model_url %>_path(assigns(:<%= singular_table_name %>))
41
- end
42
-
43
- test "should destroy <%= singular_table_name %>" do
44
- assert_difference('<%= class_name %>.count', -1) do
45
- delete :destroy, id: <%= "@#{singular_table_name}" %>
46
- end
47
-
48
- assert_redirected_to <%= prefixed_index_helper %>_path
49
- end
50
- end
51
- <% end -%>