padrino-admin 0.9.15 → 0.9.16
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/padrino-admin.rb +6 -2
- data/lib/padrino-admin/generators/admin_app.rb +9 -4
- data/lib/padrino-admin/generators/orm.rb +3 -3
- data/padrino-admin.gemspec +1 -2
- data/test/generators/test_admin_app_generator.rb +72 -65
- data/test/generators/test_admin_page_generator.rb +55 -50
- data/test/helper.rb +3 -8
- metadata +11 -27
data/lib/padrino-admin.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'padrino-core'
|
2
|
-
require 'padrino-gen'
|
3
2
|
require 'padrino-helpers'
|
4
3
|
|
5
4
|
FileSet.glob_require('padrino-admin/*.rb', __FILE__)
|
@@ -30,4 +29,9 @@ I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-admin/locale/**/*.yml"]
|
|
30
29
|
##
|
31
30
|
# Now we need to add admin generators to padrino-gen
|
32
31
|
#
|
33
|
-
|
32
|
+
begin
|
33
|
+
require 'padrino-gen'
|
34
|
+
Padrino::Generators.load_paths << Dir[File.dirname(__FILE__) + '/padrino-admin/generators/{actions,orm,admin_app,admin_page}.rb']
|
35
|
+
rescue LoadError
|
36
|
+
|
37
|
+
end
|
@@ -46,10 +46,15 @@ module Padrino
|
|
46
46
|
directory "templates/app", destination_root("admin")
|
47
47
|
directory "templates/assets", destination_root("public", "admin")
|
48
48
|
|
49
|
-
|
49
|
+
account_params = [
|
50
50
|
"account", "name:string", "surname:string", "email:string", "crypted_password:string", "salt:string", "role:string",
|
51
|
-
"-r=#{options[:root]}"
|
52
|
-
]
|
51
|
+
"-r=#{options[:root]}"
|
52
|
+
]
|
53
|
+
|
54
|
+
account_params << "-s" if options[:skip_migration]
|
55
|
+
account_params << "-d" if options[:destroy]
|
56
|
+
|
57
|
+
Padrino::Generators::Model.start(account_params)
|
53
58
|
|
54
59
|
column = Struct.new(:name, :type)
|
55
60
|
columns = [:id, :name, :surname, :email].map { |col| column.new(col) }
|
@@ -95,4 +100,4 @@ module Padrino
|
|
95
100
|
end
|
96
101
|
end # AdminApp
|
97
102
|
end # Generators
|
98
|
-
end # Padrino
|
103
|
+
end # Padrino
|
@@ -7,14 +7,14 @@ module Padrino
|
|
7
7
|
|
8
8
|
def initialize(name, orm, columns=nil, column_fields=nil)
|
9
9
|
name = name.to_s
|
10
|
-
@klass_name = name.
|
11
|
-
@klass =
|
10
|
+
@klass_name = name.camelize
|
11
|
+
@klass = @klass_name.constantize rescue nil
|
12
12
|
@name_plural = name.underscore.pluralize
|
13
13
|
@name_singular = name.underscore
|
14
14
|
@orm = orm.to_sym
|
15
15
|
@columns = columns
|
16
16
|
@column_fields = column_fields
|
17
|
-
raise OrmError, "Model '#{
|
17
|
+
raise OrmError, "Model '#{klass_name}' could not be found!" if @columns.nil? && @klass.nil?
|
18
18
|
end
|
19
19
|
|
20
20
|
def field_type(type)
|
data/padrino-admin.gemspec
CHANGED
@@ -16,6 +16,5 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.rdoc_options = ["--charset=UTF-8"]
|
17
17
|
s.require_path = "lib"
|
18
18
|
s.add_dependency("padrino-core", Padrino.version)
|
19
|
-
s.add_dependency("padrino-gen", Padrino.version)
|
20
19
|
s.add_dependency("padrino-helpers", Padrino.version)
|
21
|
-
end
|
20
|
+
end
|
@@ -3,85 +3,92 @@ require File.expand_path(File.dirname(__FILE__) + '/../helper')
|
|
3
3
|
class TestAdminAppGenerator < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
6
|
+
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
|
7
|
+
`mkdir -p #{@apptmp}`
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
`rm -rf #{@apptmp}`
|
7
12
|
end
|
8
13
|
|
9
14
|
context 'the admin app generator' do
|
10
15
|
|
11
16
|
should 'fail outside app root' do
|
12
|
-
output = silence_logger { generate(:admin_app,
|
17
|
+
output = silence_logger { generate(:admin_app, "-r=#{@apptmp}") }
|
13
18
|
assert_match(/not at the root/, output)
|
14
19
|
assert_no_file_exists('/tmp/admin')
|
15
20
|
end
|
16
21
|
|
17
|
-
should 'fail if we don\'t an orm' do
|
18
|
-
assert_nothing_raised { silence_logger { generate(:project, 'sample_project',
|
19
|
-
assert_raise(SystemExit) { silence_logger { generate(:admin_app,
|
22
|
+
should 'fail if we don\'t specify an orm' do
|
23
|
+
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}") } }
|
24
|
+
assert_raise(SystemExit) { silence_logger { generate(:admin_app, "-r=#{@apptmp}/sample_project") } }
|
20
25
|
end
|
21
26
|
|
22
|
-
should 'fail if we don\'t a valid theme' do
|
23
|
-
assert_nothing_raised { silence_logger { generate(:project, 'sample_project',
|
24
|
-
assert_raise(SystemExit) { silence_logger { generate(:admin_app,
|
27
|
+
should 'fail if we don\'t specify a valid theme' do
|
28
|
+
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord') } }
|
29
|
+
assert_raise(SystemExit) { silence_logger { generate(:admin_app, "-r=#{@apptmp}/sample_project", '--theme=foo') } }
|
25
30
|
end
|
26
31
|
|
27
|
-
should '
|
28
|
-
assert_nothing_raised { silence_logger { generate(:project, 'sample_project',
|
29
|
-
assert_nothing_raised { silence_logger { generate(:admin_app,
|
30
|
-
assert_file_exists(
|
31
|
-
assert_file_exists(
|
32
|
-
assert_file_exists(
|
33
|
-
assert_file_exists(
|
34
|
-
assert_file_exists(
|
35
|
-
assert_file_exists(
|
36
|
-
assert_file_exists(
|
37
|
-
assert_file_exists(
|
38
|
-
assert_file_exists(
|
39
|
-
assert_file_exists(
|
40
|
-
assert_file_exists(
|
41
|
-
assert_file_exists(
|
42
|
-
assert_file_exists(
|
43
|
-
assert_file_exists(
|
44
|
-
assert_file_exists(
|
45
|
-
assert_file_exists(
|
46
|
-
assert_file_exists(
|
47
|
-
assert_file_exists(
|
48
|
-
assert_file_exists(
|
49
|
-
assert_file_exists(
|
50
|
-
assert_file_exists(
|
51
|
-
assert_file_exists(
|
52
|
-
|
53
|
-
assert_match_in_file '
|
54
|
-
assert_match_in_file '
|
32
|
+
should 'correctly generate a new padrino admin application with default renderer' do
|
33
|
+
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') } }
|
34
|
+
assert_nothing_raised { silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") } }
|
35
|
+
assert_file_exists("#{@apptmp}/sample_project")
|
36
|
+
assert_file_exists("#{@apptmp}/sample_project/admin")
|
37
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
|
38
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers")
|
39
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers/accounts.rb")
|
40
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers/base.rb")
|
41
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers/sessions.rb")
|
42
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views")
|
43
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/_form.haml")
|
44
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/edit.haml")
|
45
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/index.haml")
|
46
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/new.haml")
|
47
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.haml")
|
48
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.haml")
|
49
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/base/_sidebar.haml")
|
50
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.haml")
|
51
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/layouts/application.haml")
|
52
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.haml")
|
53
|
+
assert_file_exists("#{@apptmp}/sample_project/public/admin")
|
54
|
+
assert_file_exists("#{@apptmp}/sample_project/public/admin/stylesheets")
|
55
|
+
assert_file_exists("#{@apptmp}/sample_project/app/models/account.rb")
|
56
|
+
assert_file_exists("#{@apptmp}/sample_project/db/seeds.rb")
|
57
|
+
assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_accounts.rb")
|
58
|
+
assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
|
59
|
+
assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
|
60
|
+
assert_match_in_file 'role.project_module :accounts, "/accounts"', "#{@apptmp}/sample_project/admin/app.rb"
|
55
61
|
end
|
56
62
|
|
57
|
-
should '
|
58
|
-
assert_nothing_raised { silence_logger { generate(:project, 'sample_project',
|
59
|
-
assert_nothing_raised { silence_logger { generate(:admin_app,
|
60
|
-
assert_file_exists(
|
61
|
-
assert_file_exists(
|
62
|
-
assert_file_exists(
|
63
|
-
assert_file_exists(
|
64
|
-
assert_file_exists(
|
65
|
-
assert_file_exists(
|
66
|
-
assert_file_exists(
|
67
|
-
assert_file_exists(
|
68
|
-
assert_file_exists(
|
69
|
-
assert_file_exists(
|
70
|
-
assert_file_exists(
|
71
|
-
assert_file_exists(
|
72
|
-
assert_file_exists(
|
73
|
-
assert_file_exists(
|
74
|
-
assert_file_exists(
|
75
|
-
assert_file_exists(
|
76
|
-
assert_file_exists(
|
77
|
-
assert_file_exists(
|
78
|
-
assert_file_exists(
|
79
|
-
assert_file_exists(
|
80
|
-
assert_file_exists(
|
81
|
-
assert_file_exists(
|
82
|
-
|
83
|
-
assert_match_in_file '
|
84
|
-
assert_match_in_file '
|
63
|
+
should 'correctly generate a new padrino admin application with erb renderer' do
|
64
|
+
assert_nothing_raised { silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=erb') } }
|
65
|
+
assert_nothing_raised { silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") } }
|
66
|
+
assert_file_exists("#{@apptmp}/sample_project")
|
67
|
+
assert_file_exists("#{@apptmp}/sample_project/admin")
|
68
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
|
69
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers")
|
70
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers/accounts.rb")
|
71
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers/base.rb")
|
72
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/controllers/sessions.rb")
|
73
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views")
|
74
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/_form.erb")
|
75
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/edit.erb")
|
76
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/index.erb")
|
77
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/accounts/new.erb")
|
78
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.erb")
|
79
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.erb")
|
80
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/base/_sidebar.erb")
|
81
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/base/index.erb")
|
82
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/layouts/application.erb")
|
83
|
+
assert_file_exists("#{@apptmp}/sample_project/admin/views/sessions/new.erb")
|
84
|
+
assert_file_exists("#{@apptmp}/sample_project/public/admin")
|
85
|
+
assert_file_exists("#{@apptmp}/sample_project/public/admin/stylesheets")
|
86
|
+
assert_file_exists("#{@apptmp}/sample_project/app/models/account.rb")
|
87
|
+
assert_file_exists("#{@apptmp}/sample_project/db/seeds.rb")
|
88
|
+
assert_file_exists("#{@apptmp}/sample_project/db/migrate/001_create_accounts.rb")
|
89
|
+
assert_match_in_file 'Padrino.mount("Admin").to("/admin")', "#{@apptmp}/sample_project/config/apps.rb"
|
90
|
+
assert_match_in_file 'class Admin < Padrino::Application', "#{@apptmp}/sample_project/admin/app.rb"
|
91
|
+
assert_match_in_file 'role.project_module :accounts, "/accounts"', "#{@apptmp}/sample_project/admin/app.rb"
|
85
92
|
end
|
86
93
|
end
|
87
|
-
end
|
94
|
+
end
|
@@ -15,85 +15,90 @@ end
|
|
15
15
|
class TestAdminPageGenerator < Test::Unit::TestCase
|
16
16
|
|
17
17
|
def setup
|
18
|
-
|
18
|
+
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
|
19
|
+
`mkdir -p #{@apptmp}`
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
`rm -rf #{@apptmp}`
|
19
24
|
end
|
20
25
|
|
21
26
|
context 'the admin page generator' do
|
22
27
|
|
23
28
|
should 'fail outside app root' do
|
24
|
-
output = silence_logger { generate(:admin_page, 'foo',
|
29
|
+
output = silence_logger { generate(:admin_page, 'foo', "-r=#{@apptmp}/sample_project") }
|
25
30
|
assert_match(/not at the root/, output)
|
26
31
|
assert_no_file_exists('/tmp/admin')
|
27
32
|
end
|
28
33
|
|
29
34
|
should 'fail without argument and model' do
|
30
|
-
silence_logger { generate(:project, 'sample_project',
|
31
|
-
silence_logger { generate(:admin_app,
|
32
|
-
assert_raise(Padrino::Admin::Generators::OrmError) { generate(:admin_page, 'foo',
|
35
|
+
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord') }
|
36
|
+
silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
37
|
+
assert_raise(Padrino::Admin::Generators::OrmError) { generate(:admin_page, 'foo', "-r=#{@apptmp}/sample_project") }
|
33
38
|
end
|
34
39
|
|
35
40
|
should 'correctly generate a new padrino admin application default renderer' do
|
36
|
-
silence_logger { generate(:project, 'sample_project',
|
37
|
-
silence_logger { generate(:admin_app,
|
38
|
-
silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string",
|
39
|
-
silence_logger { generate(:admin_page, 'person',
|
40
|
-
assert_file_exists
|
41
|
-
assert_file_exists
|
42
|
-
assert_file_exists
|
43
|
-
assert_file_exists
|
44
|
-
assert_file_exists
|
41
|
+
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
42
|
+
silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
43
|
+
silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
|
44
|
+
silence_logger { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
|
45
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
|
46
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
47
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.haml"
|
48
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.haml"
|
49
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.haml"
|
45
50
|
%w(name age email).each do |field|
|
46
|
-
assert_match_in_file "label :#{field}",
|
47
|
-
assert_match_in_file "text_field :#{field}",
|
51
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
52
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
48
53
|
end
|
49
|
-
assert_match_in_file 'role.project_module :people, "/people"',
|
54
|
+
assert_match_in_file 'role.project_module :people, "/people"', "#{@apptmp}/sample_project/admin/app.rb"
|
50
55
|
end
|
51
56
|
|
52
57
|
should 'correctly generate a new padrino admin application with erb renderer' do
|
53
|
-
silence_logger { generate(:project, 'sample_project',
|
54
|
-
silence_logger { generate(:admin_app,
|
55
|
-
silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string",
|
56
|
-
silence_logger { generate(:admin_page, 'person',
|
57
|
-
assert_file_exists
|
58
|
-
assert_file_exists
|
59
|
-
assert_file_exists
|
60
|
-
assert_file_exists
|
61
|
-
assert_file_exists
|
58
|
+
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper', '-e=erb') }
|
59
|
+
silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
60
|
+
silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
|
61
|
+
silence_logger { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
|
62
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
|
63
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.erb"
|
64
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.erb"
|
65
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.erb"
|
66
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.erb"
|
62
67
|
%w(name age email).each do |field|
|
63
|
-
assert_match_in_file "label :#{field}",
|
64
|
-
assert_match_in_file "text_field :#{field}",
|
68
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
|
69
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
|
65
70
|
end
|
66
|
-
assert_match_in_file 'role.project_module :people, "/people"',
|
71
|
+
assert_match_in_file 'role.project_module :people, "/people"', "#{@apptmp}/sample_project/admin/app.rb"
|
67
72
|
end
|
68
73
|
|
69
74
|
should 'correctly generate a new padrino admin application with multiple models' do
|
70
|
-
silence_logger { generate(:project, 'sample_project',
|
71
|
-
silence_logger { generate(:admin_app,
|
72
|
-
silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string",
|
73
|
-
silence_logger { generate(:model, 'page', "name:string", "body:string",
|
74
|
-
silence_logger { generate(:admin_page, 'person', 'page',
|
75
|
+
silence_logger { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
76
|
+
silence_logger { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
77
|
+
silence_logger { generate(:model, 'person', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
|
78
|
+
silence_logger { generate(:model, 'page', "name:string", "body:string", "-root=#{@apptmp}/sample_project") }
|
79
|
+
silence_logger { generate(:admin_page, 'person', 'page', "--root=#{@apptmp}/sample_project") }
|
75
80
|
# For Person
|
76
|
-
assert_file_exists
|
77
|
-
assert_file_exists
|
78
|
-
assert_file_exists
|
79
|
-
assert_file_exists
|
80
|
-
assert_file_exists
|
81
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
|
82
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
83
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.haml"
|
84
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.haml"
|
85
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.haml"
|
81
86
|
%w(name age email).each do |field|
|
82
|
-
assert_match_in_file "label :#{field}",
|
83
|
-
assert_match_in_file "text_field :#{field}",
|
87
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
88
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
84
89
|
end
|
85
|
-
assert_match_in_file 'role.project_module :people, "/people"',
|
90
|
+
assert_match_in_file 'role.project_module :people, "/people"', "#{@apptmp}/sample_project/admin/app.rb"
|
86
91
|
# For Page
|
87
|
-
assert_file_exists
|
88
|
-
assert_file_exists
|
89
|
-
assert_file_exists
|
90
|
-
assert_file_exists
|
91
|
-
assert_file_exists
|
92
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/pages.rb"
|
93
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/_form.haml"
|
94
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/edit.haml"
|
95
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/index.haml"
|
96
|
+
assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/new.haml"
|
92
97
|
%w(name body).each do |field|
|
93
|
-
assert_match_in_file "label :#{field}",
|
94
|
-
assert_match_in_file "text_field :#{field}",
|
98
|
+
assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/pages/_form.haml"
|
99
|
+
assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/pages/_form.haml"
|
95
100
|
end
|
96
|
-
assert_match_in_file 'role.project_module :pages, "/pages"',
|
101
|
+
assert_match_in_file 'role.project_module :pages, "/pages"', "#{@apptmp}/sample_project/admin/app.rb"
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|
data/test/helper.rb
CHANGED
@@ -4,6 +4,7 @@ PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
|
4
4
|
require File.expand_path('../../../load_paths', __FILE__)
|
5
5
|
require 'test/unit'
|
6
6
|
require 'rack/test'
|
7
|
+
require 'uuid'
|
7
8
|
require 'rack'
|
8
9
|
require 'shoulda'
|
9
10
|
require 'thor/group'
|
@@ -53,17 +54,11 @@ class Test::Unit::TestCase
|
|
53
54
|
Rack::Lint.new(@app)
|
54
55
|
end
|
55
56
|
|
56
|
-
# generate(:admin_app,
|
57
|
+
# generate(:admin_app, "-r=#{@apptmp}/sample_project")
|
57
58
|
def generate(name, *params)
|
58
59
|
"Padrino::Generators::#{name.to_s.camelize}".constantize.start(params)
|
59
60
|
end
|
60
61
|
|
61
|
-
# Asserts that a file matches the pattern
|
62
|
-
def assert_match_in_file(pattern, file)
|
63
|
-
assert File.exist?(file), "File '#{file}' does not exist!"
|
64
|
-
assert_match pattern, File.read(file)
|
65
|
-
end
|
66
|
-
|
67
62
|
# Assert_file_exists('/tmp/app')
|
68
63
|
def assert_file_exists(file_path)
|
69
64
|
assert File.exist?(file_path), "File at path '#{file_path}' does not exist!"
|
@@ -93,4 +88,4 @@ class Test::Unit::TestCase
|
|
93
88
|
end
|
94
89
|
|
95
90
|
alias :response :last_response
|
96
|
-
end
|
91
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 16
|
10
|
+
version: 0.9.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Padrino Team
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-
|
21
|
+
date: 2010-09-24 00:00:00 +02:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -29,46 +29,30 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - "="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
hash:
|
32
|
+
hash: 27
|
33
33
|
segments:
|
34
34
|
- 0
|
35
35
|
- 9
|
36
|
-
-
|
37
|
-
version: 0.9.
|
36
|
+
- 16
|
37
|
+
version: 0.9.16
|
38
38
|
type: :runtime
|
39
39
|
version_requirements: *id001
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
|
-
name: padrino-
|
41
|
+
name: padrino-helpers
|
42
42
|
prerelease: false
|
43
43
|
requirement: &id002 !ruby/object:Gem::Requirement
|
44
44
|
none: false
|
45
45
|
requirements:
|
46
46
|
- - "="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
hash:
|
48
|
+
hash: 27
|
49
49
|
segments:
|
50
50
|
- 0
|
51
51
|
- 9
|
52
|
-
-
|
53
|
-
version: 0.9.
|
52
|
+
- 16
|
53
|
+
version: 0.9.16
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: padrino-helpers
|
58
|
-
prerelease: false
|
59
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
|
-
requirements:
|
62
|
-
- - "="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
hash: 37
|
65
|
-
segments:
|
66
|
-
- 0
|
67
|
-
- 9
|
68
|
-
- 15
|
69
|
-
version: 0.9.15
|
70
|
-
type: :runtime
|
71
|
-
version_requirements: *id003
|
72
56
|
description: Admin View for Padrino applications
|
73
57
|
email: padrinorb@gmail.com
|
74
58
|
executables: []
|