padrino-admin 0.9.7 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. data/Rakefile +0 -1
  2. data/VERSION +1 -1
  3. data/lib/padrino-admin/generators/actions.rb +1 -1
  4. data/lib/padrino-admin/generators/admin_app.rb +14 -13
  5. data/lib/padrino-admin/generators/admin_page.rb +16 -14
  6. data/lib/padrino-admin/generators/orm.rb +4 -4
  7. data/lib/padrino-admin/generators/templates/app/app.rb +1 -1
  8. data/lib/padrino-admin/generators/templates/assets/stylesheets/base.css +5 -5
  9. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css +1 -1
  10. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec-green/style.css +1 -1
  11. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css +1 -1
  12. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/blue/style.css +1 -1
  13. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/default/style.css +2 -2
  14. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/djime-cerulean/style.css +1 -1
  15. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/kathleene/style.css +1 -1
  16. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/olive/style.css +1 -1
  17. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/reidb-greenish/style.css +1 -1
  18. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/ruby/style.css +1 -1
  19. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/warehouse/style.css +2 -2
  20. data/lib/padrino-admin/helpers/authentication_helpers.rb +3 -3
  21. data/padrino-admin.gemspec +11 -11
  22. data/test/generators/test_admin_app_generator.rb +1 -1
  23. data/test/generators/test_admin_page_generator.rb +39 -5
  24. data/test/test_admin_application.rb +1 -1
  25. metadata +9 -9
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require 'sdoc'
4
3
 
5
4
  GEM_VERSION = File.read(File.dirname(__FILE__) + '/VERSION')
6
5
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.7
1
+ 0.9.9
@@ -22,7 +22,7 @@ module Padrino
22
22
  #
23
23
  def add_project_module(controller)
24
24
  permission = " role.project_module :#{controller}, \"/#{controller}\"\n"
25
- inject_into_file destination_root("/admin/app.rb"), permission, :after => "access_control.roles_for :admin do |role, account|\n"
25
+ inject_into_file destination_root("/admin/app.rb"), permission, :after => "access_control.roles_for :admin do |role|\n"
26
26
  end
27
27
  end # Actions
28
28
  end # Admin
@@ -16,7 +16,7 @@ module Padrino
16
16
  include Padrino::Generators::Actions
17
17
  include Padrino::Generators::Admin::Actions
18
18
 
19
- desc "Description:\n\n\tpadrino-gen admin generates a new Padrino Admin"
19
+ desc "Description:\n\n\tpadrino-gen admin generates a new Padrino Admin application"
20
20
 
21
21
  class_option :skip_migration, :aliases => "-s", :default => false, :type => :boolean
22
22
  class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
@@ -30,7 +30,7 @@ module Padrino
30
30
  if in_app_root?
31
31
 
32
32
  unless supported_orm.include?(orm)
33
- say "<= A the moment we only support #{supported_orm.join(" or ")}. Sorry!"
33
+ say "<= At the moment, Padrino only supports #{supported_orm.join(" or ")}. Sorry!"
34
34
  raise SystemExit
35
35
  end
36
36
 
@@ -54,16 +54,16 @@ module Padrino
54
54
  column = Struct.new(:name, :type)
55
55
  columns = [:id, :name, :surname, :email].map { |col| column.new(col) }
56
56
  column_fields = [
57
- { :name => :name, :field_type => :text_field },
58
- { :name => :surname, :field_type => :text_field },
59
- { :name => :email, :field_type => :text_field },
60
- { :name => :password, :field_type => :text_field },
61
- { :name => :password_confirmation, :field_type => :text_field },
62
- { :name => :role, :field_type => :text_field }
57
+ { :name => :name, :field_type => :text_field },
58
+ { :name => :surname, :field_type => :text_field },
59
+ { :name => :email, :field_type => :text_field },
60
+ { :name => :password, :field_type => :password_field },
61
+ { :name => :password_confirmation, :field_type => :password_field },
62
+ { :name => :role, :field_type => :text_field }
63
63
  ]
64
64
 
65
65
  admin_app = Padrino::Generators::AdminPage.new(["account"], :root => options[:root])
66
- admin_app.orm = Padrino::Admin::Generators::Orm.new(:account, orm, columns, column_fields)
66
+ admin_app.default_orm = Padrino::Admin::Generators::Orm.new(:account, orm, columns, column_fields)
67
67
  admin_app.invoke
68
68
 
69
69
  template "templates/account/#{orm}.rb.tt", destination_root("app", "models", "account.rb"), :force => true
@@ -76,15 +76,16 @@ module Padrino
76
76
  add_project_module :accounts
77
77
  append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"Admin\").to(\"/admin\")"
78
78
  gsub_file destination_root("admin/views/accounts/_form.#{ext}"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles"
79
-
79
+ gsub_file destination_root("admin/controllers/accounts.rb"), "if account.destroy", "if account != current_account && account.destroy"
80
80
  return if self.behavior == :revoke
81
81
  say (<<-TEXT).gsub(/ {10}/,'')
82
82
 
83
83
  =================================================================
84
- Admin has been successfully installed, now follow this steps:
84
+ The admin panel has been mounted! Next, follow these steps:
85
85
  =================================================================
86
- 1) Run migrations
87
- 2) Run padrino rake seed
86
+ 1) Run migrations (if necessary)
87
+ 2) Run 'padrino rake seed'
88
+ 3) Visit the admin panel in the browser at '/admin'
88
89
  =================================================================
89
90
 
90
91
  TEXT
@@ -2,7 +2,7 @@ module Padrino
2
2
  module Generators
3
3
 
4
4
  class AdminPage < Thor::Group
5
- attr_accessor :orm
5
+ attr_accessor :default_orm
6
6
 
7
7
  # Add this generator to our padrino-gen
8
8
  Padrino::Generators.add_generator(:admin_page, self)
@@ -16,8 +16,8 @@ module Padrino
16
16
  include Padrino::Generators::Actions
17
17
  include Padrino::Generators::Admin::Actions
18
18
 
19
- desc "Description:\n\n\tpadrino-gen admin_page YourModel"
20
- argument :model, :desc => "The name of your model"
19
+ desc "Description:\n\n\tpadrino-gen admin_page model(s)"
20
+ argument :models, :desc => "The name(s) of your model(s)", :type => :array
21
21
  class_option :skip_migration, :aliases => "-s", :default => false, :type => :boolean
22
22
  class_option :root, :desc => "The root destination", :aliases => '-r', :type => :string
23
23
  class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
@@ -29,17 +29,19 @@ module Padrino
29
29
  def create_controller
30
30
  self.destination_root = options[:root]
31
31
  if in_app_root?
32
- @orm ||= Padrino::Admin::Generators::Orm.new(model, adapter)
33
- self.behavior = :revoke if options[:destroy]
34
- ext = fetch_component_choice(:renderer)
35
-
36
- template "templates/page/controller.rb.tt", destination_root("/admin/controllers/#{@orm.name_plural}.rb")
37
- template "templates/#{ext}/page/_form.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/_form.#{ext}")
38
- template "templates/#{ext}/page/edit.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/edit.#{ext}")
39
- template "templates/#{ext}/page/index.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/index.#{ext}")
40
- template "templates/#{ext}/page/new.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/new.#{ext}")
41
-
42
- add_project_module(@orm.name_plural)
32
+ models.each do |model|
33
+ @orm = default_orm || Padrino::Admin::Generators::Orm.new(model, adapter)
34
+ self.behavior = :revoke if options[:destroy]
35
+ ext = fetch_component_choice(:renderer)
36
+
37
+ template "templates/page/controller.rb.tt", destination_root("/admin/controllers/#{@orm.name_plural}.rb")
38
+ template "templates/#{ext}/page/_form.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/_form.#{ext}")
39
+ template "templates/#{ext}/page/edit.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/edit.#{ext}")
40
+ template "templates/#{ext}/page/index.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/index.#{ext}")
41
+ template "templates/#{ext}/page/new.#{ext}.tt", destination_root("/admin/views/#{@orm.name_plural}/new.#{ext}")
42
+
43
+ add_project_module(@orm.name_plural)
44
+ end
43
45
  else
44
46
  say "You are not at the root of a Padrino application! (config/boot.rb not found)" and return unless in_app_root?
45
47
  end
@@ -14,7 +14,7 @@ module Padrino
14
14
  @orm = orm.to_sym
15
15
  @columns = columns
16
16
  @column_fields = column_fields
17
- raise OrmError, "Model #{name} not found!" if @columns.nil? && @klass.nil?
17
+ raise OrmError, "Model #{name} was not found!" if @columns.nil? && @klass.nil?
18
18
  end
19
19
 
20
20
  def field_type(type)
@@ -33,7 +33,7 @@ module Padrino
33
33
  when :datamapper then @klass.properties
34
34
  when :mongoid then @klass.fields.values
35
35
  when :mongomapper then @klass.keys.values.reject { |key| key.name == "_id" } # On MongoMapper keys are an hash
36
- else raise OrmError, "Adapter #{orm} not yet supported!"
36
+ else raise OrmError, "Adapter #{orm} is not yet supported!"
37
37
  end
38
38
  end
39
39
 
@@ -54,7 +54,7 @@ module Padrino
54
54
  case orm
55
55
  when :activerecord, :mongomapper, :mongoid then "#{klass_name}.find(#{params})"
56
56
  when :datamapper then "#{klass_name}.get(#{params})"
57
- else raise OrmError, "Adapter #{orm} not yet supported!"
57
+ else raise OrmError, "Adapter #{orm} is not yet supported!"
58
58
  end
59
59
  end
60
60
 
@@ -74,7 +74,7 @@ module Padrino
74
74
  case orm
75
75
  when :activerecord, :mongomapper, :mongoid then "#{name_singular}.update_attributes(#{params})"
76
76
  when :datamapper then "#{name_singular}.update(#{params})"
77
- else raise OrmError, "Adapter #{orm} not yet supported!"
77
+ else raise OrmError, "Adapter #{orm} is not yet supported!"
78
78
  end
79
79
  end
80
80
 
@@ -24,7 +24,7 @@ class Admin < Padrino::Application
24
24
  role.allow "/sessions"
25
25
  end
26
26
 
27
- access_control.roles_for :admin do |role, account|
27
+ access_control.roles_for :admin do |role|
28
28
  end
29
29
 
30
30
  end
@@ -61,21 +61,21 @@ body{font-size:12px;font-family:sans-serif;}
61
61
  .table td{padding:10px;}
62
62
  .table td.last{text-align:right;}
63
63
  /* forms */
64
- input.checkbox{margin:0;padding:0;}
64
+ input.check_box{margin:0;padding:0;}
65
65
  .form .group{margin-bottom:15px;}
66
66
  .form div.left{width:20%;float:left;}
67
67
  .form div.right{width:75%;float:right;}
68
68
  .form .columns .column{width:48%;}
69
69
  .form .columns .left{float:left;}
70
70
  .form .columns .right{float:right;}
71
- .form label,.form input.text_field,.form textarea.text_area{font-size:1.0em;padding:2px 0;margin:0;color:#36393D;}
71
+ .form label,.form input.text_field,.form input.password_field,.form textarea.text_area{font-size:1.0em;padding:2px 0;margin:0;color:#36393D;}
72
72
  .form label.right{text-align:right;}
73
- .form input.checkbox,.form input.radio{margin-right:5px;}
74
- .form label.checkbox,.form label.radio{line-height:1.5em;}
73
+ .form input.check_box,.form input.radio{margin-right:5px;}
74
+ .form label.check_box,.form label.radio{line-height:1.5em;}
75
75
  .form label{padding-bottom:2px;font-weight:bold;}
76
76
  .form .error{color:red;}
77
77
  .form a{color:red;font-size:14px;}
78
- .form input.text_field,.form textarea.text_area{width:100%;border-width:1px;border-style:solid;}
78
+ .form input.text_field,.form input.password_field,.form textarea.text_area{width:100%;border-width:1px;border-style:solid;}
79
79
  .button_to{display:inline;}
80
80
  .button_to input{background:none;border:none;display:inline;font-size:12px;color:#A72D2E;cursor:pointer;}
81
81
  /* lists */
@@ -253,7 +253,7 @@ p {
253
253
  }
254
254
  /* forms */
255
255
 
256
- .form input.text_field, .form textarea.text_area {
256
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
257
257
  width: 100%;
258
258
  border:1px solid #CFCFCF;
259
259
  }
@@ -16,7 +16,7 @@ p {
16
16
  line-height: 20px;
17
17
  }
18
18
 
19
- input.checkbox {
19
+ input.check_box {
20
20
  vertical-align:middle;
21
21
  }
22
22
 
@@ -16,7 +16,7 @@ p {
16
16
  line-height: 20px;
17
17
  }
18
18
 
19
- input.checkbox {
19
+ input.check_box {
20
20
  vertical-align:middle;
21
21
  }
22
22
 
@@ -176,7 +176,7 @@ hr {
176
176
 
177
177
  /* forms */
178
178
 
179
- .form input.text_field, .form textarea.text_area {
179
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
180
180
  width: 100%;
181
181
  border: 1px solid #262626;
182
182
  }
@@ -239,7 +239,7 @@ hr {
239
239
  /* tables */
240
240
 
241
241
  .table th {
242
- background: #36393d;
242
+ background: #36393d;
243
243
  color: #FFF;
244
244
  }
245
245
 
@@ -257,7 +257,7 @@ hr {
257
257
  color: #666666;
258
258
  }
259
259
 
260
- .form input.text_field, .form textarea.text_area {
260
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
261
261
  width: 100%;
262
262
  border: 1px solid #cfcfcf;
263
263
  }
@@ -193,7 +193,7 @@ hr {
193
193
 
194
194
  /* forms */
195
195
 
196
- .form input.text_field, .form textarea.text_area {
196
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
197
197
  width: 100%;
198
198
  border: 1px solid #001C26;
199
199
  }
@@ -164,7 +164,7 @@ hr {
164
164
 
165
165
  /* forms */
166
166
 
167
- .form input.text_field, .form textarea.text_area {
167
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
168
168
  width: 100%;
169
169
  border: 1px solid #2a0000;
170
170
  }
@@ -234,7 +234,7 @@ p {
234
234
  }
235
235
  /* forms */
236
236
 
237
- .form input.text_field, .form textarea.text_area {
237
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
238
238
  width: 100%;
239
239
  border:1px solid #CFCFCF;
240
240
  }
@@ -184,7 +184,7 @@ padding: 8px 12px;
184
184
 
185
185
  /* forms */
186
186
 
187
- .form input.text_field, .form textarea.text_area {
187
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
188
188
  width: 100%;
189
189
  border: 1px solid #262626;
190
190
  }
@@ -170,7 +170,7 @@ hr {
170
170
 
171
171
  /* forms */
172
172
 
173
- .form input.text_field, .form textarea.text_area {
173
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
174
174
  width: 100%;
175
175
  border: 1px solid #262626;
176
176
  }
@@ -17,7 +17,7 @@ p {
17
17
  line-height: 20px;
18
18
  }
19
19
 
20
- input.checkbox {
20
+ input.check_box {
21
21
  vertical-align:middle;
22
22
  }
23
23
 
@@ -309,7 +309,7 @@ input.checkbox {
309
309
  width:99%;
310
310
  }
311
311
 
312
- .form input.text_field, .form textarea.text_area {
312
+ .form input.text_field, .form input.password_field, .form textarea.text_area {
313
313
  border-right: 1px solid #ddd;
314
314
  border-bottom: 1px solid #ddd;
315
315
  border-top: 2px solid #ccc;
@@ -24,7 +24,7 @@ module Padrino
24
24
  # set_current_account(Account.authenticate(params[:email], params[:password])
25
25
  #
26
26
  def set_current_account(account=nil)
27
- session[options.session_id] = account ? account.id : nil
27
+ session[settings.session_id] = account ? account.id : nil
28
28
  @current_account = account
29
29
  end
30
30
 
@@ -86,11 +86,11 @@ module Padrino
86
86
  end
87
87
 
88
88
  def login_page
89
- options.login_page rescue nil # on sinatra 9.4.x respond_to?(:login_page) didn't work
89
+ settings.login_page rescue nil
90
90
  end
91
91
 
92
92
  def store_location
93
- options.store_location rescue false
93
+ settings.store_location rescue nil
94
94
  end
95
95
 
96
96
  def login_from_session
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{padrino-admin}
8
- s.version = "0.9.7"
8
+ s.version = "0.9.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
- s.date = %q{2010-03-22}
12
+ s.date = %q{2010-03-29}
13
13
  s.description = %q{Admin View for Padrino applications}
14
14
  s.email = %q{padrinorb@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -94,18 +94,18 @@ Gem::Specification.new do |s|
94
94
  s.specification_version = 3
95
95
 
96
96
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
97
- s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.7"])
98
- s.add_runtime_dependency(%q<padrino-gen>, ["= 0.9.7"])
99
- s.add_runtime_dependency(%q<padrino-helpers>, ["= 0.9.7"])
97
+ s.add_runtime_dependency(%q<padrino-core>, ["= 0.9.9"])
98
+ s.add_runtime_dependency(%q<padrino-gen>, ["= 0.9.9"])
99
+ s.add_runtime_dependency(%q<padrino-helpers>, ["= 0.9.9"])
100
100
  s.add_development_dependency(%q<haml>, [">= 2.2.1"])
101
101
  s.add_development_dependency(%q<shoulda>, [">= 0"])
102
102
  s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
103
103
  s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
104
104
  s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
105
105
  else
106
- s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
107
- s.add_dependency(%q<padrino-gen>, ["= 0.9.7"])
108
- s.add_dependency(%q<padrino-helpers>, ["= 0.9.7"])
106
+ s.add_dependency(%q<padrino-core>, ["= 0.9.9"])
107
+ s.add_dependency(%q<padrino-gen>, ["= 0.9.9"])
108
+ s.add_dependency(%q<padrino-helpers>, ["= 0.9.9"])
109
109
  s.add_dependency(%q<haml>, [">= 2.2.1"])
110
110
  s.add_dependency(%q<shoulda>, [">= 0"])
111
111
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -113,9 +113,9 @@ Gem::Specification.new do |s|
113
113
  s.add_dependency(%q<webrat>, [">= 0.5.1"])
114
114
  end
115
115
  else
116
- s.add_dependency(%q<padrino-core>, ["= 0.9.7"])
117
- s.add_dependency(%q<padrino-gen>, ["= 0.9.7"])
118
- s.add_dependency(%q<padrino-helpers>, ["= 0.9.7"])
116
+ s.add_dependency(%q<padrino-core>, ["= 0.9.9"])
117
+ s.add_dependency(%q<padrino-gen>, ["= 0.9.9"])
118
+ s.add_dependency(%q<padrino-helpers>, ["= 0.9.9"])
119
119
  s.add_dependency(%q<haml>, [">= 2.2.1"])
120
120
  s.add_dependency(%q<shoulda>, [">= 0"])
121
121
  s.add_dependency(%q<mocha>, [">= 0.9.7"])
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../helper')
2
2
  require 'thor/group'
3
3
  require 'fakeweb'
4
4
  require 'padrino-gen/generators/actions'
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/../helper')
2
2
  require 'thor/group'
3
3
  require 'fakeweb'
4
4
  require 'padrino-gen/generators/actions'
@@ -10,6 +10,12 @@ class Person
10
10
  end
11
11
  end
12
12
 
13
+ class Page
14
+ def self.properties
15
+ [:id, :name, :body].map { |c| OpenStruct.new(:name => c) }
16
+ end
17
+ end
18
+
13
19
  class TestAdminPageGenerator < Test::Unit::TestCase
14
20
 
15
21
  def setup
@@ -34,8 +40,7 @@ class TestAdminPageGenerator < Test::Unit::TestCase
34
40
  assert_raise(Padrino::Admin::Generators::OrmError) { @page.start(['foo', '-r=/tmp/sample_project']) }
35
41
  end
36
42
 
37
- should 'correctyl generate a new padrino admin application default renderer' do
38
- 'Person'.classify.constantize
43
+ should 'correctly generate a new padrino admin application default renderer' do
39
44
  silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=datamapper']) }
40
45
  silence_logger { @admin.start(['--root=/tmp/sample_project']) }
41
46
  silence_logger { @model.start(['person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project']) }
@@ -52,8 +57,7 @@ class TestAdminPageGenerator < Test::Unit::TestCase
52
57
  assert_match_in_file 'role.project_module :people, "/people"', '/tmp/sample_project/admin/app.rb'
53
58
  end
54
59
 
55
- should 'correctyl generate a new padrino admin application with erb renderer' do
56
- 'Person'.classify.constantize
60
+ should 'correctly generate a new padrino admin application with erb renderer' do
57
61
  silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=datamapper', '-e=erb']) }
58
62
  silence_logger { @admin.start(['--root=/tmp/sample_project']) }
59
63
  silence_logger { @model.start(['person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project']) }
@@ -69,5 +73,35 @@ class TestAdminPageGenerator < Test::Unit::TestCase
69
73
  end
70
74
  assert_match_in_file 'role.project_module :people, "/people"', '/tmp/sample_project/admin/app.rb'
71
75
  end
76
+
77
+ should 'correctly generate a new padrino admin application with multiple models' do
78
+ silence_logger { @project.start(['sample_project', '--root=/tmp', '-d=datamapper']) }
79
+ silence_logger { @admin.start(['--root=/tmp/sample_project']) }
80
+ silence_logger { @model.start(['person', "name:string", "age:integer", "email:string", '-root=/tmp/sample_project']) }
81
+ silence_logger { @model.start(['page', "name:string", "body:string", '-root=/tmp/sample_project']) }
82
+ silence_logger { @page.start(['person', 'page', '--root=/tmp/sample_project']) }
83
+ # For Person
84
+ assert_file_exists '/tmp/sample_project/admin/controllers/people.rb'
85
+ assert_file_exists '/tmp/sample_project/admin/views/people/_form.haml'
86
+ assert_file_exists '/tmp/sample_project/admin/views/people/edit.haml'
87
+ assert_file_exists '/tmp/sample_project/admin/views/people/index.haml'
88
+ assert_file_exists '/tmp/sample_project/admin/views/people/new.haml'
89
+ %w(name age email).each do |field|
90
+ assert_match_in_file "label :#{field}", '/tmp/sample_project/admin/views/people/_form.haml'
91
+ assert_match_in_file "text_field :#{field}", '/tmp/sample_project/admin/views/people/_form.haml'
92
+ end
93
+ assert_match_in_file 'role.project_module :people, "/people"', '/tmp/sample_project/admin/app.rb'
94
+ # For Page
95
+ assert_file_exists '/tmp/sample_project/admin/controllers/pages.rb'
96
+ assert_file_exists '/tmp/sample_project/admin/views/pages/_form.haml'
97
+ assert_file_exists '/tmp/sample_project/admin/views/pages/edit.haml'
98
+ assert_file_exists '/tmp/sample_project/admin/views/pages/index.haml'
99
+ assert_file_exists '/tmp/sample_project/admin/views/pages/new.haml'
100
+ %w(name body).each do |field|
101
+ assert_match_in_file "label :#{field}", '/tmp/sample_project/admin/views/pages/_form.haml'
102
+ assert_match_in_file "text_field :#{field}", '/tmp/sample_project/admin/views/pages/_form.haml'
103
+ end
104
+ assert_match_in_file 'role.project_module :pages, "/pages"', '/tmp/sample_project/admin/app.rb'
105
+ end
72
106
  end
73
107
  end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/helper')
2
2
 
3
3
  class TestAdminApplication < Test::Unit::TestCase
4
4
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 7
9
- version: 0.9.7
8
+ - 9
9
+ version: 0.9.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Padrino Team
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-03-22 00:00:00 -07:00
20
+ date: 2010-03-29 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -30,8 +30,8 @@ dependencies:
30
30
  segments:
31
31
  - 0
32
32
  - 9
33
- - 7
34
- version: 0.9.7
33
+ - 9
34
+ version: 0.9.9
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -44,8 +44,8 @@ dependencies:
44
44
  segments:
45
45
  - 0
46
46
  - 9
47
- - 7
48
- version: 0.9.7
47
+ - 9
48
+ version: 0.9.9
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
51
  - !ruby/object:Gem::Dependency
@@ -58,8 +58,8 @@ dependencies:
58
58
  segments:
59
59
  - 0
60
60
  - 9
61
- - 7
62
- version: 0.9.7
61
+ - 9
62
+ version: 0.9.9
63
63
  type: :runtime
64
64
  version_requirements: *id003
65
65
  - !ruby/object:Gem::Dependency