lazy-head-gen 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README.md +0 -52
  2. data/VERSION +1 -1
  3. data/lazy-head-gen.gemspec +1 -35
  4. data/lib/lazy-head-gen.rb +1 -1
  5. data/lib/lazy-head-gen/templates/admin_controller_test/admin_controller_test.rb.tt +0 -1
  6. metadata +3 -37
  7. data/lib/lazy-head-gen/bootstrapped_admin_app.rb +0 -119
  8. data/lib/lazy-head-gen/bootstrapped_admin_page.rb +0 -58
  9. data/lib/lazy-head-gen/templates/admin_app/account/activerecord.rb.tt +0 -38
  10. data/lib/lazy-head-gen/templates/admin_app/account/seeds.rb.tt +0 -28
  11. data/lib/lazy-head-gen/templates/admin_app/app.rb.tt +0 -36
  12. data/lib/lazy-head-gen/templates/admin_app/app/controllers/base.rb +0 -6
  13. data/lib/lazy-head-gen/templates/admin_app/app/controllers/sessions.rb.tt +0 -26
  14. data/lib/lazy-head-gen/templates/admin_app/app/helpers/application_helper.rb +0 -23
  15. data/lib/lazy-head-gen/templates/admin_app/assets/css/bootstrap-responsive.css +0 -815
  16. data/lib/lazy-head-gen/templates/admin_app/assets/css/bootstrap-responsive.min.css +0 -9
  17. data/lib/lazy-head-gen/templates/admin_app/assets/css/bootstrap.css +0 -4983
  18. data/lib/lazy-head-gen/templates/admin_app/assets/css/bootstrap.min.css +0 -9
  19. data/lib/lazy-head-gen/templates/admin_app/assets/ico/apple-touch-icon-114-precomposed.png +0 -0
  20. data/lib/lazy-head-gen/templates/admin_app/assets/ico/apple-touch-icon-144-precomposed.png +0 -0
  21. data/lib/lazy-head-gen/templates/admin_app/assets/ico/apple-touch-icon-57-precomposed.png +0 -0
  22. data/lib/lazy-head-gen/templates/admin_app/assets/ico/apple-touch-icon-72-precomposed.png +0 -0
  23. data/lib/lazy-head-gen/templates/admin_app/assets/ico/favicon.ico +0 -0
  24. data/lib/lazy-head-gen/templates/admin_app/assets/img/glyphicons-halflings-white.png +0 -0
  25. data/lib/lazy-head-gen/templates/admin_app/assets/img/glyphicons-halflings.png +0 -0
  26. data/lib/lazy-head-gen/templates/admin_app/assets/js/bootstrap.js +0 -1825
  27. data/lib/lazy-head-gen/templates/admin_app/assets/js/bootstrap.min.js +0 -6
  28. data/lib/lazy-head-gen/templates/admin_app/assets/js/jquery-min.js +0 -4
  29. data/lib/lazy-head-gen/templates/admin_app/assets/js/jquery-ujs.js +0 -92
  30. data/lib/lazy-head-gen/templates/admin_app/assets/js/jquery.js +0 -9404
  31. data/lib/lazy-head-gen/templates/admin_app/erb/app/base/index.erb.tt +0 -16
  32. data/lib/lazy-head-gen/templates/admin_app/erb/app/layouts/application.erb.tt +0 -79
  33. data/lib/lazy-head-gen/templates/admin_app/erb/app/sessions/new.erb.tt +0 -98
  34. data/lib/lazy-head-gen/templates/admin_app/erb/page/_form.erb.tt +0 -16
  35. data/lib/lazy-head-gen/templates/admin_app/erb/page/edit.erb.tt +0 -26
  36. data/lib/lazy-head-gen/templates/admin_app/erb/page/index.erb.tt +0 -41
  37. data/lib/lazy-head-gen/templates/admin_app/erb/page/new.erb.tt +0 -23
  38. data/lib/lazy-head-gen/templates/admin_app/page/controller.rb.tt +0 -47
  39. data/test/lazy-head-gen/test_bootstrapped_admin_app_generator.rb +0 -211
  40. data/test/lazy-head-gen/test_bootstrapped_admin_page_generator.rb +0 -94
@@ -1,94 +0,0 @@
1
- require 'helper'
2
-
3
- class Person
4
- def self.columns
5
- [:id, :name, :age, :email].map { |c| OpenStruct.new(:name => c) }
6
- end
7
- end
8
-
9
- class Page
10
- def self.columns
11
- [:id, :name, :body].map { |c| OpenStruct.new(:name => c) }
12
- end
13
- end
14
-
15
- describe "BootstrappedAdminPageGenerator" do
16
-
17
- def setup
18
- @apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
19
- `mkdir -p #{@apptmp}`
20
- end
21
-
22
- def teardown
23
- `rm -rf #{@apptmp}`
24
- end
25
-
26
- describe 'the bootstrapped admin page generator' do
27
-
28
- it 'should fail outside app root' do
29
- out, err = capture_io { generate(:bootstrapped_admin_page, 'foo', "-r=#{@apptmp}/sample_project") }
30
- assert_match(/not at the root/, out)
31
- assert_no_file_exists('/tmp/admin')
32
- end
33
-
34
- it 'should fail without argument and model' do
35
- capture_io { generate(:project, 'sample_project', "-r=#{@apptmp}", '-d=activerecord') }
36
- capture_io { generate(:bootstrapped_admin_app, "-r=#{@apptmp}/sample_project") }
37
- assert_raises(Padrino::Admin::Generators::OrmError) { generate(:bootstrapped_admin_page, 'foo', "-r=#{@apptmp}/sample_project") }
38
- end
39
-
40
- it 'should correctly generate a new padrino admin application default renderer' do
41
- capture_io { generate(:project, 'sample_project', "-r=#{@apptmp}", '-d=activerecord','-e=erb', '-a mysql') }
42
- capture_io { generate(:bootstrapped_admin_app, "-r=#{@apptmp}/sample_project") }
43
- capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
44
- capture_io { generate(:bootstrapped_admin_page, 'person', "-r=#{@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.erb"
47
- assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.erb"
48
- assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.erb"
49
- assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.erb"
50
- %w(name age email).each do |field|
51
- assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
52
- assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
53
- end
54
- assert_match_in_file "role.project_module :people, '/people'", "#{@apptmp}/sample_project/admin/app.rb"
55
- assert_match_in_file "elsif Padrino.env == :development && params[:bypass]", "#{@apptmp}/sample_project/admin/controllers/sessions.rb"
56
- assert_match_in_file "check_box_tag :bypass", "#{@apptmp}/sample_project/admin/views/sessions/new.erb"
57
- end
58
-
59
- it "should store and apply session_secret" do
60
- capture_io { generate(:project, 'sample_project', "-r=#{@apptmp}", '-d=activerecord','-e=erb') }
61
- assert_match_in_file(/set :session_secret, '[0-9A-z]*'/, "#{@apptmp}/sample_project/config/apps.rb")
62
- end
63
-
64
- it 'should correctly generate a new padrino admin application with multiple models' do
65
- capture_io { generate(:project, 'sample_project', "-r=#{@apptmp}", '-d=activerecord','-e=erb', '-a mysql') }
66
- capture_io { generate(:bootstrapped_admin_app, "-r=#{@apptmp}/sample_project") }
67
- capture_io { generate(:model, 'person', "name:string", "age:integer", "email:string", "-r=#{@apptmp}/sample_project") }
68
- capture_io { generate(:model, 'page', "name:string", "body:string", "-r=#{@apptmp}/sample_project") }
69
- capture_io { generate(:bootstrapped_admin_page, 'person', 'page', "-r=#{@apptmp}/sample_project") }
70
- # For Person
71
- assert_file_exists "#{@apptmp}/sample_project/admin/controllers/people.rb"
72
- assert_file_exists "#{@apptmp}/sample_project/admin/views/people/_form.erb"
73
- assert_file_exists "#{@apptmp}/sample_project/admin/views/people/edit.erb"
74
- assert_file_exists "#{@apptmp}/sample_project/admin/views/people/index.erb"
75
- assert_file_exists "#{@apptmp}/sample_project/admin/views/people/new.erb"
76
- %w(name age email).each do |field|
77
- assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
78
- assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/people/_form.erb"
79
- end
80
- assert_match_in_file "role.project_module :people, '/people'", "#{@apptmp}/sample_project/admin/app.rb"
81
- # For Page
82
- assert_file_exists "#{@apptmp}/sample_project/admin/controllers/pages.rb"
83
- assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/_form.erb"
84
- assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/edit.erb"
85
- assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/index.erb"
86
- assert_file_exists "#{@apptmp}/sample_project/admin/views/pages/new.erb"
87
- %w(name body).each do |field|
88
- assert_match_in_file "label :#{field}", "#{@apptmp}/sample_project/admin/views/pages/_form.erb"
89
- assert_match_in_file "text_field :#{field}", "#{@apptmp}/sample_project/admin/views/pages/_form.erb"
90
- end
91
- assert_match_in_file "role.project_module :pages, '/pages'", "#{@apptmp}/sample_project/admin/app.rb"
92
- end
93
- end
94
- end