padrino-admin 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +3 -3
- data/.yardopts +1 -0
- data/{LICENSE → LICENSE.txt} +0 -0
- data/lib/padrino-admin/access_control.rb +34 -2
- data/lib/padrino-admin/generators/admin_app.rb +10 -11
- data/lib/padrino-admin/generators/templates/app.rb.tt +11 -11
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css +8 -8
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec-green/style.css +5 -5
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css +5 -5
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/blue/style.css +9 -9
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/djime-cerulean/style.css +1 -1
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/kathleene/style.css +9 -9
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/olive/style.css +8 -8
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/orange/style.css +7 -7
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/reidb-greenish/style.css +27 -27
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/ruby/style.css +9 -9
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/warehouse/style.css +3 -3
- data/lib/padrino-admin/helpers/authentication_helpers.rb +1 -2
- data/lib/padrino-admin/helpers/view_helpers.rb +23 -6
- data/lib/padrino-admin/locale/admin/lv.yml +16 -0
- data/lib/padrino-admin/locale/admin/zh_cn.yml +3 -3
- data/lib/padrino-admin/locale/orm/lv.yml +26 -0
- data/test/generators/test_account_model_generator.rb +9 -9
- data/test/generators/test_admin_app_generator.rb +24 -23
- data/test/generators/test_admin_page_generator.rb +24 -24
- data/test/helper.rb +6 -19
- data/test/test_admin_application.rb +1 -1
- data/test/test_locale.rb +1 -1
- metadata +14 -11
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../helper')
|
2
2
|
|
3
|
-
|
3
|
+
describe "AdminAppGenerator" do
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
|
@@ -14,24 +14,24 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
14
14
|
context 'the admin app generator' do
|
15
15
|
|
16
16
|
should 'fail outside app root' do
|
17
|
-
|
18
|
-
assert_match(/not at the root/,
|
17
|
+
out, err = capture_io { generate(:admin_app, "-r=#{@apptmp}") }
|
18
|
+
assert_match(/not at the root/, out)
|
19
19
|
assert_no_file_exists('/tmp/admin')
|
20
20
|
end
|
21
21
|
|
22
|
-
should
|
23
|
-
|
24
|
-
|
22
|
+
should "fail if we don't specify an orm" do
|
23
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-e=haml') }
|
24
|
+
assert_raises(SystemExit) { @out, @err = capture_io { generate(:admin_app, "-r=#{@apptmp}/sample_project") } }
|
25
25
|
end
|
26
26
|
|
27
|
-
should
|
28
|
-
|
29
|
-
|
27
|
+
should "fail if we don't specify a valid theme" do
|
28
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') }
|
29
|
+
assert_raises(SystemExit) { @out, @err = capture_io { generate(:admin_app, "-r=#{@apptmp}/sample_project", '--theme=foo') } }
|
30
30
|
end
|
31
31
|
|
32
32
|
should 'correctly generate a new padrino admin application with default renderer' do
|
33
|
-
|
34
|
-
|
33
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') }
|
34
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
35
35
|
assert_file_exists("#{@apptmp}/sample_project")
|
36
36
|
assert_file_exists("#{@apptmp}/sample_project/admin")
|
37
37
|
assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
|
@@ -62,8 +62,8 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
should 'correctly generate a new padrino admin application with erb renderer' do
|
65
|
-
|
66
|
-
|
65
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=erb') }
|
66
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
67
67
|
assert_file_exists("#{@apptmp}/sample_project")
|
68
68
|
assert_file_exists("#{@apptmp}/sample_project/admin")
|
69
69
|
assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
|
@@ -94,8 +94,8 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
94
94
|
end
|
95
95
|
|
96
96
|
should 'correctly generate a new padrino admin application with slim renderer' do
|
97
|
-
|
98
|
-
|
97
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=slim') }
|
98
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
99
99
|
assert_file_exists("#{@apptmp}/sample_project")
|
100
100
|
assert_file_exists("#{@apptmp}/sample_project/admin")
|
101
101
|
assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
|
@@ -126,8 +126,8 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
126
126
|
end
|
127
127
|
|
128
128
|
should 'correctly generate a new padrino admin application with model in non-default application path' do
|
129
|
-
|
130
|
-
|
129
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') }
|
130
|
+
capture_io { generate(:admin_app,"-a=/admin", "--root=#{@apptmp}/sample_project") }
|
131
131
|
assert_file_exists("#{@apptmp}/sample_project")
|
132
132
|
assert_file_exists("#{@apptmp}/sample_project/admin")
|
133
133
|
assert_file_exists("#{@apptmp}/sample_project/admin/app.rb")
|
@@ -159,7 +159,7 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
159
159
|
end
|
160
160
|
|
161
161
|
should 'not conflict with existing seeds file' do
|
162
|
-
|
162
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord', '-e=erb') }
|
163
163
|
|
164
164
|
# Add seeds file
|
165
165
|
FileUtils.mkdir_p @apptmp + '/sample_project/db' unless File.exist?(@apptmp + '/sample_project/db')
|
@@ -167,7 +167,7 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
167
167
|
seeds_rb.puts "# Old Seeds Content"
|
168
168
|
end
|
169
169
|
|
170
|
-
|
170
|
+
capture_io do
|
171
171
|
$stdout.expects(:print).with { |value| value =~ /Overwrite\s.*?\/db\/seeds.rb/ }.never
|
172
172
|
$stdin.stubs(:gets).returns('y')
|
173
173
|
generate(:admin_app, "--root=#{@apptmp}/sample_project")
|
@@ -178,10 +178,11 @@ class TestAdminAppGenerator < Test::Unit::TestCase
|
|
178
178
|
end
|
179
179
|
|
180
180
|
should "navigate completely inside an app with activerecord" do
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
181
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", "-d=activerecord", "-e=haml", "--dev") }
|
182
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
183
|
+
skip "Check bundle install and rake"
|
184
|
+
bundle(:install, :gemfile => "#{@apptmp}/sample_project/Gemfile", :path => "#{@apptmp}/bundle")
|
185
|
+
cli(:rake, '-T', "-c=#{@apptmp}/sample_project")
|
185
186
|
end
|
186
187
|
end
|
187
188
|
end
|
@@ -12,7 +12,7 @@ class Page
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
describe "AdminPageGenerator" do
|
16
16
|
|
17
17
|
def setup
|
18
18
|
@apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
|
@@ -26,22 +26,22 @@ class TestAdminPageGenerator < Test::Unit::TestCase
|
|
26
26
|
context 'the admin page generator' do
|
27
27
|
|
28
28
|
should 'fail outside app root' do
|
29
|
-
|
30
|
-
assert_match(/not at the root/,
|
29
|
+
out, err = capture_io { generate(:admin_page, 'foo', "-r=#{@apptmp}/sample_project") }
|
30
|
+
assert_match(/not at the root/, out)
|
31
31
|
assert_no_file_exists('/tmp/admin')
|
32
32
|
end
|
33
33
|
|
34
34
|
should 'fail without argument and model' do
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=activerecord') }
|
36
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
37
|
+
assert_raises(Padrino::Admin::Generators::OrmError) { generate(:admin_page, 'foo', "-r=#{@apptmp}/sample_project") }
|
38
38
|
end
|
39
39
|
|
40
40
|
should 'correctly generate a new padrino admin application default renderer' do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
42
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
43
|
+
capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
|
44
|
+
capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
|
45
45
|
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
|
46
46
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
47
47
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.haml"
|
@@ -57,15 +57,15 @@ class TestAdminPageGenerator < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
should "store and apply session_secret" do
|
60
|
-
|
60
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
61
61
|
assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb")
|
62
62
|
end
|
63
63
|
|
64
64
|
should 'correctly generate a new padrino admin application with erb renderer' do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper', '-e=erb') }
|
66
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
67
|
+
capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
|
68
|
+
capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
|
69
69
|
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
|
70
70
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.erb"
|
71
71
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.erb"
|
@@ -81,10 +81,10 @@ class TestAdminPageGenerator < Test::Unit::TestCase
|
|
81
81
|
end
|
82
82
|
|
83
83
|
should 'correctly generate a new padrino admin application with slim renderer' do
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper', '-e=slim') }
|
85
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
86
|
+
capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
|
87
|
+
capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
|
88
88
|
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
|
89
89
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.slim"
|
90
90
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.slim"
|
@@ -100,11 +100,11 @@ class TestAdminPageGenerator < Test::Unit::TestCase
|
|
100
100
|
end
|
101
101
|
|
102
102
|
should 'correctly generate a new padrino admin application with multiple models' do
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
|
104
|
+
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
|
105
|
+
capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
|
106
|
+
capture_io { generate(:model, 'page', "name:string", "body:string", "-root=#{@apptmp}/sample_project") }
|
107
|
+
capture_io { generate(:admin_page, 'person', 'page', "--root=#{@apptmp}/sample_project") }
|
108
108
|
# For Person
|
109
109
|
assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
|
110
110
|
assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.haml"
|
data/test/helper.rb
CHANGED
@@ -2,12 +2,10 @@ ENV['PADRINO_ENV'] = 'test'
|
|
2
2
|
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
3
3
|
|
4
4
|
require File.expand_path('../../../load_paths', __FILE__)
|
5
|
-
require 'test
|
5
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'padrino-core', 'test', 'mini_shoulda')
|
6
6
|
require 'rack/test'
|
7
|
-
require 'uuid'
|
8
7
|
require 'rack'
|
9
|
-
require '
|
10
|
-
require 'mocha'
|
8
|
+
require 'uuid'
|
11
9
|
require 'thor/group'
|
12
10
|
require 'padrino-core/support_lite' unless defined?(SupportLite)
|
13
11
|
require 'padrino-admin'
|
@@ -15,31 +13,20 @@ require 'padrino-admin'
|
|
15
13
|
Padrino::Generators.load_components!
|
16
14
|
|
17
15
|
module Kernel
|
18
|
-
# Silences the output by redirecting to stringIO
|
19
|
-
# silence_logger { ...commands... } => "...output..."
|
20
|
-
def silence_logger(&block)
|
21
|
-
$stdout = $stderr = log_buffer = StringIO.new
|
22
|
-
block.call
|
23
|
-
$stdout = STDOUT
|
24
|
-
$stderr = STDERR
|
25
|
-
log_buffer.string
|
26
|
-
end
|
27
|
-
alias :silence_stdout :silence_logger
|
28
|
-
|
29
16
|
def load_fixture(file)
|
30
17
|
Object.send(:remove_const, :Account) if defined?(Account)
|
31
18
|
Object.send(:remove_const, :Category) if defined?(Category)
|
32
19
|
file += ".rb" if file !~ /.rb$/
|
33
|
-
|
20
|
+
capture_io { load File.join(File.dirname(__FILE__), "fixtures", file) }
|
34
21
|
end
|
35
22
|
end
|
36
23
|
|
37
24
|
class Class
|
38
25
|
# Allow assertions in request context
|
39
|
-
include
|
26
|
+
include MiniTest::Assertions
|
40
27
|
end
|
41
28
|
|
42
|
-
class
|
29
|
+
class MiniTest::Spec
|
43
30
|
include Rack::Test::Methods
|
44
31
|
|
45
32
|
# Sets up a Sinatra::Base subclass defined with the block
|
@@ -47,7 +34,7 @@ class Test::Unit::TestCase
|
|
47
34
|
# the application.
|
48
35
|
def mock_app(base=Padrino::Application, &block)
|
49
36
|
@app = Sinatra.new(base, &block)
|
50
|
-
@app.send :include,
|
37
|
+
@app.send :include, MiniTest::Assertions
|
51
38
|
@app.register Padrino::Helpers
|
52
39
|
end
|
53
40
|
|
data/test/test_locale.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
|
3
|
-
|
3
|
+
describe "Filters" do
|
4
4
|
Dir[File.expand_path("../../lib/padrino-admin/locale/admin/*.yml", __FILE__)].each do |file|
|
5
5
|
name = File.basename(file, '.yml')
|
6
6
|
should "have a vaild #{name} locale for admin" do
|
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: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 0.10.
|
9
|
+
- 3
|
10
|
+
version: 0.10.3
|
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: 2011-
|
21
|
+
date: 2011-10-03 00:00:00 -07:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -29,12 +29,12 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - "="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
hash:
|
32
|
+
hash: 49
|
33
33
|
segments:
|
34
34
|
- 0
|
35
35
|
- 10
|
36
|
-
-
|
37
|
-
version: 0.10.
|
36
|
+
- 3
|
37
|
+
version: 0.10.3
|
38
38
|
type: :runtime
|
39
39
|
version_requirements: *id001
|
40
40
|
- !ruby/object:Gem::Dependency
|
@@ -45,12 +45,12 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
hash:
|
48
|
+
hash: 49
|
49
49
|
segments:
|
50
50
|
- 0
|
51
51
|
- 10
|
52
|
-
-
|
53
|
-
version: 0.10.
|
52
|
+
- 3
|
53
|
+
version: 0.10.3
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
56
|
description: Admin View for Padrino applications
|
@@ -64,7 +64,8 @@ extra_rdoc_files:
|
|
64
64
|
files:
|
65
65
|
- .document
|
66
66
|
- .gitignore
|
67
|
-
-
|
67
|
+
- .yardopts
|
68
|
+
- LICENSE.txt
|
68
69
|
- README.rdoc
|
69
70
|
- Rakefile
|
70
71
|
- lib/padrino-admin.rb
|
@@ -132,6 +133,7 @@ files:
|
|
132
133
|
- lib/padrino-admin/locale/admin/hu.yml
|
133
134
|
- lib/padrino-admin/locale/admin/it.yml
|
134
135
|
- lib/padrino-admin/locale/admin/ja.yml
|
136
|
+
- lib/padrino-admin/locale/admin/lv.yml
|
135
137
|
- lib/padrino-admin/locale/admin/nl.yml
|
136
138
|
- lib/padrino-admin/locale/admin/no.yml
|
137
139
|
- lib/padrino-admin/locale/admin/pl.yml
|
@@ -150,6 +152,7 @@ files:
|
|
150
152
|
- lib/padrino-admin/locale/orm/hu.yml
|
151
153
|
- lib/padrino-admin/locale/orm/it.yml
|
152
154
|
- lib/padrino-admin/locale/orm/ja.yml
|
155
|
+
- lib/padrino-admin/locale/orm/lv.yml
|
153
156
|
- lib/padrino-admin/locale/orm/nl.yml
|
154
157
|
- lib/padrino-admin/locale/orm/no.yml
|
155
158
|
- lib/padrino-admin/locale/orm/pl.yml
|