adminpanel 2.1.1 → 2.1.2

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -7
  3. data/Rakefile +8 -7
  4. data/adminpanel.gemspec +6 -6
  5. data/app/controllers/adminpanel/application_controller.rb +1 -0
  6. data/app/controllers/concerns/adminpanel/facebook_actions.rb +1 -1
  7. data/app/controllers/concerns/adminpanel/sitemap_actions.rb +13 -0
  8. data/app/models/concerns/adminpanel/base.rb +1 -2
  9. data/app/models/concerns/adminpanel/facebook.rb +1 -1
  10. data/app/models/concerns/adminpanel/sitemap.rb +34 -0
  11. data/lib/adminpanel/version.rb +1 -1
  12. data/lib/generators/adminpanel/gallery/gallery_generator.rb +26 -28
  13. data/lib/generators/adminpanel/initialize/initialize_generator.rb +50 -52
  14. data/lib/generators/adminpanel/resource/resource_generator.rb +190 -193
  15. data/lib/tasks/adminpanel/adminpanel.rake +4 -4
  16. data/test/dummy/app/controllers/adminpanel/departments_controller.rb +13 -0
  17. data/test/dummy/app/models/adminpanel/department.rb +47 -0
  18. data/test/dummy/app/models/adminpanel/item.rb +38 -0
  19. data/test/dummy/app/models/adminpanel/mug.rb +1 -1
  20. data/test/dummy/app/models/adminpanel/salesman.rb +1 -0
  21. data/test/dummy/config/initializers/adminpanel_setup.rb +1 -0
  22. data/test/dummy/db/schema.rb +12 -0
  23. data/test/dummy/test/fixtures/adminpanel/mugs.yml +12 -0
  24. data/test/dummy/test/fixtures/adminpanel/products.yml +6 -0
  25. data/test/dummy/test/fixtures/adminpanel/salesmen.yml +12 -0
  26. data/test/features/shared/action_exclution_test.rb +20 -0
  27. data/test/features/shared/belongs_to_category_modal_test.rb +35 -0
  28. data/test/features/shared/belongs_to_non_category_modal_test.rb +41 -0
  29. data/test/features/shared/edit_test.rb +32 -0
  30. data/test/features/shared/has_many_through_category_modal_test.rb +35 -0
  31. data/test/features/shared/has_many_through_non_category_modal_test.rb +37 -0
  32. data/test/features/shared/index_test.rb +20 -0
  33. data/test/features/shared/new_test.rb +3 -3
  34. data/test/features/shared/show_test.rb +20 -0
  35. data/test/generators/gallery_generator_test.rb +39 -0
  36. data/test/generators/initialize_generator_test.rb +45 -0
  37. data/test/generators/resource_generator_test.rb +138 -0
  38. data/test/tasks/adminpanel_rake_test.rb +32 -0
  39. data/test/test_helper.rb +16 -23
  40. metadata +81 -70
  41. data/app/uploaders/adminpanel/image_uploader.rb +0 -58
  42. data/spec/features/galleries_pages_spec.rb +0 -110
  43. data/spec/features/section_pages_spec.rb +0 -36
  44. data/spec/features/shared_pages/edit_spec.rb +0 -48
  45. data/spec/features/shared_pages/index_spec.rb +0 -50
  46. data/spec/features/shared_pages/new_spec.rb +0 -128
  47. data/spec/features/shared_pages/show_spec.rb +0 -30
  48. data/spec/generators/gallery_generator_spec.rb +0 -48
  49. data/spec/generators/initialize_generator_spec.rb +0 -68
  50. data/spec/generators/resource_generator_spec.rb +0 -169
  51. data/spec/spec_helper.rb +0 -42
  52. data/spec/support/capybara_matchers.rb +0 -17
  53. data/spec/support/factories.rb +0 -52
  54. data/spec/support/helper_methods.rb +0 -30
  55. data/spec/support/shared_connection.rb +0 -10
  56. data/spec/tasks/adminpanel_rake_spec.rb +0 -59
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
- require 'generators/adminpanel/gallery/gallery_generator'
3
-
4
- describe Adminpanel::Generators::GalleryGenerator do
5
- destination File.expand_path("../../dummy/tmp", __FILE__)
6
-
7
- before do
8
- Rails::Generators.options[:rails][:orm] = :active_record
9
- end
10
-
11
- after do
12
- prepare_destination
13
- end
14
-
15
- describe 'with "product" as argument' do
16
- before do
17
- prepare_destination
18
- run_generator %w(Product)
19
- end
20
-
21
- it 'should generate the productfile migration' do
22
- migration_file('db/migrate/create_adminpanel_productfiles_table.rb').should
23
- be_a_migration
24
- end
25
-
26
-
27
- it 'should migrate the correct fields' do
28
- migration_file('db/migrate/create_adminpanel_productfiles.rb').should(
29
- contain(/t.integer :product_id/) &&
30
- contain(/create_table :adminpanel_productfiles/)
31
- )
32
- end
33
-
34
- it 'should generate the productfile model with uploader' do
35
- file('app/models/adminpanel/productfile.rb').should(
36
- contain(/mount_uploader :file, ProductfileUploader/)
37
- )
38
- end
39
-
40
- it 'should generate the productfile model with uploader' do
41
- file('app/models/adminpanel/productfile.rb').should exist
42
- end
43
-
44
- it 'should the produfile uploader' do
45
- file('app/uploaders/adminpanel/productfile_uploader.rb').should exist
46
- end
47
- end
48
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
- require 'generators/adminpanel/initialize/initialize_generator'
3
-
4
- describe Adminpanel::Generators::InitializeGenerator do
5
- destination File.expand_path("../../dummy/tmp", __FILE__)
6
-
7
- before do
8
- Rails::Generators.options[:rails][:orm] = :active_record
9
- end
10
-
11
- after do
12
- prepare_destination
13
- end
14
-
15
- describe 'with no arguments' do
16
- before do
17
- prepare_destination
18
- run_generator
19
- end
20
-
21
- it 'should generate the initial migration' do
22
- migration_file('db/migrate/create_adminpanel_tables.rb').should be_a_migration
23
- end
24
-
25
- it 'should generate the adminpanel_setup file' do
26
- file('config/initializers/adminpanel_setup.rb').should exist
27
- end
28
-
29
- it 'should generate the categories migration' do
30
- migration_file('db/migrate/create_adminpanel_categories_table.rb').should be_a_migration
31
- end
32
-
33
- it 'should generate the category file' do
34
- file('app/models/adminpanel/category.rb').should exist
35
- end
36
-
37
- it 'should generate the section uploader' do
38
- file('app/uploaders/adminpanel/section_uploader.rb').should exist
39
- end
40
- end
41
-
42
- describe 'with arguments -c true -u true -m true -p true' do
43
- before do
44
- prepare_destination
45
- run_generator %w(-c true -u true -m true -p true)
46
- end
47
-
48
- it 'should\'t generate the adminpanel_setup' do
49
- file('config/initializers/adminpanel_setup.rb').should_not exist
50
- end
51
-
52
- it 'should\'t generate the initial migration' do
53
- migration_file('db/migrate/create_adminpanel_categories_table.rb').should_not exist
54
- end
55
-
56
- it 'should\'t genearte the section uploader' do
57
- file('app/uploaders/adminpanel/section_uploader.rb').should_not exist
58
- end
59
-
60
- it 'should\'t generate the categories migration' do
61
- migration_file('db/migrate/create_adminpanel_categories_table.rb').should_not exist
62
- end
63
-
64
- it 'should\'t generate the category file' do
65
- file('app/models/adminpanel/category.rb').should_not exist
66
- end
67
- end
68
- end
@@ -1,169 +0,0 @@
1
- require 'spec_helper'
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 args and option -g false' do
17
-
18
- before do
19
- # File.new "#{Rails.root}/tmp/config/initializers/adminpanel_setup.rb", 'w+' do |f|
20
- # create config/initializers/adminpanel_setup.rb file under generator
21
- # f.puts 'hi'
22
- # end
23
- run_generator %w(
24
- post
25
- name
26
- description:wysiwyg
27
- number:float
28
- -g=false
29
- )
30
- end
31
-
32
- it "shouldn't generate the gallery " do
33
- file('app/models/adminpanel/postfile.rb').should_not exist
34
- end
35
-
36
- # it "should add ':posts,' to file adminpanel_setup.rb" do
37
- # file('config/initializers/adminpanel_setup.rb').should(
38
- # contain(/:posts,/)
39
- # )
40
- # end
41
- end
42
-
43
- describe 'with arguments %w(post name description:wysiwyg number:float
44
- quantity:integer date:datepicker)' do
45
-
46
- before do
47
- run_generator %w(
48
- post
49
- name
50
- description:wysiwyg
51
- number:float
52
- flag:boolean
53
- quantity:integer
54
- date:datepicker
55
- )
56
- end
57
-
58
- it 'should generate the posts migration' do
59
- migration_file('db/migrate/create_adminpanel_posts.rb').should be_a_migration
60
- end
61
-
62
- context 'the migration' do
63
- it 'should have the correct fields' do
64
- migration_file('db/migrate/create_adminpanel_posts.rb').should(
65
- contain(/t.string :name/) &&
66
- contain(/t.float :number/) &&
67
- contain(/t.boolean :flag/) &&
68
- contain(/t.integer :quantity/) &&
69
- contain(/t.string :date/) &&
70
- contain(/t.text :description/)
71
- )
72
- end
73
- end
74
-
75
- context 'the controller' do
76
- it 'should generate posts controller' do
77
- file('app/controllers/adminpanel/posts_controller.rb').should exist
78
- end
79
-
80
- it 'should have the params whitelisted' do
81
- file('app/controllers/adminpanel/posts_controller.rb').should(
82
- contain(/params.require(:post).permit/) &&
83
- contain(/:name/) &&
84
- contain(/:description/) &&
85
- contain(/:number/) &&
86
- contain(/:flag/) &&
87
- contain(/:quantity/) &&
88
- contain(/:date/) &&
89
- contain(/{ postfiles_attributes: \[:id, :file, :_destroy\] }/)
90
- )
91
- end
92
- end
93
-
94
-
95
- it 'should generate post model' do
96
- file('app/models/adminpanel/post.rb').should exist
97
- end
98
-
99
- context 'the model' do
100
- it 'should generate the model with correct values' do
101
- file('app/models/adminpanel/post.rb').should(
102
- contain(/include Adminpanel::Base/) &&
103
- contain(/mount_images :postfiles/) &&
104
- contain(/'photos' => \{/) &&
105
- contain(/'type' => 'adminpanel_file_field'/)
106
- )
107
- end
108
-
109
- it 'should have the description hash' do
110
- file('app/models/adminpanel/post.rb').should(
111
- contain(/'description' => \{/) &&
112
- contain(/'type' => 'wysiwyg_field',/) &&
113
- contain(/'name' => \{/) &&
114
- contain(/'type' => 'text_field',/) &&
115
- contain(/'number' => \{/) &&
116
- contain(/'type' => 'text_field',/) &&
117
- contain(/'flag' => \{/) &&
118
- contain(/'type' => 'boolean',/) &&
119
- contain(/'quantity' => \{/) &&
120
- contain(/'type' => 'number_field',/) &&
121
- contain(/'date' => \{/) &&
122
- contain(/'type' => 'datepicker_field',/) &&
123
- contain(/'postfiles' => \{/) &&
124
- contain(/'type' => 'adminpanel_file_field',/)
125
- )
126
- end
127
- end
128
- end
129
-
130
- describe 'with arguments categorizations
131
- category:belongs_to product:belongs_to' do
132
-
133
- before do
134
- run_generator %w(
135
- categorization
136
- category:belongs_to
137
- product:belongs_to
138
- )
139
- end
140
-
141
- it "shouldn't generate categorizations controller" do
142
- file('app/controllers/adminpanel/categorizations_controller').should_not exist
143
- end
144
-
145
- it 'should generate categorization model' do
146
- file('app/models/adminpanel/categorization.rb').should(
147
- contain(/belongs_to :product/) &&
148
- contain(/belongs_to :category/)
149
- )
150
- end
151
- end
152
-
153
- describe 'with arguments post name products:has_many' do
154
- before do
155
- run_generator %w(
156
- post
157
- name
158
- products:has_many
159
- )
160
- end
161
-
162
- it 'should generate the model with has_many :categorizations' do
163
- file('app/models/adminpanel/post.rb').should(
164
- contain(/# has_many :categorizations/) &&
165
- contain(/# has_many :products, :through => :categorizations/)
166
- )
167
- end
168
- end
169
- end
data/spec/spec_helper.rb DELETED
@@ -1,42 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
-
8
- ENV['RAILS_ENV'] ||= 'test'
9
- require File.expand_path('../dummy/config/environment', __FILE__)
10
- require 'rspec/rails'
11
- require 'capybara/rspec'
12
- require 'factory_girl_rails'
13
- require 'carrierwave/orm/activerecord'
14
- require 'carrierwave/test/matchers'
15
- require 'active_record'
16
- require 'rake'
17
-
18
- Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
19
-
20
- Capybara.javascript_driver = :webkit
21
-
22
- RSpec.configure do |config|
23
- config.treat_symbols_as_metadata_keys_with_true_values = true
24
- config.run_all_when_everything_filtered = true
25
- config.filter_run :focus
26
-
27
- ActiveRecord::Base.establish_connection(
28
- :adapter => 'sqlite3',
29
- :database => ':memory:'
30
- )
31
-
32
- puts "creating sqlite in memory database"
33
- load "#{Rails.root}/db/schema.rb"
34
-
35
- ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
36
-
37
- config.use_transactional_fixtures = false
38
-
39
- config.include Rails.application.routes.url_helpers
40
-
41
- config.order = 'random'
42
- end
@@ -1,17 +0,0 @@
1
- RSpec::Matchers::define :have_title do |text|
2
- match do |page|
3
- Capybara.string(page.body).has_selector?('title', :text => text)
4
- end
5
- end
6
-
7
- RSpec::Matchers.define(:have_image) do |src|
8
- match { |node| node.has_selector? %(img[src="#{src}"]) }
9
-
10
- failure_message_for_should do
11
- "Expected an image with src #{src.inspect}"
12
- end
13
-
14
- failure_message_for_should_not do
15
- "Found image with src #{src.inspect}!"
16
- end
17
- end
@@ -1,52 +0,0 @@
1
- include ActionDispatch::TestProcess
2
- FactoryGirl.define do
3
-
4
- factory :user, :class => Adminpanel::User do
5
- name 'test user'
6
- email 'email@test.com'
7
- password '123456'
8
- password_confirmation '123456'
9
- group_id 1
10
- end
11
-
12
- factory :group, :class => Adminpanel::Group do
13
- name 'Admin'
14
- end
15
-
16
- factory :product, :class => Adminpanel::Product do
17
- price "12392.2"
18
- name 'product name'
19
- description "this is a little longer description, can be very long"
20
- end
21
-
22
- factory :gallery, :class => Adminpanel::Gallery do
23
- file { fixture_file_upload(Rails.root.join('app', 'assets', 'images', 'hipster.jpg'), 'image/jpeg') }
24
- end
25
-
26
- factory :section_with_gallery, :class => Adminpanel::Section do
27
- key 'key'
28
- # description "<p>description</p>"
29
- has_image true
30
- has_description false
31
- name 'section_name'
32
- page 'index'
33
- end
34
-
35
- factory :image_section, :class => Adminpanel::Image do |image|
36
- file { fixture_file_upload(Rails.root.join('app', 'assets', 'images', 'hipster.jpg'), 'image/jpeg') }
37
- end
38
-
39
- factory :category, :class => Adminpanel::Category do
40
- name 'Test Category'
41
- model 'Product'
42
- end
43
-
44
- factory :photo, :class => Adminpanel::Photo do
45
- file { fixture_file_upload(Rails.root.join('app', 'assets', 'images', 'hipster.jpg'), 'image/jpeg') }
46
- end
47
-
48
- factory :mug, :class => Adminpanel::Mug do
49
- name 'super mug'
50
- number 2
51
- end
52
- end
@@ -1,30 +0,0 @@
1
- def valid_signin_as_admin(user)
2
- user.update_attribute(:group_id, get_admin_group.id)
3
- fill_in 'inputEmail', :with => user.email
4
- fill_in 'inputPassword', :with => user.password
5
- click_button 'signin-button'
6
- end
7
-
8
- def get_admin_group
9
- group = Adminpanel::Group.find_by_name('Admin')
10
- if group.nil?
11
- FactoryGirl.create(:group)
12
- group = Adminpanel::Group.find_by_name('Admin')
13
- end
14
- group
15
- end
16
-
17
- def get_user
18
- if Adminpanel::User.count == 0
19
- FactoryGirl.create(:user)
20
- elsif Adminpanel::User.count == 1
21
- Adminpanel::User.first
22
- else
23
- Adminpanel::User.delete_all
24
- get_user
25
- end
26
- end
27
-
28
- def clean_uploads_folder
29
- FileUtils.rm_rf(Dir["#{Rails.root}/public/uploads/."])
30
- end
@@ -1,10 +0,0 @@
1
- class ActiveRecord::Base
2
- mattr_accessor :shared_connection
3
- @@shared_connection = nil
4
-
5
- def self.connection
6
- @@shared_connection || retrieve_connection
7
- end
8
- end
9
- # Forces all threads to share the same connection. This works on
10
- # Capybara because it starts the web server in a thread.