base_editing_bootstrap 1.5.1 → 1.6.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/base_editing_bootstrap/VERSION +1 -1
- data/spec/support/external_shared/pundit.rb +41 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f292b335541e77a9d78ae97f8ef87cc436468094aaccd69750dae0f8dcf44af
|
|
4
|
+
data.tar.gz: 7c3f97b3261d736258efc021f36cc131943763b13f7d933cfb0967cbf58e5f36
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ec5909dab19b68590b2e2beb5dbcf7b502f2bbeb9ae3c2c244117837c4eeb54d20848ca30381f0cae4c88f6047bf3d55c2dfeef37dd28623b7b59933970e33c
|
|
7
|
+
data.tar.gz: dbaca2890a7a8a6ea1f9cde44fcd6d07495a6f289ba82f62698cc8b9cac6bfe20809133590ca05c91cecd1078ea7ce4a87087c0501e52570146eca17efd65486
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
|
3
3
|
|
|
4
4
|
- - -
|
|
5
|
+
## 1.6.0 - 2025-01-23
|
|
6
|
+
#### Features
|
|
7
|
+
- Add new test helper for association relation - (15690c7) - Marino Bonetti
|
|
8
|
+
#### Tests
|
|
9
|
+
- Fix association for order - (9e2bdd4) - Marino Bonetti
|
|
10
|
+
- Example order by ransack - (79cccc7) - Marino Bonetti
|
|
11
|
+
|
|
12
|
+
- - -
|
|
13
|
+
|
|
5
14
|
## 1.5.1 - 2025-01-22
|
|
6
15
|
#### Bug Fixes
|
|
7
16
|
- Ricerca template anche con contesto del controller - (ac93a9f) - Marino Bonetti
|
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.6.0
|
|
@@ -37,6 +37,47 @@ RSpec.shared_examples "a standard base model policy" do |factory, check_default_
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Controllo che se negli elementi dei #sortable_search_result_fields è presente un elemento
|
|
41
|
+
# che ha come prefisso il nome di una relazione presente in #permitted_associations_for_ransack
|
|
42
|
+
# allora nella policy della relativa associazione dovrò trovare in #permitted_attributes_for_ransack
|
|
43
|
+
# il nome della colonna da ordinare.
|
|
44
|
+
# ES:
|
|
45
|
+
# relazione: User -> Post
|
|
46
|
+
# class PostPolicy
|
|
47
|
+
# def sortable_search_result_fields = %i[user_username]
|
|
48
|
+
# def permitted_associations_for_ransack = %i[user]
|
|
49
|
+
# end
|
|
50
|
+
# class UserPolicy
|
|
51
|
+
# def permitted_attributes_for_ransack = %[username]
|
|
52
|
+
# end
|
|
53
|
+
# ordinamento per #user_username, quindi devo cercare relazione in `user` e attribute `username`
|
|
54
|
+
it "check associated sortable attributes" do
|
|
55
|
+
klass = instance.record.class
|
|
56
|
+
# non facciamo nulla se non è un active record il record da controllare
|
|
57
|
+
if klass.respond_to?(:reflect_on_association)
|
|
58
|
+
|
|
59
|
+
# escludiamo le colonne del modello
|
|
60
|
+
col_to_check = (instance.sortable_search_result_fields.collect(&:to_s) - instance.record.class.column_names).uniq
|
|
61
|
+
|
|
62
|
+
elenco_campi_ordinabili_in_relazione = col_to_check.map do |field|
|
|
63
|
+
instance.permitted_associations_for_ransack.map do |rel|
|
|
64
|
+
if field.match(/^#{rel}_(.*)$/)
|
|
65
|
+
[rel, Regexp.last_match(1)]
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end.flatten(1).compact.uniq
|
|
69
|
+
|
|
70
|
+
elenco_campi_ordinabili_in_relazione.each do |relation,field|
|
|
71
|
+
reflection = klass.reflect_on_association(relation.to_s)
|
|
72
|
+
policy = Pundit.policy(instance.user, reflection.class_name.constantize.new)
|
|
73
|
+
expect(policy.permitted_attributes_for_ransack.collect(&:to_sym).include?(field.to_sym)).to be_truthy, lambda{
|
|
74
|
+
"Mi aspetto che `#{policy.class.name}#permitted_attributes_for_ransack` includa `#{field}` per permettere l'ordinamento del campo tramite relazione"
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
40
81
|
describe "standard_methods" do
|
|
41
82
|
where(:method, :response) do
|
|
42
83
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: base_editing_bootstrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marino Bonetti
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-01-
|
|
11
|
+
date: 2025-01-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|