base_editing_bootstrap 0.13.0 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b84e9dad4cfafc627cd9615c427fe7668ebb638b80e2196e55fd16c4afcc33c
4
- data.tar.gz: a1bb90eb4aebe3fe952a41a384ba50d177db408f85a2884376fa06ab9f43f6f6
3
+ metadata.gz: 6aef652b3fc0651d54b2a217bbb32a6e750135ffc1216faa82dee66ad788e5b4
4
+ data.tar.gz: b9cf8df48a6c26bb2e67b7d65d9059e4fa974defb7e58ef1863f8e065e75af7a
5
5
  SHA512:
6
- metadata.gz: bbc195a2a2cdfbcb9ec6a42648d7f8a88f4643cee5260e038faaef90f3ee8a734f9c836b07f94b58717e6cc893520a4921bfc013d7b4db2435e3c7dd96055181
7
- data.tar.gz: 2b8c5a420ad067f2bdb43ee57df81ad5dd8e9b734a59274d9db2b44373c12d02706de0e80cad0b6723d40fda54ff4900a6eb758c192372517f5494ab7abe27c3
6
+ metadata.gz: 0d639657a9314a263c38b30e390af56f21b94071f835f4d59ccea7818f7799a3899081c534e2183349122968bd81347904ea1eb46996fa9190521039785b881d
7
+ data.tar.gz: b87959282627c61dc5b8f233503a3932cc0cb0a53ba25a192065a9ee765b95a754b55efc5998e4ec1032ca9ecdee0db334edce0f19563621c0026d97d873be2e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
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.15.0 - 2024-11-11
6
+ #### Bug Fixes
7
+ - Add Password for in standard fields - (593c8c2) - Marino Bonetti
8
+ - Form helper for non ActiveRecords - (9e124de) - Marino Bonetti
9
+ - Removed old code - (cbf1cd0) - Marino Bonetti
10
+ - Add translations for actionmodel - (3be05ca) - Marino Bonetti
11
+ #### Features
12
+ - Add debug helper logger for PunditNotAuthorized - (a9b30d6) - Marino Bonetti
13
+ - Human action messages (#10) - (63f9de9) - Marino Bonetti
14
+ #### Tests
15
+ - Add check for human_action_message method - (38af466) - Marino Bonetti
16
+ - Better tests messages - (cda150e) - Marino Bonetti
17
+
18
+ - - -
19
+
20
+ ## 0.14.0 - 2024-10-14
21
+ #### Bug Fixes
22
+ - Namespaced resources (#7) - (e85f926) - Marino Bonetti
23
+ #### Continuous Integration
24
+ - Start Enabling Rails 8.0 - (9c66914) - Marino Bonetti
25
+ - Fix scaffold generator questions - (0379151) - Marino Bonetti
26
+ #### Documentation
27
+ - Add more info in spec desc - (82ab3a7) - Marino Bonetti
28
+ - Add docs for Development - (616a0ea) - Marino Bonetti
29
+ - Add locals form partial - (022eb83) - Marino Bonetti
30
+ #### Features
31
+ - Boolean field - (8c7d0a2) - Marino Bonetti
32
+ - Auto remove input-group for checkboxes - (d5b13d2) - Marino Bonetti
33
+ - Add searchable columns - (9ccfb6f) - Marino Bonetti
34
+ - Add option to FullDisallowPolicy - (6468967) - Marino Bonetti
35
+
36
+ - - -
37
+
5
38
  ## 0.13.0 - 2024-10-02
6
39
  #### Bug Fixes
7
40
  - Correct generator - (c3a5e60) - Marino Bonetti
data/README.md CHANGED
@@ -146,6 +146,7 @@ Utilizzo per modello base, in questo esempio prendiamo come modello Post come es
146
146
  - Decimal => _decimal.html.erb
147
147
  - DateTime => _datetime.html.erb
148
148
  - Date => _date.html.erb
149
+ - Boolean => _boolean.html.erb
149
150
  - Enum => _enum.html.erb
150
151
  Per gli enum, le traduzioni dei labels di ogni valore provvengono da i18n
151
152
  attraverso l'helper: `Utilities::EnumHelper#enum_translation`
@@ -220,9 +221,40 @@ RSpec.describe ServicePolicy, type: :policy do
220
221
  end
221
222
  ```
222
223
 
224
+ ## Message translations
225
+ I messaggi di generati per il flash provengono dal metodo BaseEditingBootstrap::ActionTranslation.human_action_message
226
+ e seguono una logica simile ad human_attribute_name.
227
+ Sono già presenti i messaggi di default, a cui viene passato il nome del modello,
228
+ ma è possibile fare override del messaggio con la classe:
229
+
230
+ ```yaml
231
+ LANG:
232
+ activerecord:
233
+ successful:
234
+ messages:
235
+ created: "example %{model}"
236
+ updated:
237
+ destroyed:
238
+ CLASS_NAME:
239
+ created: "customized %{model} created"
240
+ unsuccessful:
241
+ messages:
242
+ created:
243
+ updated:
244
+ ```
245
+
246
+
223
247
 
224
248
  ## Contributing
225
- Contribution directions go here.
249
+ 1. Setup env with:
250
+ ```shell
251
+ docker compose run app spec/dummy/bin/setup
252
+ ```
253
+
254
+ 2. Start environment with:
255
+ ```shell
256
+ docker compose up
257
+ ```
226
258
 
227
259
  ## License
228
260
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -86,12 +86,14 @@ class BaseEditingController < RestrictedAreaController
86
86
 
87
87
  def base_class
88
88
  return @_base_class if @_base_class
89
- controller = controller_path
90
- modello = controller.singularize.camelize.safe_constantize
91
- logger.debug { "Editazione del controller:#{controller} per modello: #{modello.to_s}" }
92
- raise "Non riesco a restituire la classe base per il controller #{controller}" if modello.nil?
89
+ finder = BaseEditingBootstrap::ResourceFinder.new(controller_path)
90
+ if finder.model
91
+ logger.debug { "Editazione del controller:#{controller_path} per modello: #{finder.model.to_s}" }
92
+ else
93
+ raise "Non riesco a restituire la classe base per il controller #{controller_path}"
94
+ end
93
95
 
94
- @_base_class = modello
96
+ @_base_class = finder.model
95
97
  end
96
98
 
97
99
  private
@@ -184,13 +186,13 @@ class BaseEditingController < RestrictedAreaController
184
186
  format.all do
185
187
  redirect_to index_custom_polymorphic_path(base_class),
186
188
  status: :see_other,
187
- notice: t('activerecord.successful.messages.destroyed', model: base_class.model_name.human)
189
+ notice: human_action_message(action: :destroyed)
188
190
  end
189
191
  end
190
192
 
191
193
  def _failed_create(format)
192
194
  format.html do
193
- flash.now.alert = t('activerecord.unsuccessful.messages.created', model: base_class.model_name.human)
195
+ flash.now.alert = human_action_message(action: :created, successful: false)
194
196
  render action: :new, status: :unprocessable_entity
195
197
  end
196
198
  end
@@ -205,13 +207,13 @@ class BaseEditingController < RestrictedAreaController
205
207
  end
206
208
  redirect_to path,
207
209
  status: :see_other,
208
- notice: t('activerecord.successful.messages.created', model: base_class.model_name.human)
210
+ notice: human_action_message(action: :created)
209
211
  end
210
212
  end
211
213
 
212
214
  def _failed_update(format)
213
215
  format.html do
214
- flash.now.alert = t('activerecord.unsuccessful.messages.updated', model: base_class.model_name.human)
216
+ flash.now.alert = human_action_message(action: :updated, successful: false)
215
217
  render action: :edit, status: :unprocessable_entity
216
218
  end
217
219
  end
@@ -226,7 +228,10 @@ class BaseEditingController < RestrictedAreaController
226
228
  end
227
229
  redirect_to path,
228
230
  status: :see_other,
229
- notice: t('activerecord.successful.messages.updated', model: base_class.model_name.human)
231
+ notice: human_action_message(action: :updated)
230
232
  end
231
233
  end
234
+
235
+ delegate :human_action_message, to: :base_class
236
+
232
237
  end
@@ -18,6 +18,7 @@ class RestrictedAreaController < BaseEditingBootstrap.inherited_controller.const
18
18
  private
19
19
 
20
20
  def user_not_authorized(exception)
21
+ Rails.logger.debug{"Pundit::NotAuthorizedError [#{exception.message}]"}
21
22
  policy_name = exception.policy.class.to_s.underscore
22
23
 
23
24
  flash[:error] = t "#{policy_name}.#{exception.query}", scope: "pundit", default: :default
@@ -3,20 +3,7 @@ module BaseEditingHelper
3
3
  include Utilities::EnumHelper
4
4
  include Utilities::SearchHelper
5
5
  include Utilities::FormHelper
6
+ include Utilities::IconHelper
6
7
 
7
8
 
8
- ##
9
- # Genera le icone di Bootstrap icons
10
- def icon( name, text = nil, html_options = {})
11
- text, html_options = nil, text if text.is_a?(Hash)
12
-
13
- content_class = "bi-#{name}"
14
- content_class << " #{html_options[:class]}" if html_options.key?(:class)
15
- html_options[:class] = content_class
16
- html_options['aria-hidden'] ||= true
17
-
18
- html = content_tag(:i, nil, html_options)
19
- html << ' ' << text.to_s unless text.blank?
20
- html
21
- end
22
9
  end
@@ -18,10 +18,14 @@ module Utilities
18
18
  # @param [Symbol] field
19
19
  def form_print_field(form, field)
20
20
  locals = {form:, field:}
21
- if form.object.class.defined_enums.key?(field.to_s)
21
+ if form.object.class.respond_to?(:defined_enums) && form.object.class.defined_enums.key?(field.to_s)
22
22
  generic_field = "enum"
23
23
  else
24
- type = form.object.class.type_for_attribute(field).type
24
+ if form.object.class.respond_to?(:type_for_attribute)
25
+ type = form.object.class.type_for_attribute(field).type
26
+ else
27
+ type = :string
28
+ end
25
29
  case type
26
30
  when :datetime
27
31
  generic_field = "datetime"
@@ -35,6 +39,8 @@ module Utilities
35
39
  generic_field = "decimal"
36
40
  when :integer
37
41
  generic_field = "integer"
42
+ when :boolean
43
+ generic_field = "boolean"
38
44
  else
39
45
  generic_field = "base"
40
46
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Utilities::IconHelper
4
+
5
+ ##
6
+ # Genera le icone di Bootstrap icons
7
+ def icon( name, text = nil, html_options = {})
8
+ text, html_options = nil, text if text.is_a?(Hash)
9
+
10
+ content_class = "bi-#{name}"
11
+ content_class += " #{html_options[:class]}" if html_options.key?(:class)
12
+ html_options[:class] = content_class
13
+ html_options['aria-hidden'] ||= true
14
+
15
+ html = content_tag(:i, nil, html_options)
16
+ html << ' ' << text.to_s unless text.blank?
17
+ html
18
+ end
19
+ end
@@ -1,6 +1,8 @@
1
1
  module Utilities
2
2
  module SearchHelper
3
3
  include TemplateHelper
4
+ include PageHelper
5
+ include IconHelper
4
6
 
5
7
  ##
6
8
  # Per aggiungere bottoni:
@@ -32,7 +34,14 @@ module Utilities
32
34
  when :created_at, :updated_at
33
35
  "timestamps"
34
36
  else
35
- "base"
37
+ type = obj.class.type_for_attribute(field).type
38
+ case type
39
+ when :boolean
40
+ "boolean"
41
+ else
42
+ "base"
43
+ end
44
+
36
45
  end
37
46
  template = find_template_with_fallbacks(
38
47
  obj,
@@ -1,7 +1,27 @@
1
- <%= form.label(form_field, class: ["form-label","form-#{form_field}-label"]) %>
2
- <div class="input-group mb-2 <%= form.object.validated? ? "has-validation" : "" %><%= "form-#{form_field}-input-group" %>">
1
+ <%
2
+ ##
3
+ # Template per il rendering campo
4
+ # - form -> FormBuilder
5
+ # - form_field -> Array[String]
6
+ %>
7
+ <%# locals: (form:, form_field:) -%>
8
+ <%= form.label(form_field, class: ["form-label", "form-#{form_field}-label"]) %>
9
+
10
+ <%
11
+ button_group_classes = ["mb-2"]
12
+
13
+ content = form_print_field(form, form_field)
14
+ unless content.match "checkbox"
15
+ button_group_classes << "input-group"
16
+ end
17
+
18
+ button_group_classes << (form.object.validated? ? "has-validation" : "")
19
+ button_group_classes << "form-#{form_field}-input-group"
20
+
21
+ %>
22
+ <%= content_tag :div, class: button_group_classes.join(" ") do %>
3
23
  <%= render partial: "editing_form_measure_unit", locals: {object: form.object, field: form_field} %>
4
- <%= form_print_field(form, form_field) %>
24
+ <%= content %>
5
25
  <%= error_messages_for(form.object, form_field) %>
6
- </div>
26
+ <% end %>
7
27
  <%= render partial: "editing_form_help_text", locals: {object: form.object, field: form_field} %>
@@ -0,0 +1,3 @@
1
+ <%# Renderizza il campo nella tabella della pagina dei risultati %>
2
+ <%# locals: (obj:,field:) -%>
3
+ <td><%= boolean_to_icon obj.read_attribute(field) %></td>
@@ -0,0 +1,2 @@
1
+ <%# locals: (form:, field:) -%>
2
+ <%= form.switch_box(field) %>
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  end
30
30
  spec.files += Dir['spec/support/external_shared/*.rb']
31
31
 
32
- spec.add_dependency "rails", [">= 7.0", "< 8.0"]
32
+ spec.add_dependency "rails", [">= 7.0", "< 8.1"]
33
33
  # Policy
34
34
  spec.add_dependency "pundit", ["~> 2.3", ">= 2.3.1"]
35
35
  # Search
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency "factory_bot_rails", '~> 6.4'
43
43
  spec.add_development_dependency 'faker', '~> 3.3'
44
44
  spec.add_development_dependency "puma", '~> 6.4'
45
- spec.add_development_dependency "sqlite3", '~> 1.7'
45
+ spec.add_development_dependency "sqlite3", '>= 1.7.x'
46
46
  spec.add_development_dependency "sprockets-rails", '~> 3.4'
47
47
  spec.add_development_dependency 'rails-i18n', '~> 7.0' # For 7.0.0
48
48
  spec.add_development_dependency "i18n-debug", '~> 1.2'
@@ -40,6 +40,16 @@ it:
40
40
  # post_policy:
41
41
  # update?: 'You cannot edit this post!'
42
42
  # create?: 'You cannot create posts!'
43
+ activemodel:
44
+ successful:
45
+ messages:
46
+ created: "%{model} creato correttamente."
47
+ updated: "%{model} aggiornato correttamente."
48
+ destroyed: "%{model} è stato correttamente cancellato."
49
+ unsuccessful:
50
+ messages:
51
+ created: "Ci sono errori che impediscono la creazione di %{model}"
52
+ updated: "Ci sono errori che impediscono l'aggiornamento di %{model}"
43
53
  activerecord:
44
54
  successful:
45
55
  messages:
@@ -1 +1 @@
1
- 0.13.0
1
+ 0.15.0
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ require 'active_support/concern'
3
+
4
+ module BaseEditingBootstrap
5
+ module ActionTranslation
6
+
7
+ extend ActiveSupport::Concern
8
+
9
+ class_methods do
10
+
11
+ ##
12
+ # Viene generato un messaggio rispetto all'azione nel caso di successo o fallimento
13
+ # i messaggi seguono la stessa logica del human_attribute_name con inheritance delle classi`
14
+ #
15
+ # {i18n_scope della classe}.{successful|unsuccessful}.messages.{class_name}.{action}
16
+ # {i18n_scope della classe}.{successful|unsuccessful}.messages.{class_ancestors}.{action}
17
+ # {i18n_scope della classe}.{successful|unsuccessful}.messages.{action}
18
+ def human_action_message(action:, successful: true, **options)
19
+
20
+ successful_string = successful ? "successful" : "unsuccessful"
21
+
22
+ defaults = lookup_ancestors.map do |klass|
23
+ :"#{i18n_scope}.#{successful_string}.messages.#{klass.model_name.i18n_key}.#{action}"
24
+ end
25
+
26
+ defaults << options[:default] if options[:default]
27
+ defaults << :"#{i18n_scope}.#{successful_string}.messages.#{action}"
28
+
29
+ options.reverse_merge!(model: model_name.human)
30
+
31
+ I18n.t(
32
+ defaults.shift,
33
+ default: defaults,
34
+ **options
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
@@ -6,6 +6,7 @@ module BaseEditingBootstrap
6
6
 
7
7
  included do
8
8
  include IsValidated
9
+ include ActionTranslation
9
10
  delegate :ransackable_attributes, :ransackable_associations, to: :@class
10
11
  end
11
12
 
@@ -16,8 +17,8 @@ module BaseEditingBootstrap
16
17
  else
17
18
  Pundit.policy(User.new, self.new).permitted_attributes_for_ransack.map(&:to_s)
18
19
  end
19
- end
20
-
20
+ end
21
+
21
22
  def ransackable_associations(auth_object = nil)
22
23
  if auth_object
23
24
  Pundit.policy(auth_object, self.new).permitted_associations_for_ransack.map(&:to_s)
@@ -4,6 +4,7 @@ module BaseEditingBootstrap::Forms
4
4
  class Base < ActionView::Helpers::FormBuilder
5
5
  [
6
6
  :text_field,
7
+ :password_field,
7
8
  :text_area,
8
9
  :date_field,
9
10
  :datetime_field,
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BaseEditingBootstrap
4
+ ##
5
+ # PORO to find the base classe in the BaseEditingController
6
+ class ResourceFinder
7
+ def initialize(controllar_path)
8
+ @controllar_path = controllar_path
9
+ @_model_class = false
10
+ end
11
+
12
+ # @return [NilClass|Object]
13
+ def model
14
+ if @_model_class === false
15
+ @_model_class = nil
16
+ if (anything = @controllar_path.singularize.camelize.safe_constantize)
17
+ @_model_class = anything
18
+ else
19
+ if @controllar_path.include?("/")
20
+ demodulize_one_level = @controllar_path.split("/")[1..].join("/")
21
+ if demodulize_one_level != @controllar_path
22
+ @_model_class = ResourceFinder.new(demodulize_one_level).model
23
+ end
24
+ end
25
+ end
26
+ end
27
+ @_model_class
28
+ end
29
+ end
30
+ end
@@ -7,7 +7,7 @@ module BaseEditingBootstrap
7
7
  argument :name, type: :string, banner: "Post", required: true
8
8
  argument :attributes, type: :array, default: [], banner: "field field:type"
9
9
 
10
- TYPES = [:base,:timestamps].freeze
10
+ TYPES = [:base, :timestamps, :boolean].freeze
11
11
 
12
12
  desc <<-DESCRIPTION.strip_heredoc
13
13
  Description:
@@ -7,7 +7,7 @@ module BaseEditingBootstrap
7
7
  argument :name, type: :string, banner: "Post", required: true
8
8
  argument :attributes, type: :array, default: [], banner: "field field:type"
9
9
 
10
- TYPES = %i[base date datetime decimal integer enum]
10
+ TYPES = %i[base date datetime decimal integer enum boolean]
11
11
 
12
12
  desc <<-DESCRIPTION.strip_heredoc
13
13
  Description:
@@ -31,7 +31,8 @@ module BaseEditingBootstrap
31
31
 
32
32
  def add_policy
33
33
  @search_attrs = []
34
- if yes? "Vuoi poter ricercare determinati campi con form di ricerca?"
34
+ @permitted_attributes = []
35
+ if yes? "Vuoi poter ricercare determinati campi con form di ricerca?(y/n)"
35
36
 
36
37
  say "Gli attributi che hai indicato sono: #{ attributes_names.join(",")}"
37
38
  say <<~MESSAGE
@@ -52,11 +53,11 @@ module BaseEditingBootstrap
52
53
  out << [attr, *matchers.keys.collect{|m| "#{attr}#{m}" } ]
53
54
  end
54
55
 
55
- puts out.inspect
56
-
57
56
  print_table(out,borders:true)
58
57
  @search_attrs = ask("Inserisce un elenco diviso da virgola degli attributi da ricercare").split(",")
59
-
58
+ #cerchiamo di estrapolare gli attributi da rendere disponibili a ransack per la ricerca
59
+ @permitted_attributes = out.select{|c| c[1..].intersect?(@search_attrs) }.collect(&:first)
60
+ puts @permitted_attributes.inspect
60
61
  end
61
62
 
62
63
  template "policy.rb", File.join("app/policies", "#{singular_name}_policy.rb")
@@ -8,4 +8,10 @@ class <%= class_name %>Policy < BaseModelPolicy
8
8
  %i[<%= @search_attrs.join(" ") %>]
9
9
  end
10
10
  <%- end -%>
11
+ <%- if @permitted_attributes.any? -%>
12
+ # TODO check if correct with search_fields
13
+ def permitted_attributes_for_ransack
14
+ %w[<%= @permitted_attributes.join(" ") %>]
15
+ end
16
+ <%- end -%>
11
17
  end
@@ -130,6 +130,7 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
130
130
  # edit
131
131
  expect(response).to redirect_to(url_for_edit.call(assigns[:object]))
132
132
  end
133
+ expect(flash.to_hash).to include("notice" => be_present)
133
134
  end
134
135
 
135
136
  unless skip_invalid_checks
@@ -154,6 +155,7 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
154
155
  # edit
155
156
  expect(response).to redirect_to(url_for_edit.call(assigns[:object]))
156
157
  end
158
+ expect(flash.to_hash).to include("notice" => be_present)
157
159
  end
158
160
 
159
161
  unless skip_invalid_checks
@@ -171,6 +173,7 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
171
173
  delete url_for(persisted_instance)
172
174
  expect(assigns[:object]).to be_an_instance_of(model)
173
175
  expect(response).to redirect_to(url_for_succ_delete)
176
+ expect(flash.to_hash).to include("notice" => be_present)
174
177
  end
175
178
 
176
179
  it "not valid" do
@@ -180,7 +183,7 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
180
183
  end
181
184
  delete url_for(persisted_instance)
182
185
  expect(response).to redirect_to(url_for_fail_delete)
183
- expect(flash[:error]).not_to be_blank
186
+ expect(flash.to_hash).to include("error" => be_present)
184
187
  end
185
188
  end
186
189
  end
@@ -199,7 +202,7 @@ RSpec.shared_examples "fail with unauthorized" do |request: default_unathorized_
199
202
 
200
203
  instance_exec(&request)
201
204
  expect(response).to redirect_to(root_path)
202
- expect(flash[:error]).not_to be_nil
205
+ expect(flash.to_hash).to include("error" => be_present)
203
206
  end
204
207
  end
205
208
 
@@ -2,6 +2,10 @@ RSpec.shared_examples "a base model" do |ransack_permitted_attributes: [], ransa
2
2
 
3
3
  it_behaves_like "a validated? object"
4
4
 
5
+ it "human_action_message" do
6
+ expect(described_class).to respond_to(:human_action_message)
7
+ end
8
+
5
9
  describe "with ransackables" do
6
10
  where(:base_model_method, :policy_method, :policy_output, :result) do
7
11
  [
@@ -54,7 +58,6 @@ end
54
58
 
55
59
  RSpec.shared_examples "a validated? object" do
56
60
  subject {
57
- # prendiamo un modello a caso per testare questa cosa
58
61
  described_class.new
59
62
  }
60
63
 
@@ -28,6 +28,14 @@ RSpec.shared_examples "a standard base model policy" do |factory, check_default_
28
28
  create: true,
29
29
  index: true
30
30
  }
31
+ elsif check_default_responses == :full_disallow
32
+ checks = {
33
+ show: false,
34
+ destroy: false,
35
+ update: false,
36
+ create: false,
37
+ index: false
38
+ }
31
39
  elsif check_default_responses.is_a? Hash
32
40
  checks = check_default_responses
33
41
  elsif check_default_responses == false
@@ -37,6 +45,7 @@ RSpec.shared_examples "a standard base model policy" do |factory, check_default_
37
45
  Acceptable values for check_default_responses are:
38
46
  - true
39
47
  - false
48
+ - :full_disallow -> all methods to false
40
49
  - Hash with:
41
50
  show
42
51
  destroy
@@ -64,7 +73,7 @@ RSpec.shared_examples "a standard base model policy" do |factory, check_default_
64
73
  end
65
74
 
66
75
  with_them do
67
- it "should " do
76
+ it "should respond_to? #{params[:method]}" do
68
77
  expect(instance).to respond_to(method)
69
78
  end
70
79
  if check_default_responses
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.13.0
4
+ version: 0.15.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-10-02 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '7.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '8.0'
22
+ version: '8.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '7.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '8.0'
32
+ version: '8.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pundit
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -164,16 +164,16 @@ dependencies:
164
164
  name: sqlite3
165
165
  requirement: !ruby/object:Gem::Requirement
166
166
  requirements:
167
- - - "~>"
167
+ - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: '1.7'
169
+ version: 1.7.x
170
170
  type: :development
171
171
  prerelease: false
172
172
  version_requirements: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - "~>"
174
+ - - ">="
175
175
  - !ruby/object:Gem::Version
176
- version: '1.7'
176
+ version: 1.7.x
177
177
  - !ruby/object:Gem::Dependency
178
178
  name: sprockets-rails
179
179
  requirement: !ruby/object:Gem::Requirement
@@ -302,6 +302,7 @@ files:
302
302
  - app/helpers/base_editing_helper.rb
303
303
  - app/helpers/utilities/enum_helper.rb
304
304
  - app/helpers/utilities/form_helper.rb
305
+ - app/helpers/utilities/icon_helper.rb
305
306
  - app/helpers/utilities/page_helper.rb
306
307
  - app/helpers/utilities/search_helper.rb
307
308
  - app/helpers/utilities/template_helper.rb
@@ -331,9 +332,11 @@ files:
331
332
  - app/views/base_editing/_search_result_row.html.erb
332
333
  - app/views/base_editing/_tabs.html.erb
333
334
  - app/views/base_editing/cell_field/_base.html.erb
335
+ - app/views/base_editing/cell_field/_boolean.html.erb
334
336
  - app/views/base_editing/cell_field/_timestamps.html.erb
335
337
  - app/views/base_editing/edit.html.erb
336
338
  - app/views/base_editing/form_field/_base.html.erb
339
+ - app/views/base_editing/form_field/_boolean.html.erb
337
340
  - app/views/base_editing/form_field/_date.html.erb
338
341
  - app/views/base_editing/form_field/_datetime.html.erb
339
342
  - app/views/base_editing/form_field/_decimal.html.erb
@@ -355,10 +358,12 @@ files:
355
358
  - config/routes.rb
356
359
  - lib/base_editing_bootstrap.rb
357
360
  - lib/base_editing_bootstrap/VERSION
361
+ - lib/base_editing_bootstrap/action_translation.rb
358
362
  - lib/base_editing_bootstrap/base_model.rb
359
363
  - lib/base_editing_bootstrap/engine.rb
360
364
  - lib/base_editing_bootstrap/forms/base.rb
361
365
  - lib/base_editing_bootstrap/is_validated.rb
366
+ - lib/base_editing_bootstrap/resource_finder.rb
362
367
  - lib/base_editing_bootstrap/searches/base.rb
363
368
  - lib/base_editing_bootstrap/searches/field.rb
364
369
  - lib/base_editing_bootstrap/version.rb