base_editing_bootstrap 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/app/controllers/base_editing_controller.rb +5 -1
- data/app/helpers/utilities/form_helper.rb +16 -16
- data/lib/base_editing_bootstrap/VERSION +1 -1
- data/lib/generators/base_editing_bootstrap/install/templates/initializer.rb +3 -3
- data/spec/support/external_shared/pundit.rb +6 -4
- 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: ba7128b63918eeebe5d2615895fccdfb352a01522d789b563c76c32bb48cf2a8
|
4
|
+
data.tar.gz: 8a131d2ba99e266f7ac0b92e4b993e791508141f46dbecb8b228a296bd5a6fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61af8c0e0f59c866de6216d054b6d143935ead13eae8a47287b24f9b6efa2103ce29d6684c91cf9668996ade6fa6303fbd623d7828a6587e23571e8b64f0e0c8
|
7
|
+
data.tar.gz: 3d1495bcf1b375514dd1fe010de6135e4ca68957b22e5c051aeae3871f7025996c5d75400919c1e9c0e53b01ec8799ed3067a0efc2154e7bab1f7ef6b9e0dc44
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,23 @@
|
|
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
|
+
## 0.5.0 - 2024-05-22
|
6
|
+
#### Bug Fixes
|
7
|
+
- Correct initializer commented examples - (ba90fba) - Marino Bonetti
|
8
|
+
#### Features
|
9
|
+
- Action for Show enabled - (d364ed3) - Marino Bonetti
|
10
|
+
- Enums with Integer identified - (4fa9e87) - Marino Bonetti
|
11
|
+
#### Tests
|
12
|
+
- Save example_status_persistence_file_path - (235939d) - Marino Bonetti
|
13
|
+
|
14
|
+
- - -
|
15
|
+
|
16
|
+
## 0.4.2 - 2024-05-08
|
17
|
+
#### Bug Fixes
|
18
|
+
- Rename shared example for cluck with apps - (41638f8) - Marino Bonetti
|
19
|
+
|
20
|
+
- - -
|
21
|
+
|
5
22
|
## 0.4.1 - 2024-04-30
|
6
23
|
#### Bug Fixes
|
7
24
|
- Correct pundit shared examples - (2001e08) - Marino Bonetti
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class BaseEditingController < RestrictedAreaController
|
2
|
-
before_action :load_object, only: [:edit, :update, :destroy]
|
2
|
+
before_action :load_object, only: [:edit, :show, :update, :destroy]
|
3
3
|
helper_method :base_class,
|
4
4
|
:destroy_custom_polymorphic_path,
|
5
5
|
:edit_custom_polymorphic_path,
|
@@ -32,6 +32,10 @@ class BaseEditingController < RestrictedAreaController
|
|
32
32
|
@object = yield(@object) if block_given?
|
33
33
|
end
|
34
34
|
|
35
|
+
def show
|
36
|
+
@object = yield(@object) if block_given?
|
37
|
+
end
|
38
|
+
|
35
39
|
def update
|
36
40
|
@object = yield(@object) if block_given?
|
37
41
|
respond_to do |format|
|
@@ -18,23 +18,23 @@ module Utilities
|
|
18
18
|
# @param [Symbol] field
|
19
19
|
def form_print_field(form, field)
|
20
20
|
locals = {form:, field:}
|
21
|
-
|
22
|
-
|
23
|
-
when :datetime
|
24
|
-
generic_field = "datetime"
|
25
|
-
when :date
|
26
|
-
generic_field = "date"
|
27
|
-
when :decimal
|
28
|
-
locals[:scale] = form.object.class.type_for_attribute(field).scale || 2
|
29
|
-
generic_field = "decimal"
|
30
|
-
when :float
|
31
|
-
locals[:scale] = 2 # usiamo il default dato che non abbiamo questa informazione negli attributes di rails
|
32
|
-
generic_field = "decimal"
|
33
|
-
when :integer
|
34
|
-
generic_field = "integer"
|
21
|
+
if form.object.class.defined_enums.key?(field.to_s)
|
22
|
+
generic_field = "enum"
|
35
23
|
else
|
36
|
-
|
37
|
-
|
24
|
+
type = form.object.class.type_for_attribute(field).type
|
25
|
+
case type
|
26
|
+
when :datetime
|
27
|
+
generic_field = "datetime"
|
28
|
+
when :date
|
29
|
+
generic_field = "date"
|
30
|
+
when :decimal
|
31
|
+
locals[:scale] = form.object.class.type_for_attribute(field).scale || 2
|
32
|
+
generic_field = "decimal"
|
33
|
+
when :float
|
34
|
+
locals[:scale] = 2 # usiamo il default dato che non abbiamo questa informazione negli attributes di rails
|
35
|
+
generic_field = "decimal"
|
36
|
+
when :integer
|
37
|
+
generic_field = "integer"
|
38
38
|
else
|
39
39
|
generic_field = "base"
|
40
40
|
end
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -5,18 +5,18 @@ BaseEditingBootstrap.configure do |config|
|
|
5
5
|
# Controller da cui derivare poi il BaseEditingController da cui derivano
|
6
6
|
# tutti i controller sottostanti
|
7
7
|
# @default "ApplicationController"
|
8
|
-
#
|
8
|
+
# config.inherited_controller = "ApplicationController"
|
9
9
|
|
10
10
|
##
|
11
11
|
# Configurazione per alterare lo standard di azione post aggiornamento record
|
12
12
|
# il default è andare nella pagina di editing del record
|
13
13
|
# possibili valori :edit , :index
|
14
|
-
#
|
14
|
+
# config.inherited_controller = :edit
|
15
15
|
|
16
16
|
##
|
17
17
|
# Configurazione per alterare lo standard di azione post creazione record
|
18
18
|
# il default è andare nella pagina di editing del record
|
19
19
|
# possibili valori :edit , :index
|
20
|
-
#
|
20
|
+
# config.inherited_controller = :edit
|
21
21
|
|
22
22
|
end
|
@@ -13,11 +13,11 @@ RSpec::Matchers.define :permit_editable_attributes do |*expected_attributes|
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
RSpec.shared_examples "a standard policy" do |factory|
|
16
|
+
RSpec.shared_examples "a standard base model policy" do |factory, check_default_responses: false|
|
17
17
|
let(:user) { create(:user) }
|
18
18
|
let(:instance) { described_class.new(user, build(factory)) }
|
19
19
|
|
20
|
-
describe "
|
20
|
+
describe "standard_methods" do
|
21
21
|
where(:method, :response) do
|
22
22
|
[
|
23
23
|
[:show?, false],
|
@@ -32,8 +32,10 @@ RSpec.shared_examples "a standard policy" do |factory|
|
|
32
32
|
it "should " do
|
33
33
|
expect(instance).to respond_to(method)
|
34
34
|
end
|
35
|
-
|
36
|
-
|
35
|
+
if check_default_responses
|
36
|
+
it "return value" do
|
37
|
+
expect(instance.send(method)).to be == response
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
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: 0.
|
4
|
+
version: 0.5.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: 2024-
|
11
|
+
date: 2024-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|