adminpanel 1.2.8 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. data/Gemfile +1 -1
  2. data/adminpanel.gemspec +2 -2
  3. data/app/controllers/adminpanel/{pages_controller.rb → analytics_controller.rb} +11 -6
  4. data/app/controllers/adminpanel/application_controller.rb +5 -6
  5. data/app/controllers/adminpanel/galleries_controller.rb +23 -23
  6. data/app/controllers/adminpanel/sections_controller.rb +5 -1
  7. data/app/controllers/adminpanel/sessions_controller.rb +7 -3
  8. data/app/helpers/adminpanel/application_helper.rb +7 -3
  9. data/app/helpers/adminpanel/rest_actions_helper.rb +20 -0
  10. data/app/helpers/adminpanel/router_helper.rb +2 -32
  11. data/app/helpers/adminpanel/shared_pages_helper.rb +8 -8
  12. data/app/models/adminpanel/analytic.rb +12 -0
  13. data/app/models/adminpanel/gallery.rb +48 -43
  14. data/app/models/adminpanel/section.rb +6 -2
  15. data/app/models/adminpanel/user.rb +4 -0
  16. data/app/views/adminpanel/{pages → analytics}/index.html.erb +0 -0
  17. data/app/views/adminpanel/sessions/new.html.erb +1 -1
  18. data/app/views/layouts/_side_menu.html.erb +7 -89
  19. data/app/views/shared/_gallery_entries.html.erb +11 -0
  20. data/app/views/shared/gallery_entries.js.erb +1 -0
  21. data/app/views/shared/show.html.erb +21 -9
  22. data/config/routes.rb +28 -22
  23. data/lib/adminpanel/active_record/adminpanel_extension.rb +63 -4
  24. data/lib/adminpanel/engine.rb +7 -2
  25. data/lib/adminpanel/version.rb +1 -1
  26. data/lib/generators/adminpanel/gallery/gallery_generator.rb +1 -1
  27. data/lib/generators/adminpanel/gallery/templates/gallery_template.rb +6 -0
  28. data/lib/generators/adminpanel/gallery/templates/uploader.rb +2 -2
  29. data/lib/generators/adminpanel/initialize/initialize_generator.rb +23 -7
  30. data/lib/generators/adminpanel/initialize/templates/adminpanel_setup.rb +8 -3
  31. data/lib/generators/adminpanel/initialize/templates/category_template.rb +22 -9
  32. data/lib/generators/adminpanel/resource/resource_generator.rb +8 -4
  33. data/lib/tasks/adminpanel/adminpanel.rake +9 -23
  34. data/spec/dummy/.gitignore +1 -0
  35. data/spec/dummy/app/models/adminpanel/category.rb +3 -3
  36. data/spec/dummy/app/models/adminpanel/product.rb +3 -3
  37. data/spec/dummy/config/initializers/adminpanel_setup.rb +22 -0
  38. data/spec/features/galleries_pages_spec.rb +3 -28
  39. data/spec/generators/gallery_generator_spec.rb +40 -44
  40. data/spec/generators/initialize_generator_spec.rb +46 -19
  41. data/spec/generators/resource_generator_spec.rb +101 -129
  42. data/spec/spec_helper.rb +1 -2
  43. data/spec/tasks/adminpanel_rake_spec.rb +4 -4
  44. metadata +21 -14
@@ -1,151 +1,123 @@
1
1
  require 'spec_helper'
2
-
3
- describe 'adminpanel:resource' do
4
-
5
- with_args :category do
6
- it 'should generate categories migration' do
7
- subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_categories_table.rb")
8
- end
9
- it 'should generate categories controller' do
10
- subject.should generate('app/controllers/adminpanel/categories_controller.rb')
2
+ require 'generators/adminpanel/resource/resource_generator'
3
+
4
+ describe Adminpanel::Generators::ResourceGenerator do
5
+ destination File.expand_path("../../dummy/tmp", __FILE__)
6
+
7
+ before do
8
+ prepare_destination
9
+ Rails::Generators.options[:rails][:orm] = :active_record
10
+ end
11
+
12
+ # after do
13
+ # prepare_destination
14
+ # end
15
+
16
+ describe 'with arguments %w(post name description:wysiwyg number:float
17
+ quantity:integer date:datepicker photo:images)' do
18
+
19
+ before do
20
+ run_generator %w(
21
+ post
22
+ name
23
+ description:wysiwyg
24
+ number:float
25
+ quantity:integer
26
+ date:datepicker
27
+ photo:images
28
+ )
11
29
  end
12
- it 'should generate category model' do
13
- subject.should generate('app/models/adminpanel/category.rb')
30
+
31
+ it 'should generate the posts migration' do
32
+ migration_file('db/migrate/create_posts_table.rb').should be_a_migration
14
33
  end
15
34
 
16
- context "with has_many and belongs_to" do
17
- with_args :"products,categorizations:has_many_through", :"product:belongs_to" do
18
- it "should generate categories migration" do
19
- subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_categories_table.rb") { |content|
20
- content.should =~ /t.integer :product_id/ &&
21
- (
22
- content.should_not =~ /t.integer :products_id/ ||
23
- content.should_not =~ /t.integer :categorizations_id/
24
- )
25
- }
26
- end
27
-
28
- it "should generate model with has_many categorizations" do
29
- subject.should generate("app/models/adminpanel/category.rb") { |content|
30
- content.should =~ /has_many :categorizations/
31
- }
32
- end
33
-
34
- it "should generate model with has_many products through categorizations" do
35
- subject.should generate("app/models/adminpanel/category.rb") { |content|
36
- content.should =~ /has_many :products, :through => :categorizations/
37
- }
38
- end
39
-
40
- it "should generate categories model" do
41
- subject.should generate("app/models/adminpanel/category.rb") { |content|
42
- content.should =~ /belongs_to :product/
43
- }
44
- end
35
+ context 'the migration' do
36
+ it 'should have the correct fields' do
37
+ migration_file('db/migrate/create_posts_table.rb').should(
38
+ contain(/t.string :name/) &&
39
+ contain(/t.float :number/) &&
40
+ contain(/t.integer :quantity/) &&
41
+ contain(/t.string :date/) &&
42
+ contain(/t.text :description/)
43
+ )
45
44
  end
46
45
  end
47
- end
48
46
 
49
- with_args :categorization do
50
- context "with only :belongs_to as types" do
51
- with_args :"product:belongs_to", :"category:belongs_to" do
52
- it "should generate categorizations migration" do
53
- subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_categorizations_table.rb") { |content|
54
- content.should =~ /t.integer \:product_id/ &&
55
- content.should =~ /t.integer \:category_id/
56
- }
57
- end
58
-
59
- it "shouldn't generate categorizations controller" do
60
- subject.should_not generate("app/controllers/adminpanel/categorizations_controller.rb")
61
- end
62
-
63
- it "should generate categorization model" do
64
- subject.should generate("app/models/adminpanel/categorization.rb") { |content|
65
- content.should =~ /belongs_to :product/ &&
66
- content.should =~ /belongs_to :category/
67
- }
68
- end
69
- end
47
+ it 'should generate posts controller' do
48
+ file('app/controllers/adminpanel/posts_controller.rb').should exist
70
49
  end
71
- end
72
50
 
73
- with_args "Product" do
74
- with_args :"description:wysiwyg", :"long_text:text",
75
- :"price:float", :"date:datepicker",
76
- :"name:string", :"quantity:integer" do
77
- it "should generate migration with correct values" do
78
- subject.should generate("db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_products_table.rb") { |content|
79
- content.should =~ /t.text :description/ &&
80
- content.should =~ /t.text :long_text/ &&
81
- content.should =~ /t.float :price/ &&
82
- content.should =~ /t.string :date/ &&
83
- content.should =~ /t.string :name/ &&
84
- content.should =~ /t.integer :quantity/
85
- }
86
- end
51
+
52
+ it 'should generate post model' do
53
+ file('app/models/adminpanel/post.rb').should exist
87
54
  end
88
55
 
89
- with_args :"photo:images" do
90
- it "should generate model with image relationship" do
91
- subject.should generate("app/models/adminpanel/product.rb") { |content|
92
- content.should =~ /mount_images :photos/ &&
93
- content.should =~ /'photos' => \{/ &&
94
- content.should =~ /'type' => 'adminpanel_file_field'/
95
- }
56
+ context 'the model' do
57
+ it 'should generate the model with correct values' do
58
+ file('app/models/adminpanel/post.rb').should(
59
+ contain(/mount_images :postfiles/) &&
60
+ contain(/'photos' => \{/) &&
61
+ contain(/'type' => 'adminpanel_file_field'/)
62
+ )
63
+ end
64
+
65
+ it 'should have the description hash' do
66
+ file('app/models/adminpanel/post.rb').should(
67
+ contain(/'description' => \{/) &&
68
+ contain(/'type' => 'wysiwyg_field',/) &&
69
+ contain(/'name' => \{/) &&
70
+ contain(/'type' => 'text_field',/) &&
71
+ contain(/'number' => \{/) &&
72
+ contain(/'type' => 'text_field',/) &&
73
+ contain(/'quantity' => \{/) &&
74
+ contain(/'type' => 'number_field',/) &&
75
+ contain(/'date' => \{/) &&
76
+ contain(/'type' => 'datepicker_field',/) &&
77
+ contain(/'postfiles' => \{/) &&
78
+ contain(/'type' => 'adminpanel_file_field',/)
79
+ )
96
80
  end
97
- #
98
- # it "should generate a photos uploader" do
99
- # subject.should generate("app/uploader/adminpanel/photos_uploader.rb")
100
- # end
101
- #
102
- # it "should generate a photo model" do
103
- # subject.should generate("app/models/adminpanel/photo.rb"){ |content|
104
- # content.should =~ /mount_uploader :file, CameraUploader/ &&
105
- # content.should =~ /:camera_id/
106
- # }
107
- # end
108
81
  end
82
+ end
109
83
 
84
+ describe 'with arguments categorizations
85
+ category:belongs_to product:belongs_to' do
110
86
 
111
- with_args :"name:string", :"description:wysiwyg" do
112
- it "should generate namespaced products_controller.rb" do
113
- subject.should generate("app/controllers/adminpanel/products_controller.rb") { |content|
114
- content.should =~ /module Adminpanel/ &&
115
- content.should =~ /class ProductsController < Adminpanel\:\:ApplicationController/ &&
116
- content.should =~ /end\nend/
117
- }
118
- end
87
+ before do
88
+ run_generator %w(
89
+ categorization
90
+ category:belongs_to
91
+ product:belongs_to
92
+ )
93
+ end
119
94
 
120
- it "should generate model with attr_accessible" do
121
- subject.should generate("app/models/adminpanel/product.rb") { |content|
122
- content.should =~ /attr_accessible/
123
- }
124
- end
95
+ it 'shouldn\'t generate categorizations controller' do
96
+ file('app/controllers/adminpanel/categorizations_controller').should_not exist
97
+ end
125
98
 
126
- it "should generate model with description hash" do
127
- subject.should generate("app/models/adminpanel/product.rb") { |content|
128
- content.should =~ /'description' => \{/ &&
129
- content.should =~ /'type' => 'wysiwyg_field',/&&
130
- content.should =~ /'label' => 'description',/ &&
131
- content.should =~ /'placeholder' => 'description'\}/
132
- }
133
- end
99
+ it 'should generate categorization model' do
100
+ file('app/models/adminpanel/categorization.rb').should(
101
+ contain(/belongs_to :product/) &&
102
+ contain(/belongs_to :category/)
103
+ )
104
+ end
105
+ end
134
106
 
135
- it "should generate model with name hash" do
136
- subject.should generate("app/models/adminpanel/product.rb") { |content|
137
- content.should =~ /'name' => \{/ &&
138
- content.should =~ /'type' => 'text_field',/ &&
139
- content.should =~ /'label' => 'name',/ &&
140
- content.should =~ /'placeholder' => 'name'\}/
141
- }
142
- end
107
+ describe 'with arguments post name products,categorizations:has_many_through' do
108
+ before do
109
+ run_generator %w(
110
+ post
111
+ name
112
+ products,categorizations:has_many_through
113
+ )
114
+ end
143
115
 
144
- it "should generate model with overwritten sample_name" do
145
- subject.should generate("app/models/adminpanel/product.rb") { |content|
146
- content.should =~ /def self.display_name\n \"Product\"\n end/
147
- }
148
- end
116
+ it 'should generate the model with has_many :categorizations' do
117
+ file('app/models/adminpanel/post.rb').should(
118
+ contain(/has_many :categorizations/) &&
119
+ contain(/has_many :products, :through => :categorizations/)
120
+ )
149
121
  end
150
122
  end
151
123
  end
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,6 @@ require "rspec/rails"
11
11
  require "factory_girl"
12
12
  require "carrierwave/test/matchers"
13
13
  require "active_record"
14
- require "genspec"
15
14
  require "rake"
16
15
 
17
16
  Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
@@ -28,6 +27,6 @@ RSpec.configure do |config|
28
27
  )
29
28
 
30
29
  config.include Rails.application.routes.url_helpers
31
-
30
+
32
31
  config.order = 'random'
33
32
  end
@@ -15,12 +15,12 @@ describe "adminpanel rake task" do
15
15
  end
16
16
 
17
17
 
18
- it "should generate 10 product records" do
19
- Adminpanel::Product.all.count.should eq 10
20
- end
18
+ # it "should generate 10 product records" do
19
+ # Adminpanel::Product.find(:all).count.should eq 10
20
+ # end
21
21
 
22
22
  it "attributes shouldn't be nil" do
23
- Adminpanel::Product.all.each do |product|
23
+ Adminpanel::Product.find(:all).each do |product|
24
24
  if (product.name.nil? || product.description.nil? || product.price.nil? ||
25
25
  product.name == "" || product.description == "" || product.price == "")
26
26
  has_nil_attribute = true
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminpanel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 8
10
- version: 1.2.8
9
+ - 9
10
+ version: 1.2.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jose Ramon Camacho
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-03-21 00:00:00 -06:00
19
+ date: 2014-03-28 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -184,12 +184,14 @@ dependencies:
184
184
  requirement: &id011 !ruby/object:Gem::Requirement
185
185
  none: false
186
186
  requirements:
187
- - - ">="
187
+ - - "="
188
188
  - !ruby/object:Gem::Version
189
- hash: 3
189
+ hash: 73
190
190
  segments:
191
- - 0
192
- version: "0"
191
+ - 10
192
+ - 1
193
+ - 1
194
+ version: 10.1.1
193
195
  type: :development
194
196
  version_requirements: *id011
195
197
  - !ruby/object:Gem::Dependency
@@ -303,19 +305,19 @@ dependencies:
303
305
  type: :development
304
306
  version_requirements: *id018
305
307
  - !ruby/object:Gem::Dependency
306
- name: genspec
308
+ name: ammeter
307
309
  prerelease: false
308
310
  requirement: &id019 !ruby/object:Gem::Requirement
309
311
  none: false
310
312
  requirements:
311
313
  - - "="
312
314
  - !ruby/object:Gem::Version
313
- hash: 7
315
+ hash: 5
314
316
  segments:
315
317
  - 0
316
318
  - 2
317
- - 8
318
- version: 0.2.8
319
+ - 9
320
+ version: 0.2.9
319
321
  type: :development
320
322
  version_requirements: *id019
321
323
  description: Gem that makes the admin panel for a site a breeze!
@@ -409,10 +411,10 @@ files:
409
411
  - app/assets/stylesheets/adminpanel/theme.css
410
412
  - app/assets/stylesheets/adminpanel/timepicker.css
411
413
  - app/assets/stylesheets/application-admin.css
414
+ - app/controllers/adminpanel/analytics_controller.rb
412
415
  - app/controllers/adminpanel/application_controller.rb
413
416
  - app/controllers/adminpanel/categories_controller.rb
414
417
  - app/controllers/adminpanel/galleries_controller.rb
415
- - app/controllers/adminpanel/pages_controller.rb
416
418
  - app/controllers/adminpanel/sections_controller.rb
417
419
  - app/controllers/adminpanel/sessions_controller.rb
418
420
  - app/controllers/adminpanel/users_controller.rb
@@ -424,6 +426,7 @@ files:
424
426
  - app/helpers/adminpanel/router_helper.rb
425
427
  - app/helpers/adminpanel/sessions_helper.rb
426
428
  - app/helpers/adminpanel/shared_pages_helper.rb
429
+ - app/models/adminpanel/analytic.rb
427
430
  - app/models/adminpanel/gallery.rb
428
431
  - app/models/adminpanel/image.rb
429
432
  - app/models/adminpanel/section.rb
@@ -432,6 +435,7 @@ files:
432
435
  - app/uploaders/adminpanel/gallery_uploader.rb
433
436
  - app/uploaders/adminpanel/image_uploader.rb
434
437
  - app/views/adminpanel/.DS_Store
438
+ - app/views/adminpanel/analytics/index.html.erb
435
439
  - app/views/adminpanel/categories/_categories_table.html.erb
436
440
  - app/views/adminpanel/categories/_category_form.html.erb
437
441
  - app/views/adminpanel/categories/create.js.erb
@@ -447,7 +451,6 @@ files:
447
451
  - app/views/adminpanel/galleries/new.html.erb
448
452
  - app/views/adminpanel/galleries/show.html.erb
449
453
  - app/views/adminpanel/galleries/update.html.erb
450
- - app/views/adminpanel/pages/index.html.erb
451
454
  - app/views/adminpanel/sections/_sections_table.html.erb
452
455
  - app/views/adminpanel/sections/edit.html.erb
453
456
  - app/views/adminpanel/sections/index.html.erb
@@ -461,9 +464,11 @@ files:
461
464
  - app/views/shared/_breadcrumb.html.erb
462
465
  - app/views/shared/_error_messages.html.erb
463
466
  - app/views/shared/_form_fields.html.erb
467
+ - app/views/shared/_gallery_entries.html.erb
464
468
  - app/views/shared/_image_fields.html.erb
465
469
  - app/views/shared/_init_editor.html.erb
466
470
  - app/views/shared/edit.html.erb
471
+ - app/views/shared/gallery_entries.js.erb
467
472
  - app/views/shared/index.html.erb
468
473
  - app/views/shared/new.html.erb
469
474
  - app/views/shared/show.html.erb
@@ -518,6 +523,7 @@ files:
518
523
  - spec/dummy/config/environments/development.rb
519
524
  - spec/dummy/config/environments/production.rb
520
525
  - spec/dummy/config/environments/test.rb
526
+ - spec/dummy/config/initializers/adminpanel_setup.rb
521
527
  - spec/dummy/config/initializers/backtrace_silencers.rb
522
528
  - spec/dummy/config/initializers/mime_types.rb
523
529
  - spec/dummy/config/initializers/secret_token.rb
@@ -621,6 +627,7 @@ test_files:
621
627
  - spec/dummy/config/environments/development.rb
622
628
  - spec/dummy/config/environments/production.rb
623
629
  - spec/dummy/config/environments/test.rb
630
+ - spec/dummy/config/initializers/adminpanel_setup.rb
624
631
  - spec/dummy/config/initializers/backtrace_silencers.rb
625
632
  - spec/dummy/config/initializers/mime_types.rb
626
633
  - spec/dummy/config/initializers/secret_token.rb