adminpanel 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -3
  3. data/Gemfile +7 -7
  4. data/Rakefile +20 -4
  5. data/adminpanel.gemspec +7 -7
  6. data/app/controllers/adminpanel/categories_controller.rb +1 -5
  7. data/app/controllers/adminpanel/galleries_controller.rb +13 -18
  8. data/app/controllers/concerns/adminpanel/facebook_actions.rb +26 -18
  9. data/app/controllers/concerns/adminpanel/rest_actions.rb +8 -3
  10. data/app/helpers/adminpanel/router_helper.rb +4 -0
  11. data/app/models/adminpanel/section.rb +4 -4
  12. data/app/views/adminpanel/sessions/new.html.erb +1 -1
  13. data/app/views/layouts/_top_bar.html.erb +24 -2
  14. data/app/views/layouts/admin-login.html.erb +1 -2
  15. data/app/views/shared/fb_choose_page.html.erb +3 -3
  16. data/app/views/shared/new.html.erb +24 -23
  17. data/config/locales/es.yml +8 -3
  18. data/config/routes.rb +8 -3
  19. data/lib/adminpanel/version.rb +1 -1
  20. data/lib/generators/adminpanel/gallery/templates/gallery_migration.rb +1 -1
  21. data/lib/generators/adminpanel/resource/resource_generator.rb +2 -2
  22. data/{spec → test}/dummy/.gitignore +0 -1
  23. data/{spec → test}/dummy/README.rdoc +0 -0
  24. data/{spec → test}/dummy/Rakefile +0 -0
  25. data/{spec → test}/dummy/app/assets/images/hipster.jpg +0 -0
  26. data/{spec → test}/dummy/app/assets/images/test.jpg +0 -0
  27. data/{spec → test}/dummy/app/assets/javascripts/application.js +0 -0
  28. data/{spec → test}/dummy/app/assets/stylesheets/application.css +0 -0
  29. data/{spec → test}/dummy/app/controllers/adminpanel/.gitkeep +0 -0
  30. data/{spec → test}/dummy/app/controllers/adminpanel/mugs_controller.rb +0 -0
  31. data/{spec → test}/dummy/app/controllers/adminpanel/products_controller.rb +0 -0
  32. data/{spec → test}/dummy/app/controllers/adminpanel/salesmen_controller.rb +0 -0
  33. data/{spec → test}/dummy/app/controllers/application_controller.rb +0 -0
  34. data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
  35. data/{spec → test}/dummy/app/mailers/.gitkeep +0 -0
  36. data/{spec → test}/dummy/app/models/.gitkeep +0 -0
  37. data/{spec → test}/dummy/app/models/ability.rb +0 -0
  38. data/{spec → test}/dummy/app/models/adminpanel/categorization.rb +0 -0
  39. data/{spec → test}/dummy/app/models/adminpanel/category.rb +0 -0
  40. data/{spec → test}/dummy/app/models/adminpanel/mug.rb +0 -0
  41. data/{spec → test}/dummy/app/models/adminpanel/photo.rb +0 -0
  42. data/{spec → test}/dummy/app/models/adminpanel/product.rb +0 -0
  43. data/{spec → test}/dummy/app/models/adminpanel/salesman.rb +0 -0
  44. data/{spec → test}/dummy/app/uploader/adminpanel/photo_uploader.rb +0 -0
  45. data/{spec → test}/dummy/app/uploader/adminpanel/section_uploader.rb +0 -0
  46. data/{spec → test}/dummy/app/views/layouts/application.html.erb +0 -0
  47. data/{spec → test}/dummy/config.ru +0 -0
  48. data/{spec → test}/dummy/config/application.rb +0 -0
  49. data/{spec → test}/dummy/config/boot.rb +0 -0
  50. data/{spec/dummy/config/carrierwve.rb → test/dummy/config/carrierwave.rb} +1 -1
  51. data/{spec → test}/dummy/config/database.yml +0 -0
  52. data/{spec → test}/dummy/config/environment.rb +0 -0
  53. data/{spec → test}/dummy/config/environments/development.rb +0 -0
  54. data/{spec → test}/dummy/config/environments/production.rb +0 -0
  55. data/{spec → test}/dummy/config/environments/test.rb +2 -2
  56. data/{spec → test}/dummy/config/initializers/adminpanel_setup.rb +0 -0
  57. data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  58. data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -0
  59. data/{spec → test}/dummy/config/initializers/session_store.rb +0 -0
  60. data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +0 -0
  61. data/{spec → test}/dummy/config/locales/.keep +0 -0
  62. data/{spec → test}/dummy/config/routes.rb +0 -0
  63. data/test/dummy/config/secrets.yml +2 -0
  64. data/{spec → test}/dummy/db/schema.rb +0 -0
  65. data/{spec → test}/dummy/lib/assets/.gitkeep +0 -0
  66. data/{spec → test}/dummy/public/404.html +0 -0
  67. data/{spec → test}/dummy/public/422.html +0 -0
  68. data/{spec → test}/dummy/public/500.html +0 -0
  69. data/{spec → test}/dummy/public/favicon.ico +0 -0
  70. data/{spec → test}/dummy/script/rails +0 -0
  71. data/test/dummy/test/fixtures/adminpanel/galleries.yml +15 -0
  72. data/test/dummy/test/fixtures/adminpanel/groups.yml +4 -0
  73. data/test/dummy/test/fixtures/adminpanel/users.yml +8 -0
  74. data/test/features/session/login_test.rb +33 -0
  75. data/test/features/shared/new_test.rb +39 -0
  76. data/test/models/adminpanel/gallery_test.rb +37 -0
  77. data/test/models/adminpanel/section_test.rb +53 -0
  78. data/test/models/adminpanel/user_test.rb +51 -0
  79. data/test/test_helper.rb +71 -0
  80. data/test/unit/gallery_unit_test.rb +21 -0
  81. metadata +212 -246
  82. data/spec/features/authentication_pages_spec.rb +0 -45
  83. data/spec/models/gallery_spec.rb +0 -24
  84. data/spec/models/section_spec.rb +0 -61
  85. data/spec/models/user_spec.rb +0 -94
@@ -34,11 +34,16 @@ Adminpanel::Engine.routes.draw do
34
34
  end
35
35
 
36
36
  # normal resource
37
+ resources resource, resources_parameters(resource).merge(rest_path_names)
38
+
39
+ # if resource is going to be shared on facebook
37
40
  resources resource, resources_parameters(resource).merge(rest_path_names) do
38
41
  member do
39
- get :fb_choose_page, as: 'fb_choose_page', path: 'publicar-a-pagina-en-fb'
40
- post :fb_save_token, as: 'fb_save_token', path: 'guardar-token'
41
- post 'fb_publish/:configuration_id', to: "#{resource}#fb_publish", as: 'fb_publish', path: 'publicar-a-facebook'
42
+ if has_fb_share?(resource)
43
+ get :fb_choose_page, as: 'fb_choose_page', path: 'publicar-a-pagina-en-fb'
44
+ post :fb_save_token, as: 'fb_save_token', path: 'guardar-token'
45
+ post 'fb_publish/:configuration_id', to: "#{resource}#fb_publish", as: 'fb_publish', path: 'publicar-a-facebook'
46
+ end
42
47
  end
43
48
  end
44
49
  end
@@ -1,3 +1,3 @@
1
1
  module Adminpanel
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -1,4 +1,4 @@
1
- class CreateAdminpanel<%= class_name.pluralize %>Table < ActiveRecord::Migration
1
+ class CreateAdminpanel<%= class_name.pluralize %> < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :adminpanel_<%= lower_name.pluralize %> do |t|
4
4
 
@@ -41,13 +41,13 @@ module Adminpanel
41
41
  end
42
42
 
43
43
  def generate_gallery
44
- if has_gallery?
44
+ if has_gallery? && is_a_resource?
45
45
  invoke 'adminpanel:gallery', [lower_singularized_name]
46
46
  end
47
47
  end
48
48
 
49
49
  def add_resource_to_config
50
- if setup_is_found?
50
+ if setup_is_found? && is_a_resource?
51
51
  inject_into_file 'config/initializers/adminpanel_setup.rb',
52
52
  after: 'config.displayable_resources = [' do
53
53
  indent "\n:#{pluralized_name},", 4
@@ -13,7 +13,6 @@ capybara-*.html
13
13
  rerun.txt
14
14
  pickle-email-*.html
15
15
  config/initializers/secret_token.rb
16
- config/secrets.yml
17
16
  /public/uploads/
18
17
 
19
18
  ## Environment normalisation:
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -3,4 +3,4 @@ if Rails.env.test? or Rails.env.cucumber?
3
3
  config.storage = :file
4
4
  config.enable_processing = false
5
5
  end
6
- end
6
+ end
File without changes
@@ -23,8 +23,8 @@ Dummy::Application.configure do
23
23
  # Raise exceptions instead of rendering exception templates.
24
24
  config.action_dispatch.show_exceptions = false
25
25
 
26
- # Disable request forgery protection in test environment.
27
- config.action_controller.allow_forgery_protection = false
26
+ # Enable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = true
28
28
 
29
29
  # Tell Action Mailer not to deliver emails to the real world.
30
30
  # The :test delivery method accumulates sent emails in the
File without changes
@@ -0,0 +1,2 @@
1
+ test:
2
+ secret_key_base: e152a9bf618bb8871e25e2f6c4472d9a1e5c93a221cafa4ee560fe6f58022c0f6f7554379519387568c456d71c519afe7e9c643c09b011c01d4b9e531a41f99d
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ one:
2
+ file: hipster.jpg
3
+ position: 1
4
+ created_at: <%= Date.today %>
5
+ updated_at: <%= Date.today %>
6
+ two:
7
+ file: hipster.jpg
8
+ position: 2
9
+ created_at: <%= Date.today %>
10
+ updated_at: <%= Date.today %>
11
+ three:
12
+ file: hipster.jpg
13
+ position: 3
14
+ created_at: <%= Date.today %>
15
+ updated_at: <%= Date.today %>
@@ -0,0 +1,4 @@
1
+ Admin:
2
+ name: Admin
3
+ created_at: <%= Date.today %>
4
+ updated_at: <%= Date.today %>
@@ -0,0 +1,8 @@
1
+ valid:
2
+ name: Example User
3
+ email: user@example.com
4
+ password_digest: <%= BCrypt::Password.create('foobar') %>
5
+ remember_token: <%= Digest::SHA1.hexdigest("adminSat Feb 25 17:14:00 GMT 20060.236961325863376") %>
6
+ group_id: <%= ActiveRecord::FixtureSet.identify(:Admin) %>
7
+ created_at: <%= Date.today %>
8
+ updated_at: <%= Date.today %>
@@ -0,0 +1,33 @@
1
+ require 'test_helper'
2
+
3
+ class LoginTest < ViewCase
4
+ fixtures :all
5
+
6
+ setup :visiting_signin
7
+
8
+ def test_login_messages
9
+ assert_content I18n.t('authentication.welcome')
10
+ end
11
+
12
+ def test_logging_in_with_valid_information
13
+ login
14
+ assert_content I18n.t('authentication.signin_success')
15
+ assert_content I18n.t('authentication.logout')
16
+ signout
17
+ assert_content I18n.t('authentication.welcome')
18
+ end
19
+
20
+ def test_logging_in_with_invalid_information
21
+ login('foobaz') #pass is foobar
22
+ assert_content I18n.t('authentication.signin_error')
23
+ end
24
+
25
+ protected
26
+ def visiting_signin
27
+ visit adminpanel.signin_path
28
+ end
29
+
30
+ def signout
31
+ click_link 'signout-button'
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ class NewTest < ViewCase
4
+
5
+ setup :visit_new_product
6
+ # teardown :teardown
7
+
8
+ def test_shared_new_page_messages
9
+ assert_button("#{I18n.t('action.add')} #{Adminpanel::Product.display_name}")
10
+ end
11
+
12
+ def test_submitting_with_invalid_information
13
+ click_button('Agregar Producto')
14
+ assert_content('Producto no pudo guardarse debido a 3 errores')
15
+ end
16
+
17
+ def test_submitting_with_valid_information
18
+ fill_in 'product_name', :with => 'product name'
19
+ fill_in 'product_price', :with => '855.5'
20
+ page.execute_script(
21
+ %Q(
22
+ $('#product_description').data('wysihtml5').editor.setValue('que pepsi');
23
+ )
24
+ ) # to fill the wysiwyg editor
25
+ click_button('Agregar Producto')
26
+ assert_content(I18n.t('action.save_success'))
27
+ saved_product = Adminpanel::Product.last
28
+ assert_equal 'product name', saved_product.name
29
+ assert_equal '855.5', saved_product.price
30
+ assert_equal 'que pepsi', saved_product.description
31
+ end
32
+
33
+ protected
34
+ def visit_new_product
35
+ visit adminpanel.signin_path
36
+ login
37
+ visit adminpanel.new_product_path
38
+ end
39
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+ module Adminpanel
3
+ class GalleryTest < ActiveSupport::TestCase
4
+
5
+ # set_fixture_class 'adminpanel/galleries' => Adminpanel::Gallery
6
+
7
+ def test_moving_up_with_the_best_position
8
+ gallery_1 = adminpanel_galleries(:one)
9
+ gallery_1.move_to_better_position
10
+ assert_equal 1, gallery_1.position
11
+ end
12
+
13
+ def test_moving_down_with_the_worst_position
14
+ gallery_3 = adminpanel_galleries(:three)
15
+ gallery_3.move_to_worst_position
16
+ assert_equal 3, gallery_3.position
17
+ end
18
+
19
+ def test_moving_up_with_intermediate_position
20
+ gallery_2 = adminpanel_galleries(:two)
21
+ gallery_2.move_to_better_position
22
+ assert_equal 1, gallery_2.position
23
+ end
24
+
25
+ def test_moving_down_with_intermediate_position
26
+ gallery_2 = adminpanel_galleries(:two)
27
+ gallery_2.move_to_worst_position
28
+ assert_equal 3, gallery_2.position
29
+ end
30
+
31
+ def test_file_presence
32
+ g = Adminpanel::Gallery.new
33
+ assert_not g.save
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,53 @@
1
+ require 'test_helper'
2
+
3
+ module Adminpanel
4
+ class SectionTest < ActiveSupport::TestCase
5
+
6
+ def test_telephone_validations
7
+ set_telephone
8
+ assert @telephone.valid?
9
+
10
+ @telephone.update_attribute(:description, '1' * 9)
11
+ assert @telephone.invalid?
12
+
13
+ @telephone.update_attribute(:description, '1' * 11)
14
+ assert @telephone.invalid?
15
+
16
+ @telephone.update_attribute(:description, '01-2-3-4-5')
17
+ assert @telephone.invalid?
18
+
19
+ @telephone.update_attribute(:description, '')
20
+ assert @telephone.valid?
21
+ end
22
+
23
+ def test_default_scope
24
+ assert_equal(
25
+ Adminpanel::Section.all.to_sql,
26
+ Adminpanel::Section.reorder('').order('page ASC').to_sql
27
+ )
28
+ end
29
+
30
+ protected
31
+ def set_telephone
32
+ @telephone = Adminpanel::Section.new(
33
+ name: 'Telefono',
34
+ key: 'phone',
35
+ has_description: false,
36
+ description: '1234567890',
37
+ page: 'home',
38
+ has_image: false
39
+ )
40
+ end
41
+
42
+ def set_description
43
+ @description = Adminpanel::Section.new(
44
+ name: 'Inicio',
45
+ key: 'greeting',
46
+ has_description: true,
47
+ description: 'lorem ipsum dolor sit amec',
48
+ page: 'home',
49
+ has_image: false
50
+ )
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module Adminpanel
4
+ class UserTest < ActiveSupport::TestCase
5
+ setup :assign_user
6
+
7
+ def test_is_valid_user
8
+ assert @test_user.save
9
+ end
10
+
11
+ def test_name_validation
12
+ @test_user.name = ""
13
+ assert_not @test_user.valid?
14
+ end
15
+
16
+ def test_email_validation
17
+ @test_user.email = "foo@"
18
+ assert_not @test_user.valid?
19
+
20
+ @test_user.email = "foo@bar"
21
+ assert_not @test_user.valid?
22
+
23
+ @test_user.email = "@bar.baz"
24
+ assert_not @test_user.valid?
25
+
26
+ @test_user.email = "foo.baz"
27
+ assert_not @test_user.valid?
28
+ end
29
+
30
+ def test_password_validation
31
+ @test_user.password_confirmation = "foobaz"
32
+ assert_not @test_user.valid?
33
+
34
+ @test_user.password_confirmation = "foo"
35
+ @test_user.password = "foo"
36
+ assert_not @test_user.valid?
37
+ end
38
+
39
+ protected
40
+ def assign_user
41
+ @test_user = Adminpanel::User.new(
42
+ name: "Example User",
43
+ email: "foo@bar.com",
44
+ password: "foobar",
45
+ password_confirmation: "foobar",
46
+ group_id: adminpanel_groups(:Admin).id
47
+ )
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,71 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require 'rails'
3
+ require File.expand_path('../dummy/config/environment', __FILE__)
4
+ require 'rails/test_help'
5
+ require 'minitest/autorun'
6
+ require 'minitest/emoji' #emoji output
7
+ require 'capybara/rails'
8
+ require 'minitest/unit'
9
+ require 'mocha/mini_test'
10
+ require 'capybara/poltergeist'
11
+ # require 'minitest/debugger' if ENV['DEBUG'] # for deubgging
12
+
13
+
14
+ Capybara.current_driver = :poltergeist
15
+
16
+ load Rails.root.join('db', 'schema.rb')
17
+
18
+
19
+
20
+
21
+ class ActiveRecord::Base
22
+ mattr_accessor :shared_connection
23
+ @@shared_connection = nil
24
+
25
+ def self.connection
26
+ @@shared_connection || retrieve_connection
27
+ end
28
+ end
29
+
30
+ # Forces all threads to share the same connection. This works on
31
+ # Capybara because it starts the web server in a thread.
32
+ ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
33
+
34
+
35
+ class ActiveSupport::TestCase
36
+
37
+ #fixtures live inside the dummy app
38
+ fixtures :all
39
+
40
+ # Add more helper methods to be used by all tests here...
41
+ end
42
+ class ViewCase < ActionView::TestCase
43
+ include Capybara::DSL
44
+ include Capybara::Assertions
45
+ include Rails.application.routes.url_helpers
46
+
47
+ def teardown
48
+ Capybara.reset_session!
49
+ end
50
+
51
+ protected
52
+ def login(password = 'foobar')
53
+ fill_in 'inputEmail', with: adminpanel_users(:valid).email
54
+ fill_in 'inputPassword', with: password #pass is foobar
55
+ click_button I18n.t('authentication.new-session')
56
+ end
57
+ end
58
+
59
+ # class SharedTestCase < ViewCase
60
+ # # include Capybara::DSL
61
+ # # include Capybara::Assertions
62
+ # # include Rails.application.routes.url_helpers
63
+ # def before_setup
64
+ # sign_in
65
+ # end
66
+ # protected
67
+ # def sign_in
68
+ # visit adminpanel.signin_path
69
+ # login
70
+ # end
71
+ # end