padrino-admin 0.12.9 → 0.13.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YTdlNDEzYzg0NjE3NDNkOTFhOTdlODFiY2I3Y2IwOTMwNGIyMDFhMw==
5
- data.tar.gz: !binary |-
6
- MDNjMzgzODk4MmIyN2ZmZTM0MTIyZjU5ZjRiNzk3OTU4ZDY1MTZlOQ==
2
+ SHA1:
3
+ metadata.gz: 075a91f178b97e4b77bf2a317dfd6b19023a9821
4
+ data.tar.gz: 6f64155d39707b903644f21dd97a5437d0fc8ba3
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NjM4YzEwMThlNjBhNmFmNzFhNjkwZWRjY2M2ODI5OWI4NDRiZWE5NDk5MWYy
10
- YzViMjg0YTEyM2U5YWFhZDdjMGUzZGNlMjE2M2U2NjU5NDRhY2U3MWJmOTM5
11
- ZTBlMmQwMjlhZTZkNjczM2E4MDE1YTc3ZTA3NGZiZmNjODU0NGM=
12
- data.tar.gz: !binary |-
13
- YTJhZjkxZDVjMjdjNzMwODZmNjBjN2QyZmZhNmM1NTUwYmY3YmEwNmMwYzYx
14
- NzAzYjk2MDQzNmJkMzRlZjZkZDYyOTg3Y2MxODE4ZDhlZjdjY2FkNzk4OWE5
15
- NjdhMDE4MWE4OWVhNWQzY2RkODdjYTQ5NGUzZTI0NmZkNDU3Njg=
6
+ metadata.gz: ccc59406df0dd0e3d4847644ee53727c9b3a657a548a20b75667c60346c3f54bade33a0b4fe6dfcb0d9fea40dc280c72a49f1c236442b5d2b4be02d5f05953f3
7
+ data.tar.gz: 7d31f4ec18bac84c382da388a151576d5e8ebffaa9f88442a27ceb13629e5b23f01dc72991b6727432a8ee95370c357a8fd0316fa94ad0bb083c999ba9c21b5f
data/lib/padrino-admin.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'active_support/core_ext/array/conversions'
1
2
  require 'padrino-core'
2
3
  require 'padrino-helpers'
3
4
 
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext/class/attribute_accessors'
2
+
1
3
  module Padrino
2
4
  module Admin
3
5
  class AccessControlError < StandardError
@@ -17,15 +19,7 @@ module Padrino
17
19
  app.helpers Padrino::Admin::Helpers::AuthenticationHelpers
18
20
  app.helpers Padrino::Admin::Helpers::ViewHelpers
19
21
  app.before { login_required }
20
- app.class_eval do
21
- class << self
22
- attr_accessor :access_control
23
- end
24
- def access_control
25
- self.class.access_control
26
- end
27
- end
28
-
22
+ app.send(:cattr_accessor, :access_control)
29
23
  app.send(:access_control=, Padrino::Admin::AccessControl::Base.new)
30
24
  end
31
25
  alias :included :registered
@@ -49,7 +49,7 @@ module Padrino
49
49
 
50
50
  tmp_ext = options[:renderer] || fetch_component_choice(:renderer)
51
51
  unless supported_ext.include?(tmp_ext.to_sym)
52
- say "<= You are using '#{tmp_ext}' and for admin we only support '#{supported_ext.join(', ')}'. Please use #{supported_ext.map { |ext| '-e ' + ext }.join(' or ')}", :yellow
52
+ say "<= Your are using '#{tmp_ext}' and for admin we only support '#{supported_ext.join(', ')}'. Please use -e haml or -e erb or -e slim", :yellow
53
53
  raise SystemExit
54
54
  end
55
55
 
@@ -76,8 +76,7 @@ module Padrino
76
76
  template "templates/app.rb.tt", destination_root(@admin_path + "/app.rb")
77
77
  inject_into_file destination_root('config/apps.rb'), "\nPadrino.mount(\"#{@app_name}::#{@admin_name}\", :app_file => Padrino.root('#{@admin_path}/app.rb')).to(\"/#{@admin_path}\")\n", :before => /^Padrino.mount.*\.to\('\/'\)$/
78
78
  unless options[:destroy]
79
- insert_middleware 'ConnectionPoolManagement', @admin_path if [:minirecord, :activerecord].include?(orm)
80
- insert_middleware 'IdentityMap', @admin_path if orm == :datamapper
79
+ insert_middleware 'ActiveRecord::ConnectionAdapters::ConnectionManagement', @admin_path if [:minirecord, :activerecord].include?(orm)
81
80
  end
82
81
 
83
82
  params = [
@@ -44,11 +44,6 @@ class <%= @model_name %>
44
44
  ::BCrypt::Password.new(crypted_password) == password
45
45
  end
46
46
 
47
- def password=(password)
48
- self.crypted_password = nil if password.present?
49
- @password = password
50
- end
51
-
52
47
  private
53
48
 
54
49
  def password_required
@@ -6,7 +6,7 @@
6
6
  # shell.say name
7
7
  #
8
8
  email = shell.ask "Which email do you want use for logging into admin?"
9
- password = shell.ask "Tell me the password to use:", :echo => false
9
+ password = shell.ask "Tell me the password to use:"
10
10
 
11
11
  shell.say ""
12
12
 
@@ -18,7 +18,7 @@ if account.valid?
18
18
  shell.say "<%= @model_name %> has been successfully created, now you can login with:"
19
19
  shell.say "================================================================="
20
20
  shell.say " email: #{email}"
21
- shell.say " password: #{?* * password.length}"
21
+ shell.say " password: #{password}"
22
22
  shell.say "================================================================="
23
23
  else
24
24
  shell.say "Sorry, but something went wrong!"
@@ -20,7 +20,7 @@
20
20
  <ul class="nav navbar-nav pull-right">
21
21
  <li class=navbar-edit-account><%%= link_to tag_icon(:user), url(:<%= @model_plural %>, :edit, :id => current_account.id), :title => pat(:profile), :class => 'navbar-nav-link' %></li>
22
22
  <li class=navbar-logout>
23
- <%%= button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form', :submit_options => { :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' }) { tag_icon(:'power-off') } %>
23
+ <%%= button_to(:logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form') { content_tag :button, tag_icon(:'power-off'), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' } %>
24
24
  </li>
25
25
  </ul>
26
26
 
@@ -12,7 +12,7 @@
12
12
  <%%= tag_icon :magic %> <span class=caret></span>
13
13
  </a>
14
14
  <ul class="list-menu dropdown-menu" role=menu>
15
- <li class=list-menu-wrapper>
15
+ <li class=ist-menu-wrapper>
16
16
  <%%= link_to tag_icon('check-square-o', pat(:select_all)), '#', :id => 'select-all', :class => 'list-menu-link' %>
17
17
  </li>
18
18
  <li class=list-menu-wrapper.list-menu-wrapper-disabled>
@@ -20,8 +20,8 @@
20
20
  %ul.nav.navbar-nav.pull-right
21
21
  %li.navbar-edit-account=link_to tag_icon(:user), url(:accounts, :edit, :id => current_account.id), :title => pat(:profile), :class => 'navbar-nav-link'
22
22
  %li.navbar-logout
23
- = button_to :logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form', :submit_options => { :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' } do
24
- = tag_icon('power-off')
23
+ =button_to :logout, url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form' do
24
+ =content_tag :button, tag_icon('power-off'), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link'
25
25
 
26
26
  %ul.nav.navbar-nav.pull-left
27
27
  - project_modules.each do |project_module|
@@ -85,7 +85,7 @@
85
85
  <% else %>
86
86
  if <%= @orm.multiple_destroy(@orm.name_plural) %>
87
87
  <% end %>
88
- flash[:success] = pat(:destroy_many_success, :model => '<%= @orm.name_plural.capitalize %>', :ids => "#{ids.join(', ')}")
88
+ flash[:success] = pat(:destroy_many_success, :model => '<%= @orm.name_plural.capitalize %>', :ids => "#{ids.to_sentence}")
89
89
  end
90
90
  redirect url(:<%= @orm.name_plural %>, :index)
91
91
  end
@@ -20,9 +20,8 @@ html lang='en'
20
20
 
21
21
  ul class='nav navbar-nav pull-right'
22
22
  li class='navbar-edit-account' = link_to tag_icon(:user), url(:<%= @model_plural %>, :edit, :id => current_account.id), :title => pat(:profile), :class => 'navbar-nav-link'
23
- li class='navbar-logout'
24
- = button_to pat(:logout), url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form', :submit_options => { :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link' } do
25
- = tag_icon(:'power-off')
23
+ li class='navbar-logout' = button_to(pat(:logout), url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form') do
24
+ = content_tag :button, tag_icon(:'power-off'), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link'
26
25
 
27
26
  ul class='nav navbar-nav pull-left'
28
27
  - project_modules.each do |project_module|
@@ -1,6 +1,7 @@
1
1
  require 'digest/sha1'
2
2
  require 'sequel'
3
- require 'sequel/extensions/migration'
3
+
4
+ Sequel::Model.plugin(:schema)
4
5
 
5
6
  Sequel::Model.db =
6
7
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
@@ -11,6 +12,7 @@ Sequel::Model.db =
11
12
  Sequel.sqlite(":memory:")
12
13
  end
13
14
 
15
+ Sequel.extension :migration
14
16
  migration = Sequel.migration do
15
17
  up do
16
18
  create_table :accounts do
@@ -22,24 +24,11 @@ migration = Sequel.migration do
22
24
  String :role
23
25
  end
24
26
 
25
- create_table :sections do
27
+ create_table :categories do
26
28
  primary_key :id
27
29
  foreign_key :account_id
28
30
  String :name
29
31
  end
30
-
31
- create_table :friends do
32
- primary_key :id
33
- String :name
34
- String :age
35
- String :email
36
- end
37
-
38
- create_table :pages do
39
- primary_key :id
40
- String :name
41
- String :body
42
- end
43
32
  end
44
33
 
45
34
  down do
@@ -49,14 +38,8 @@ end
49
38
 
50
39
  migration.apply(Sequel::Model.db, :up)
51
40
 
52
- class Friend < Sequel::Model
53
- end
54
-
55
- class Page < Sequel::Model
56
- end
57
-
58
- # Fake Section Model
59
- class Section < Sequel::Model
41
+ # Fake Category Model
42
+ class Category < Sequel::Model
60
43
  many_to_one :account
61
44
  end
62
45
 
@@ -64,7 +47,7 @@ end
64
47
  class Account < Sequel::Model
65
48
  attr_accessor :password, :password_confirmation
66
49
 
67
- one_to_many :sections
50
+ one_to_many :categories
68
51
 
69
52
  def self.admin; first(:role => "admin"); end
70
53
  def self.editor; first(:role => "editor"); end
@@ -84,6 +67,6 @@ editor = Account.create(:name => "Dexter", :role => "editor", :email => "editor@
84
67
  :password => "some", :password_confirmation => "some")
85
68
 
86
69
  %w(News Press HowTo).each do |c|
87
- admin.add_section(:name => c)
88
- editor.add_section(:name => c)
70
+ admin.add_category(:name => c)
71
+ editor.add_category(:name => c)
89
72
  end
@@ -183,33 +183,19 @@ describe "AdminAppGenerator" do
183
183
  it 'should add it for #activerecord' do
184
184
  capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') }
185
185
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
186
- assert_match_in_file(/ use ConnectionPoolManagement/m, "#{@apptmp}/sample_project/admin/app.rb")
186
+ assert_match_in_file(/ use ActiveRecord::ConnectionAdapters::ConnectionManagemen/m, "#{@apptmp}/sample_project/admin/app.rb")
187
187
  end
188
188
 
189
189
  it 'should add it #minirecord' do
190
190
  capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=minirecord', '-e=haml') }
191
191
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
192
- assert_match_in_file(/ use ConnectionPoolManagement/m, "#{@apptmp}/sample_project/admin/app.rb")
192
+ assert_match_in_file(/ use ActiveRecord::ConnectionAdapters::ConnectionManagemen/m, "#{@apptmp}/sample_project/admin/app.rb")
193
193
  end
194
194
 
195
195
  it 'should not add it for #datamapper' do
196
196
  capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper', '-e=haml') }
197
197
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
198
- assert_no_match_in_file(/ use ConnectionPoolManagement/m, "#{@apptmp}/sample_project/admin/app.rb")
199
- end
200
- end
201
-
202
- describe "datamapper middleware" do
203
- it 'should add it for #datamapper' do
204
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper', '-e=haml') }
205
- capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
206
- assert_match_in_file(/ use IdentityMap/m, "#{@apptmp}/sample_project/admin/app.rb")
207
- end
208
-
209
- it 'should not add it for #activerecord' do
210
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=activerecord', '-e=haml') }
211
- capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
212
- assert_no_match_in_file(/ use IdentityMap/m, "#{@apptmp}/sample_project/admin/app.rb")
198
+ assert_no_match_in_file(/ use ActiveRecord::ConnectionAdapters::ConnectionManagemen/m, "#{@apptmp}/sample_project/admin/app.rb")
213
199
  end
214
200
  end
215
201
 
@@ -1,5 +1,16 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../helper')
2
- require File.join(File.dirname(__FILE__), '../fixtures/sequel')
2
+
3
+ class Person
4
+ def self.properties
5
+ [:id, :name, :age, :email].map { |c| OpenStruct.new(:name => c) }
6
+ end
7
+ end
8
+
9
+ class Page
10
+ def self.properties
11
+ [:id, :name, :body].map { |c| OpenStruct.new(:name => c) }
12
+ end
13
+ end
3
14
 
4
15
  describe "AdminPageGenerator" do
5
16
  before do
@@ -25,94 +36,94 @@ describe "AdminPageGenerator" do
25
36
  end
26
37
 
27
38
  it 'should correctly generate a new page' do
28
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=sequel','-e=haml') }
39
+ capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
29
40
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
30
- capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
31
- capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
32
- assert_file_exists "#{@apptmp}/sample_project/admin/controllers/friends.rb"
33
- assert_match_in_file "SampleProject::Admin.controllers :friends do", "#{@apptmp}/sample_project/admin/controllers/friends.rb"
34
- assert_match_in_file "role.project_module :friends, '/friends'", "#{@apptmp}/sample_project/admin/app.rb"
41
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
42
+ capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
43
+ assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
44
+ assert_match_in_file "SampleProject::Admin.controllers :people do", "#{@apptmp}/sample_project/admin/controllers/people.rb"
45
+ assert_match_in_file "role.project_module :people, '/people'", "#{@apptmp}/sample_project/admin/app.rb"
35
46
  assert_match_in_file "elsif Padrino.env == :development && params[:bypass]", "#{@apptmp}/sample_project/admin/controllers/sessions.rb"
36
47
  end
37
48
 
38
49
  # users can override certain templates from a generators/templates folder in the destination_root
39
50
  it "should use custom generator templates from the project root, if they exist" do
40
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=sequel','-e=haml') }
51
+ capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
41
52
  custom_template_path = "#{@apptmp}/sample_project/generators/templates/haml/page/"
42
53
  `mkdir -p #{custom_template_path} && echo "%h1= 'Hello, custom generator' " > #{custom_template_path}index.haml.tt`
43
54
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
44
- capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
45
- capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
46
- assert_match_in_file(/Hello, custom generator/, "#{@apptmp}/sample_project/admin/views/friends/index.haml")
55
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
56
+ capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
57
+ assert_match_in_file(/Hello, custom generator/, "#{@apptmp}/sample_project/admin/views/people/index.haml")
47
58
  end
48
59
 
49
60
  describe "renderers" do
50
61
  it 'should correctly generate a new page with haml' do
51
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=sequel','-e=haml') }
62
+ capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
52
63
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
53
- capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
54
- capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
55
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
56
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.haml"
57
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.haml"
58
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.haml"
64
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
65
+ capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
66
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.haml"
67
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.haml"
68
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.haml"
69
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.haml"
59
70
  %w(name age email).each do |field|
60
- assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
61
- assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
71
+ assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
72
+ assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
62
73
  end
63
74
  assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.haml"
64
75
  end
65
76
 
66
77
  it 'should correctly generate a new page with erb' do
67
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=sequel','-e=erb') }
78
+ capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=erb') }
68
79
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
69
- capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
70
- capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
71
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.erb"
72
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.erb"
73
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.erb"
74
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.erb"
80
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
81
+ capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
82
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.erb"
83
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.erb"
84
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.erb"
85
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.erb"
75
86
  %w(name age email).each do |field|
76
- assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.erb"
77
- assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.erb"
87
+ assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
88
+ assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
78
89
  end
79
90
  assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.erb"
80
91
  end
81
92
 
82
93
  it 'should correctly generate a new page with slim' do
83
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=sequel','-e=slim') }
94
+ capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=slim') }
84
95
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
85
- capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
86
- capture_io { generate(:admin_page, 'friend', "--root=#{@apptmp}/sample_project") }
87
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.slim"
88
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.slim"
89
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.slim"
90
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.slim"
96
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "--root=#{@apptmp}/sample_project") }
97
+ capture_io { generate(:admin_page, 'person', "--root=#{@apptmp}/sample_project") }
98
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.slim"
99
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.slim"
100
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.slim"
101
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.slim"
91
102
  %w(name age email).each do |field|
92
- assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.slim"
93
- assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.slim"
103
+ assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.slim"
104
+ assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.slim"
94
105
  end
95
106
  assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.slim"
96
107
  end
97
108
  end
98
109
 
99
110
  it 'should correctly generate a new padrino admin application with multiple models at the same time' do
100
- capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=sequel','-e=haml') }
111
+ capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper','-e=haml') }
101
112
  capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
102
- capture_io { generate(:model, 'friend', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
113
+ capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-root=#{@apptmp}/sample_project") }
103
114
  capture_io { generate(:model, 'page', "name:string", "body:string", "-root=#{@apptmp}/sample_project") }
104
- capture_io { generate(:admin_page, 'friend', 'page', "--root=#{@apptmp}/sample_project") }
105
- # For Friend
106
- assert_file_exists "#{@apptmp}/sample_project/admin/controllers/friends.rb"
107
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
108
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/edit.haml"
109
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/index.haml"
110
- assert_file_exists "#{@apptmp}/sample_project/admin/views/friends/new.haml"
115
+ capture_io { generate(:admin_page, 'person', 'page', "--root=#{@apptmp}/sample_project") }
116
+ # For Person
117
+ assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
118
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.haml"
119
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.haml"
120
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.haml"
121
+ assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.haml"
111
122
  %w(name age email).each do |field|
112
- assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
113
- assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/friends/_form.haml"
123
+ assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
124
+ assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.haml"
114
125
  end
115
- assert_match_in_file "role.project_module :friends, '/friends'", "#{@apptmp}/sample_project/admin/app.rb"
126
+ assert_match_in_file "role.project_module :people, '/people'", "#{@apptmp}/sample_project/admin/app.rb"
116
127
  # For Page
117
128
  assert_file_exists "#{@apptmp}/sample_project/admin/controllers/pages.rb"
118
129
  assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/_form.haml"
data/test/helper.rb CHANGED
@@ -6,7 +6,7 @@ require 'minitest/pride'
6
6
  require 'mocha/setup'
7
7
  require 'rack/test'
8
8
  require 'thor/group'
9
- require 'sequel/model'
9
+ require 'dm-core'
10
10
  require 'padrino-admin'
11
11
 
12
12
  require 'ext/minitest-spec'
@@ -109,7 +109,7 @@ describe "AdminApplication" do
109
109
  end
110
110
 
111
111
  # Prepare a basic page
112
- get "/login(/:role)" do
112
+ get "/login(/:role)?" do
113
113
  set_current_account(Account.send(params[:role])) if params[:role]
114
114
  "logged as #{params[:role] || "any"}"
115
115
  end
@@ -268,21 +268,4 @@ describe "AdminApplication" do
268
268
  get "/modules"
269
269
  assert_equal "admin => /admin", body
270
270
  end
271
-
272
- it 'should use different access control for different apps' do
273
- app1 = Sinatra.new Padrino::Application do
274
- register Padrino::Admin::AccessControl
275
- access_control.roles_for :any do |role|
276
- role.project_module :foo, "/foo"
277
- end
278
- end
279
- app2 = Sinatra.new Padrino::Application do
280
- register Padrino::Admin::AccessControl
281
- access_control.roles_for :any do |role|
282
- role.project_module :bar, "/bar"
283
- end
284
- end
285
- assert_equal '/foo', app1.access_control.project_modules(:any).first.path
286
- assert_equal '/bar', app2.access_control.project_modules(:any).first.path
287
- end
288
271
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.9
4
+ version: 0.13.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-02-23 00:00:00.000000000 Z
14
+ date: 2015-02-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-core
@@ -19,28 +19,28 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.12.9
22
+ version: 0.13.0.beta1
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.12.9
29
+ version: 0.13.0.beta1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: padrino-helpers
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 0.12.9
36
+ version: 0.13.0.beta1
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
- version: 0.12.9
43
+ version: 0.13.0.beta1
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: therubyracer
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -281,18 +281,26 @@ require_paths:
281
281
  - lib
282
282
  required_ruby_version: !ruby/object:Gem::Requirement
283
283
  requirements:
284
- - - ! '>='
284
+ - - '>='
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  requirements:
289
- - - ! '>='
289
+ - - '>'
290
290
  - !ruby/object:Gem::Version
291
- version: 1.3.6
291
+ version: 1.3.1
292
292
  requirements: []
293
293
  rubyforge_project: padrino-admin
294
- rubygems_version: 2.6.14
294
+ rubygems_version: 2.0.6
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: Admin Dashboard for Padrino
298
- test_files: []
298
+ test_files:
299
+ - test/fixtures/sequel.rb
300
+ - test/generators/test_account_model_generator.rb
301
+ - test/generators/test_admin_app_generator.rb
302
+ - test/generators/test_admin_page_generator.rb
303
+ - test/helper.rb
304
+ - test/test_admin_application.rb
305
+ - test/test_locale.rb
306
+ has_rdoc: