godmin 1.3.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +0 -2
- data/.gitignore +1 -0
- data/.travis.yml +9 -10
- data/Appraisals +4 -4
- data/CHANGELOG.md +84 -2
- data/Gemfile +1 -2
- data/README.md +119 -10
- data/Rakefile +2 -2
- data/app/views/godmin/resource/_breadcrumb.html.erb +12 -24
- data/app/views/godmin/resource/_breadcrumb_actions.html.erb +41 -0
- data/app/views/godmin/resource/_button_actions.html.erb +1 -1
- data/app/views/godmin/resource/_pagination.html.erb +4 -4
- data/app/views/godmin/resource/_table.html.erb +3 -0
- data/app/views/godmin/resource/columns/_actions.html.erb +4 -4
- data/app/views/godmin/resource/show.html.erb +1 -1
- data/config/locales/en.yml +2 -0
- data/config/locales/pt-BR.yml +2 -0
- data/config/locales/sv.yml +2 -0
- data/gemfiles/rails_5.gemfile +3 -4
- data/gemfiles/rails_6.gemfile +8 -0
- data/godmin.gemspec +18 -16
- data/lib/generators/godmin/resource/resource_generator.rb +7 -1
- data/lib/generators/godmin/resource/templates/resource_model.rb +4 -0
- data/lib/godmin/application_controller.rb +10 -11
- data/lib/godmin/authentication.rb +11 -11
- data/lib/godmin/authentication/sessions_controller.rb +2 -1
- data/lib/godmin/authorization.rb +34 -14
- data/lib/godmin/engine_wrapper.rb +10 -1
- data/lib/godmin/generators/base.rb +4 -4
- data/lib/godmin/generators/named_base.rb +4 -4
- data/lib/godmin/helpers/application.rb +3 -3
- data/lib/godmin/helpers/batch_actions.rb +1 -1
- data/lib/godmin/helpers/forms.rb +5 -1
- data/lib/godmin/paginator.rb +12 -4
- data/lib/godmin/resolver.rb +20 -5
- data/lib/godmin/resources/resource_controller.rb +24 -5
- data/lib/godmin/resources/resource_controller/batch_actions.rb +1 -1
- data/lib/godmin/resources/resource_service.rb +8 -7
- data/lib/godmin/resources/resource_service/associations.rb +23 -0
- data/lib/godmin/version.rb +1 -1
- data/template.rb +17 -3
- data/test/dummy/admin/app/controllers/admin/authorized_articles_controller.rb +29 -0
- data/test/dummy/admin/app/models/admin/article.rb +4 -0
- data/test/dummy/admin/app/models/admin/magazine.rb +4 -0
- data/test/dummy/admin/app/policies/admin/article_policy.rb +11 -0
- data/test/dummy/admin/app/policies/admin/magazine_policy.rb +4 -0
- data/test/dummy/admin/app/views/admin/shared/_navigation.html.erb +5 -0
- data/test/dummy/admin/config/routes.rb +1 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/controllers/another_admin_sessions_controller.rb +8 -0
- data/test/dummy/app/controllers/comments_controller.rb +3 -0
- data/test/dummy/app/models/another_admin_user.rb +7 -0
- data/test/dummy/app/models/article.rb +1 -0
- data/test/dummy/app/models/comment.rb +7 -0
- data/test/dummy/app/models/magazine.rb +2 -0
- data/test/dummy/app/services/article_service.rb +2 -0
- data/test/dummy/app/services/comment_service.rb +7 -0
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/config/application.rb +2 -14
- data/test/dummy/config/locales/en.yml +9 -0
- data/test/dummy/config/routes.rb +6 -1
- data/test/dummy/db/migrate/20150717121532_create_articles.rb +1 -1
- data/test/dummy/db/migrate/20150907133753_create_admin_users.rb +1 -1
- data/test/dummy/db/migrate/20160713134238_create_comment.rb +9 -0
- data/test/dummy/db/migrate/20170207081043_create_another_admin_user.rb +10 -0
- data/test/dummy/db/migrate/20210519215502_create_magazines.rb +9 -0
- data/test/dummy/db/schema.rb +38 -16
- data/test/fakes/article.rb +1 -1
- data/test/fakes/article_service.rb +3 -7
- data/test/generators/resource_generator_test.rb +78 -0
- data/test/integration/authentication_test.rb +8 -0
- data/test/integration/authorization_test.rb +13 -0
- data/test/integration/nested_resources_test.rb +47 -0
- data/test/test_helper.rb +1 -4
- data/test/{lib/godmin → unit}/engine_wrapper_test.rb +1 -1
- data/test/{lib/godmin → unit}/helpers/filters_test.rb +0 -0
- data/test/{lib/godmin → unit}/paginator_test.rb +11 -0
- data/test/{lib/godmin → unit}/resolver_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service/batch_actions_test.rb +1 -1
- data/test/{lib/godmin → unit}/resources/resource_service/filters_test.rb +1 -1
- data/test/{lib/godmin → unit}/resources/resource_service/ordering_test.rb +1 -1
- data/test/{lib/godmin → unit}/resources/resource_service/pagination_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service/scopes_test.rb +0 -0
- data/test/{lib/godmin → unit}/resources/resource_service_test.rb +0 -0
- metadata +175 -108
- data/gemfiles/rails_4.gemfile +0 -9
- data/lib/godmin/authorization/policy_finder.rb +0 -31
- data/lib/tasks/godmin_tasks.rake +0 -4
- data/test/lib/godmin/policy_finder_test.rb +0 -55
data/gemfiles/rails_4.gemfile
DELETED
@@ -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
|
data/lib/tasks/godmin_tasks.rake
DELETED
@@ -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
|