adminpanel 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
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,58 +0,0 @@
1
- # encoding: utf-8
2
- module Adminpanel
3
- class ImageUploader < CarrierWave::Uploader::Base
4
-
5
- # Include RMagick or MiniMagick support:
6
- include CarrierWave::RMagick
7
- # include CarrierWave::MiniMagick
8
- # Choose what kind of storage to use for this uploader:
9
- storage :file
10
- # storage :fog
11
-
12
- def root
13
- Rails.root.join 'public/'
14
- end
15
-
16
- # Override the directory where uploaded files will be stored.
17
- # This is a sensible default for uploaders that are meant to be mounted:
18
- def store_dir
19
- "uploads/image/#{mounted_as}/#{model.id}"
20
- end
21
-
22
- # Provide a default URL as a default if there hasn't been a file uploaded:
23
- # def default_url
24
- # # For Rails 3.1+ asset pipeline compatibility:
25
- # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
26
- #
27
- # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
28
- # end
29
-
30
- # Process files as they are uploaded:
31
- # process :resize_to_fill => [1366, 768]
32
- #
33
- # def scale(width, height)
34
- # # do something
35
- # end
36
- version :portfolio do
37
- process :resize_to_fill => [468, 312]
38
- end
39
-
40
- # Create different versions of your uploaded files:
41
- version :thumb do
42
- process :resize_to_limit => [220, 220]
43
- end
44
-
45
- # Add a white list of extensions which are allowed to be uploaded.
46
- # For images you might use something like this:
47
- def extension_white_list
48
- %w(jpg jpeg png)
49
- end
50
-
51
- # Override the filename of the uploaded files:
52
- # Avoid using model.id or version_name here, see uploader/store.rb for details.
53
- # def filename
54
- # "something.jpg" if original_filename
55
- # end
56
-
57
- end
58
- end
@@ -1,110 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Gallery pages' do
4
- let(:gallery) { FactoryGirl.build(:gallery) }
5
- let(:user) { FactoryGirl.build(:user) }
6
-
7
- subject { page }
8
-
9
- before do
10
- gallery.save
11
- visit adminpanel.signin_path
12
- valid_signin_as_admin(user)
13
- clean_uploads_folder
14
- end
15
-
16
- describe 'galleries' do
17
- before do
18
- visit adminpanel.galleries_path
19
- end
20
-
21
- it { should have_link(I18n.t('gallery.new'), adminpanel.new_gallery_path)}
22
- it { should have_link('i', adminpanel.gallery_path(gallery)) }
23
- it { should have_link('i', adminpanel.edit_gallery_path(gallery)) }
24
- it { should have_link('i', adminpanel.move_to_better_gallery_path(gallery)) }
25
- it { should have_link('i', adminpanel.move_to_worst_gallery_path(gallery)) }
26
- end
27
-
28
- context 'when creating' do
29
- let(:gallery_1) { FactoryGirl.build(:gallery) }
30
- let(:gallery_2) { FactoryGirl.build(:gallery) }
31
- let(:gallery_3) { FactoryGirl.build(:gallery) }
32
-
33
- before do
34
- Adminpanel::Gallery.delete_all
35
- gallery_1.save
36
- end
37
-
38
- describe 'a single image' do
39
- it { gallery_1.position.should eq 1 }
40
- end
41
-
42
- describe '3 images' do
43
-
44
- before do
45
- gallery_2.save
46
- gallery_3.save
47
- end
48
- it { gallery_2.position.should eq 2 }
49
- it { gallery_3.position.should eq 3 }
50
- describe "when moving down the image in position 1" do
51
- before do
52
- gallery_1.move_to_worst_position
53
- gallery_2.reload
54
- gallery_3.reload
55
- end
56
-
57
- it { gallery_1.move_to_worst_position.should eq true}
58
- it { gallery_3.move_to_worst_position.should eq false}
59
- it { gallery_1.position.should eq 2}
60
- it { gallery_2.position.should eq 1}
61
- it { gallery_3.position.should eq 3}
62
-
63
- after do
64
- gallery_1.position = 1
65
- gallery_2.position = 2
66
- gallery_3.position = 3
67
- end
68
- end
69
-
70
- describe "when moving up the image in position 2" do
71
- before do
72
- gallery_2.move_to_better_position
73
- gallery_1.reload
74
- gallery_3.reload
75
- end
76
-
77
- it { gallery_1.move_to_better_position.should eq true}
78
- it { gallery_2.move_to_better_position.should eq false}
79
- it { gallery_1.position.should eq 2}
80
- it { gallery_2.position.should eq 1}
81
- it { gallery_3.position.should eq 3}
82
-
83
- after do
84
- gallery_1.position = 1
85
- gallery_2.position = 2
86
- gallery_3.position = 3
87
- end
88
- end
89
-
90
- describe "when deleting the image in position 1" do
91
- before do
92
- gallery_1.destroy
93
- gallery_2.reload
94
- gallery_3.reload
95
- end
96
-
97
- it { gallery_2.position.should eq 1}
98
- it { gallery_3.position.should eq 2}
99
- end
100
- end
101
- end
102
-
103
- describe "show" do
104
- before do
105
- visit adminpanel.gallery_path(gallery)
106
- end
107
-
108
- it { page.should have_selector("img[src='#{gallery.file_url(:thumb)}']") }
109
- end
110
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
-
4
- describe 'Section pages' do
5
- subject { page }
6
-
7
- let(:user) { get_user }
8
- before do
9
- Adminpanel::Section.delete_all
10
- visit adminpanel.signin_path
11
- valid_signin_as_admin(user)
12
- end
13
-
14
- describe 'index' do
15
- let!(:section) { FactoryGirl.create(:section_with_gallery) }
16
- before do
17
- visit adminpanel.sections_path
18
- end
19
-
20
- it { should have_link('i', adminpanel.section_path(section)) }
21
- it { should have_link('i', adminpanel.edit_section_path(section)) }
22
- end
23
-
24
- describe 'show' do
25
- describe 'with gallery' do
26
- let(:section) { FactoryGirl.create(:section_with_gallery) }
27
-
28
- before do
29
- visit adminpanel.section_path(section)
30
- end
31
-
32
- it { should have_content(section.description) }
33
- it { should have_link('i', adminpanel.edit_section_path(section)) }
34
- end
35
- end
36
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Shared edit', js: true do
4
- subject { page }
5
-
6
- let(:user) { get_user }
7
-
8
- before do
9
- Adminpanel::User.delete_all
10
- visit adminpanel.signin_path
11
- valid_signin_as_admin(user)
12
- end
13
-
14
- after do
15
- Adminpanel::User.delete_all
16
- end
17
-
18
- context 'edit' do
19
- let!(:product) { FactoryGirl.create(:product) }
20
- let!(:category){ FactoryGirl.create(:category) }
21
-
22
- before do
23
- product.category_ids = [category.id]
24
- visit adminpanel.edit_product_path(product)
25
- end
26
-
27
- it { should have_link('Agregar Categoria') }
28
-
29
- it { should have_content('Test Category') }
30
-
31
- it { should have_title(I18n.t('action.update') + " " + Adminpanel::Product.display_name) }
32
-
33
- describe "with invalid information" do
34
- before do
35
- fill_in "product_name", with: ""
36
- fill_in "product_price", with: ""
37
- click_button('Guardar Product')
38
- end
39
-
40
- it 'should have an error alert' do
41
- should have_content('Producto no pudo guardarse debido a')
42
- end
43
-
44
- it { should have_title(I18n.t('action.update') + " " + Adminpanel::Product.display_name) }
45
- end
46
-
47
- end
48
- end
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Shared index' do
4
- subject { page }
5
-
6
- let(:user) { get_user }
7
-
8
- before do
9
- Adminpanel::User.delete_all
10
- visit adminpanel.signin_path
11
- valid_signin_as_admin(user)
12
- end
13
-
14
- after do
15
- Adminpanel::User.delete_all
16
- end
17
-
18
- context 'mugs#index excluding every rest action with configurtions but index' do
19
- before do
20
- Adminpanel::Mug.create
21
- visit adminpanel.mugs_path
22
- end
23
-
24
- after do
25
- Adminpanel::Mug.delete_all
26
- end
27
-
28
- it 'should not have create mug button' do
29
- should_not have_link('a', href:'/adminpanel/tazas/new')
30
- end
31
- it 'should not have show or destroy button' do
32
- should_not have_link('a', href:'/adminpanel/tazas/1')
33
- end
34
- it 'should not have edit button' do
35
- should_not have_link('a', href:'/adminpanel/tazas/1/edit')
36
- end
37
- end
38
-
39
-
40
- context 'index' do
41
- let!(:product) { FactoryGirl.create(:product) }
42
- before do
43
- visit adminpanel.products_path
44
- end
45
-
46
- it { should have_link(Adminpanel::Product.display_name, adminpanel.new_product_path)}
47
- it { should have_link('i', adminpanel.product_path(product)) }
48
- it { should have_link('i', adminpanel.edit_product_path(product)) }
49
- end
50
- end
@@ -1,128 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Shared new', js: true do
4
- subject { page }
5
-
6
- let(:user) { get_user }
7
-
8
- before do
9
- Adminpanel::User.delete_all
10
- visit adminpanel.signin_path
11
- valid_signin_as_admin(user)
12
- visit adminpanel.new_product_path
13
- end
14
-
15
- after do
16
- Adminpanel::User.delete_all
17
- end
18
-
19
-
20
- describe 'when submtting with invalid information' do
21
- before do
22
- click_button('Agregar Producto')
23
- end
24
-
25
- it { should have_title("#{I18n.t('action.create')} #{Adminpanel::Product.display_name}") }
26
-
27
- it 'should have validation alert' do
28
- should have_content('Producto no pudo guardarse debido a')
29
- end
30
- end
31
-
32
- describe 'when submitting with valid information' do
33
- before do
34
- fill_in 'product_name', :with => 'product name'
35
- fill_in 'product_price', :with => '855.5'
36
- page.execute_script(
37
- %Q(
38
- $('#product_description').data('wysihtml5').editor.setValue('que pepsi');
39
- )
40
- ) # to fill the wysiwyg editor
41
-
42
- click_button('Agregar Producto')
43
- end
44
-
45
- it { should have_content(I18n.t("action.save_success"))}
46
- it { should have_title('Ver Producto')}
47
- end
48
-
49
- describe 'when clicking create remote category link (has_many through)' do
50
- before do
51
- click_link('Agregar Categoria')
52
- end
53
-
54
- it 'the modal should have the correct title' do
55
- sleep 1
56
- find('#modal-title').text.should eq('Agregar Categoria')
57
- end
58
-
59
- it 'should show the cateogry form in a modal' do
60
- should have_content('Agregar Categoria')
61
- end
62
-
63
- context 'when submitting the remote (checkboxes) category form' do
64
- describe 'with valid information' do
65
- before do
66
- fill_in 'category_name', with: 'remote category'
67
- click_button 'Agregar Categoria'
68
- end
69
-
70
- it 'should have the created category in the checkboxes options' do
71
- should have_content 'remote category'
72
- end
73
- end
74
-
75
- describe 'with invalid information' do
76
- before do
77
- click_button 'Agregar Categoria'
78
- end
79
-
80
- it 'should have the errors' do
81
- should have_content I18n.t('errors', model: 'Categoria', count: 1)
82
- end
83
- end
84
- end
85
- end
86
-
87
- context 'new salesman' do
88
- before do
89
- visit adminpanel.new_salesman_path
90
- end
91
-
92
- describe 'when clicking the create remote product link (belongs_to)' do
93
- before do
94
- click_link 'Agregar Producto'
95
- sleep 1
96
- end
97
-
98
- it 'the modal should have the correct title' do
99
- find('#modal-title').text.should eq('Agregar Producto')
100
- end
101
-
102
- context 'submitting the remote (select) product form' do
103
- describe 'with valid information' do
104
- before do
105
- fill_in 'product_name', with: 'remote product'
106
- fill_in 'product_description', with: 'remote description lorem'
107
- fill_in 'product_price', with: '12.3'
108
- click_button 'Agregar Producto'
109
- end
110
-
111
- it 'should have the created product in the select options' do
112
- should have_xpath "//option[contains(text(), 'remote product' )]"
113
- end
114
- end
115
-
116
- describe 'with invalid information' do
117
- before do
118
- click_button 'Agregar Producto'
119
- end
120
-
121
- it 'should have the errors' do
122
- should have_content I18n.t('errors', model: 'Producto', count: 3)
123
- end
124
- end
125
- end
126
- end
127
- end
128
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Shared show', js: true do
4
- subject { page }
5
-
6
- let(:user) { get_user }
7
- let!(:category){ FactoryGirl.create(:category) }
8
- let!(:product) { FactoryGirl.create(:product) }
9
- let!(:photo) { FactoryGirl.create(:photo) }
10
-
11
- before do
12
- Adminpanel::User.delete_all
13
- visit adminpanel.signin_path
14
- valid_signin_as_admin(user)
15
- product.category_ids = [category.id]
16
- photo.product_id = product.id
17
- visit adminpanel.product_path(product)
18
- end
19
-
20
- after do
21
- Adminpanel::User.delete_all
22
- end
23
-
24
- it { page.should have_selector('div', text: product.name) }
25
- it { page.should have_selector('div', text: product.price) }
26
- it { page.should have_selector('div', text: product.description) }
27
- it { should have_content("#{I18n.t("gallery.container")}: #{Adminpanel::Product.display_name}")}
28
- it { should have_content("#{category.name}")}
29
- it { should have_link('i', adminpanel.edit_product_path(product)) }
30
- end