godmin 1.3.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +0 -2
  3. data/.gitignore +1 -0
  4. data/.travis.yml +9 -10
  5. data/Appraisals +4 -4
  6. data/CHANGELOG.md +84 -2
  7. data/Gemfile +1 -2
  8. data/README.md +119 -10
  9. data/Rakefile +2 -2
  10. data/app/views/godmin/resource/_breadcrumb.html.erb +12 -24
  11. data/app/views/godmin/resource/_breadcrumb_actions.html.erb +41 -0
  12. data/app/views/godmin/resource/_button_actions.html.erb +1 -1
  13. data/app/views/godmin/resource/_pagination.html.erb +4 -4
  14. data/app/views/godmin/resource/_table.html.erb +3 -0
  15. data/app/views/godmin/resource/columns/_actions.html.erb +4 -4
  16. data/app/views/godmin/resource/show.html.erb +1 -1
  17. data/config/locales/en.yml +2 -0
  18. data/config/locales/pt-BR.yml +2 -0
  19. data/config/locales/sv.yml +2 -0
  20. data/gemfiles/rails_5.gemfile +3 -4
  21. data/gemfiles/rails_6.gemfile +8 -0
  22. data/godmin.gemspec +18 -16
  23. data/lib/generators/godmin/resource/resource_generator.rb +7 -1
  24. data/lib/generators/godmin/resource/templates/resource_model.rb +4 -0
  25. data/lib/godmin/application_controller.rb +10 -11
  26. data/lib/godmin/authentication.rb +11 -11
  27. data/lib/godmin/authentication/sessions_controller.rb +2 -1
  28. data/lib/godmin/authorization.rb +34 -14
  29. data/lib/godmin/engine_wrapper.rb +10 -1
  30. data/lib/godmin/generators/base.rb +4 -4
  31. data/lib/godmin/generators/named_base.rb +4 -4
  32. data/lib/godmin/helpers/application.rb +3 -3
  33. data/lib/godmin/helpers/batch_actions.rb +1 -1
  34. data/lib/godmin/helpers/forms.rb +5 -1
  35. data/lib/godmin/paginator.rb +12 -4
  36. data/lib/godmin/resolver.rb +20 -5
  37. data/lib/godmin/resources/resource_controller.rb +24 -5
  38. data/lib/godmin/resources/resource_controller/batch_actions.rb +1 -1
  39. data/lib/godmin/resources/resource_service.rb +8 -7
  40. data/lib/godmin/resources/resource_service/associations.rb +23 -0
  41. data/lib/godmin/version.rb +1 -1
  42. data/template.rb +17 -3
  43. data/test/dummy/admin/app/controllers/admin/authorized_articles_controller.rb +29 -0
  44. data/test/dummy/admin/app/models/admin/article.rb +4 -0
  45. data/test/dummy/admin/app/models/admin/magazine.rb +4 -0
  46. data/test/dummy/admin/app/policies/admin/article_policy.rb +11 -0
  47. data/test/dummy/admin/app/policies/admin/magazine_policy.rb +4 -0
  48. data/test/dummy/admin/app/views/admin/shared/_navigation.html.erb +5 -0
  49. data/test/dummy/admin/config/routes.rb +1 -0
  50. data/test/dummy/app/assets/config/manifest.js +4 -0
  51. data/test/dummy/app/controllers/another_admin_sessions_controller.rb +8 -0
  52. data/test/dummy/app/controllers/comments_controller.rb +3 -0
  53. data/test/dummy/app/models/another_admin_user.rb +7 -0
  54. data/test/dummy/app/models/article.rb +1 -0
  55. data/test/dummy/app/models/comment.rb +7 -0
  56. data/test/dummy/app/models/magazine.rb +2 -0
  57. data/test/dummy/app/services/article_service.rb +2 -0
  58. data/test/dummy/app/services/comment_service.rb +7 -0
  59. data/test/dummy/bin/rails +1 -1
  60. data/test/dummy/config/application.rb +2 -14
  61. data/test/dummy/config/locales/en.yml +9 -0
  62. data/test/dummy/config/routes.rb +6 -1
  63. data/test/dummy/db/migrate/20150717121532_create_articles.rb +1 -1
  64. data/test/dummy/db/migrate/20150907133753_create_admin_users.rb +1 -1
  65. data/test/dummy/db/migrate/20160713134238_create_comment.rb +9 -0
  66. data/test/dummy/db/migrate/20170207081043_create_another_admin_user.rb +10 -0
  67. data/test/dummy/db/migrate/20210519215502_create_magazines.rb +9 -0
  68. data/test/dummy/db/schema.rb +38 -16
  69. data/test/fakes/article.rb +1 -1
  70. data/test/fakes/article_service.rb +3 -7
  71. data/test/generators/resource_generator_test.rb +78 -0
  72. data/test/integration/authentication_test.rb +8 -0
  73. data/test/integration/authorization_test.rb +13 -0
  74. data/test/integration/nested_resources_test.rb +47 -0
  75. data/test/test_helper.rb +1 -4
  76. data/test/{lib/godmin → unit}/engine_wrapper_test.rb +1 -1
  77. data/test/{lib/godmin → unit}/helpers/filters_test.rb +0 -0
  78. data/test/{lib/godmin → unit}/paginator_test.rb +11 -0
  79. data/test/{lib/godmin → unit}/resolver_test.rb +0 -0
  80. data/test/{lib/godmin → unit}/resources/resource_service/batch_actions_test.rb +1 -1
  81. data/test/{lib/godmin → unit}/resources/resource_service/filters_test.rb +1 -1
  82. data/test/{lib/godmin → unit}/resources/resource_service/ordering_test.rb +1 -1
  83. data/test/{lib/godmin → unit}/resources/resource_service/pagination_test.rb +0 -0
  84. data/test/{lib/godmin → unit}/resources/resource_service/scopes_test.rb +0 -0
  85. data/test/{lib/godmin → unit}/resources/resource_service_test.rb +0 -0
  86. metadata +175 -108
  87. data/gemfiles/rails_4.gemfile +0 -9
  88. data/lib/godmin/authorization/policy_finder.rb +0 -31
  89. data/lib/tasks/godmin_tasks.rake +0 -4
  90. data/test/lib/godmin/policy_finder_test.rb +0 -55
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "admin", :path => "../test/dummy/admin", :group => [:test, :development]
6
- gem "codeclimate-test-reporter", :group => :test, :require => nil
7
- gem "rails", "~> 4.0"
8
-
9
- gemspec :path => "../"
@@ -1,31 +0,0 @@
1
- module Godmin
2
- module Authorization
3
- class PolicyFinder
4
- class << self
5
- def find(object, namespace = nil)
6
- return object.policy_class if object.respond_to?(:policy_class)
7
- return object.class.policy_class if object.class.respond_to?(:policy_class)
8
-
9
- klass =
10
- if object.respond_to?(:model_name)
11
- object.model_name
12
- elsif object.class.respond_to?(:model_name)
13
- object.class.model_name
14
- elsif object.is_a?(Class)
15
- object
16
- elsif object.is_a?(Symbol)
17
- object.to_s.classify
18
- else
19
- object.class
20
- end
21
-
22
- if namespace
23
- "#{namespace}::#{klass}Policy"
24
- else
25
- "#{klass}Policy"
26
- end.constantize
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :godmin do
3
- # # Task goes here
4
- # end
@@ -1,55 +0,0 @@
1
- require "test_helper"
2
-
3
- module Godmin
4
- module Authorization
5
- class PolicyFinderTest < ActiveSupport::TestCase
6
- class Article; end
7
- class ArticlePolicy; end
8
-
9
- def test_find_by_model
10
- klass = Class.new do
11
- extend ActiveModel::Naming
12
-
13
- def self.name
14
- "Article"
15
- end
16
- end
17
-
18
- policy = PolicyFinder.find(klass, Godmin::Authorization::PolicyFinderTest)
19
- assert_equal ArticlePolicy, policy
20
- end
21
-
22
- def test_find_by_class
23
- policy = PolicyFinder.find(Article)
24
- assert_equal ArticlePolicy, policy
25
- end
26
-
27
- def test_find_by_symbol
28
- policy = PolicyFinder.find(:article, Godmin::Authorization::PolicyFinderTest)
29
- assert_equal ArticlePolicy, policy
30
- end
31
-
32
- def test_override_policy_class_on_class
33
- klass = Class.new do
34
- def self.policy_class
35
- ArticlePolicy
36
- end
37
- end
38
-
39
- policy = PolicyFinder.find(klass)
40
- assert_equal ArticlePolicy, policy
41
- end
42
-
43
- def test_override_policy_class_on_instance
44
- klass = Class.new do
45
- def policy_class
46
- ArticlePolicy
47
- end
48
- end
49
-
50
- policy = PolicyFinder.find(klass.new)
51
- assert_equal ArticlePolicy, policy
52
- end
53
- end
54
- end
55
- end