pg_rails 7.3.4 → 7.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b6625d4eea069719a53935223e89933c45ea8193b707a0a601646cf1c7d4d28
4
- data.tar.gz: 8fc921c742a0dd8c2d361b8844a36d04f92ca03617cec64dd178bf043ae11781
3
+ metadata.gz: 76de379c2a544b8c8cbb3dc273d48c889a4e1433382f4cb5506f6af6ab5a87a0
4
+ data.tar.gz: 6e8328117a18ec5919b5e524491bd9dae8a157c14af0bf9ad4ff81c360ef39a1
5
5
  SHA512:
6
- metadata.gz: 42908b6091fa4b5d36cc10bcdc19c6665171c107f73c0dd7b2457355550e931e8bec5d212de311a8bb667090531506b2aab8ce30c101829566e8acd20b8f260f
7
- data.tar.gz: deba07fbf28846fb3a536ebc4d0002965cc131c4ad6bb626d4242c49ba9a45d303ccd85ccebec6f75cbd8eab6c3dea58159588541db785f4320e4fbdff0f5c7e
6
+ metadata.gz: '050966c0de869132e98d92ee13a2697f38429a1b11145161318c41ffa00cbba38f02dde11d2d72a6db798171cf99c9377eb48422bd292ba01a89ba5f49a1ee1d'
7
+ data.tar.gz: 0c61544a7e0152a31fd2e2cdea22172e809f04125d11cb2d009e40c676bd631e713c9758e9fb7189840e65851df32d2ee94f8f705baebba695ce04f5a8718b5e
@@ -15,7 +15,7 @@ class InternalErrorComponent < BaseComponent
15
15
  </div>
16
16
  Por favor, intentá nuevamente
17
17
  <br>
18
- o <a class="text-decoration-underline" href="<%= new_public_mensaje_contacto_path %>">dejá un mensaje</a>
18
+ o <a class="text-decoration-underline" href="<%= new_public_mensaje_contacto_path %>" data-turbo="false">dejá un mensaje</a>
19
19
  para que te avisemos
20
20
  <br>
21
21
  cuando el problema esté resuelto 🙏
@@ -379,7 +379,7 @@ module PgEngine
379
379
  def render_listing
380
380
  total = @collection.count
381
381
  current_page = params[:page].presence&.to_i || 1
382
- if current_page_size * (current_page - 1) > total
382
+ if current_page_size * (current_page - 1) >= total
383
383
  current_page = (total.to_f / current_page_size).ceil
384
384
  end
385
385
  @collection = @collection.page(current_page).per(current_page_size)
@@ -96,7 +96,7 @@ module PgEngine
96
96
  @navbar_chevron_class = navbar_expanded ? 'bi-chevron-left' : 'bi-chevron-right'
97
97
  @navbar = Navbar.new(Current.user)
98
98
 
99
- if Rollbar.configuration.enabled && Rails.application.credentials.rollbar.present?
99
+ if defined?(Rollbar) && Rollbar.configuration.enabled && Rails.application.credentials.rollbar.present?
100
100
  @rollbar_token = Rails.application.credentials.rollbar.access_token_client
101
101
  end
102
102
 
@@ -1,5 +1,15 @@
1
1
  module PgEngine
2
2
  class DeviseController < ApplicationController
3
+ prepend_before_action only: :create do
4
+ rate_limiting(
5
+ to: 10,
6
+ within: 1.hour,
7
+ by: -> { request.remote_ip },
8
+ with: -> { head :too_many_requests },
9
+ store: cache_store
10
+ )
11
+ end
12
+
3
13
  before_action :configure_permitted_parameters
4
14
  before_action do
5
15
  @no_main_frame = true
@@ -4,6 +4,16 @@
4
4
 
5
5
  module Public
6
6
  class MensajeContactosController < PublicController
7
+ prepend_before_action only: :create do
8
+ rate_limiting(
9
+ to: 3,
10
+ within: 1.hour,
11
+ by: -> { request.remote_ip },
12
+ with: -> { head :too_many_requests },
13
+ store: cache_store
14
+ )
15
+ end
16
+
7
17
  include PgEngine::Resource
8
18
 
9
19
  self.clase_modelo = MensajeContacto
@@ -1,3 +1,4 @@
1
+ if defined? ActiveAdmin
1
2
  class MyAdapter < ActiveAdmin::AuthorizationAdapter
2
3
  def authorized?(action, subject = nil)
3
4
  user.developer?
@@ -356,3 +357,4 @@ ActiveAdmin.setup do |config|
356
357
  #
357
358
  # config.use_webpacker = true
358
359
  end
360
+ end
@@ -1,3 +1,4 @@
1
+ if defined? Rollbar
1
2
  Rollbar.configure do |config|
2
3
  # Without configuration, Rollbar is enabled in all environments.
3
4
  # To disable in specific environments, set config.enabled=false.
@@ -89,3 +90,4 @@ Rollbar.configure do |config|
89
90
  acceptable_levels.include?(item[:level].to_sym) ? 'gogoogogooo' : 'ignored'
90
91
  end
91
92
  end
93
+ end
@@ -1,4 +1,5 @@
1
1
  Rails.autoloaders.main.ignore(
2
+ "#{Rails.root}/app/admin",
2
3
  "#{PgEngine::Engine.root}/app/admin",
3
4
  "#{PgEngine::Engine.root}/app/assets",
4
5
  "#{PgEngine::Engine.root}/app/javascript",
@@ -35,7 +35,9 @@ Rails.application.routes.draw do
35
35
  pg_resource(:user_accounts)
36
36
  get 'login_as', to: 'users#login_as'
37
37
  end
38
- ActiveAdmin.routes(self)
38
+ if defined? ActiveAdmin
39
+ ActiveAdmin.routes(self)
40
+ end
39
41
  end
40
42
 
41
43
  # Prefix Verb URI Pattern Controller#Action
@@ -28,7 +28,7 @@ module PgEngine
28
28
  initializer 'pg_engine.set_factory_paths', after: 'factory_bot.set_factory_paths' do
29
29
  # Para que tome las factories de pg_engine/spec/factories
30
30
  # además de las de dummy/spec/factories
31
- FactoryBot.definition_file_paths << "#{root}/spec/factories"
31
+ FactoryBot.definition_file_paths << "#{root}/spec/factories" if defined? FactoryBot
32
32
  end
33
33
 
34
34
  initializer 'configurar_pg_rails' do
@@ -35,14 +35,12 @@ require 'discard'
35
35
  require 'audited'
36
36
  require 'pundit'
37
37
  require 'dotenv-rails'
38
- require 'faker'
39
38
  require 'puma'
40
39
  require 'rollbar'
41
40
  require 'sprockets/rails'
42
41
  require 'jsbundling-rails'
43
42
  require 'cssbundling-rails'
44
43
  require 'turbo-rails'
45
- require 'activeadmin'
46
44
  require 'sassc'
47
45
  require 'image_processing'
48
46
  require 'hashid/rails'
@@ -52,6 +50,7 @@ require 'mailgun-ruby'
52
50
  require 'pg_search'
53
51
  require 'view_component'
54
52
  require 'noticed'
53
+ require 'ransack'
55
54
  require 'ransack_memory'
56
55
  require 'holidays'
57
56
 
@@ -74,6 +73,7 @@ if Rails.env.local?
74
73
  # require 'spring-commands-rspec'
75
74
  require 'rspec-rails'
76
75
  require 'factory_bot_rails'
76
+ require 'faker'
77
77
  require 'rails-controller-testing'
78
78
  end
79
79
 
@@ -31,7 +31,7 @@ document.addEventListener('turbo:before-fetch-request', (ev) => {
31
31
  // on successful redirect no haya posibilidad de que se abra un modal
32
32
  // FIXME: buscar una manera mejor de hacerlo porque es para problemas
33
33
  // quizás, con la movida de abrir modales desde JS
34
- if (ev.detail.fetchOptions.method === 'post') {
34
+ if (ev.detail.fetchOptions.method.toLowerCase() === 'post') {
35
35
  ev.detail.fetchOptions.headers.Accept = 'text/html, application/xhtml+xml'
36
36
  }
37
37
 
@@ -3,8 +3,9 @@
3
3
 
4
4
  import './set_consumer'
5
5
  import './progress_bar'
6
-
7
6
  import '@hotwired/turbo-rails'
7
+ import { flashMessage } from 'pg_rails/utils'
8
+ import Rollbar from 'rollbar'
8
9
 
9
10
  // TODO: testear con capybara
10
11
  document.addEventListener('turbo:before-cache', () => {
@@ -22,6 +23,25 @@ document.addEventListener('turbo:before-cache', () => {
22
23
  })
23
24
  })
24
25
 
26
+ document.addEventListener('turbo:frame-missing', (ev) => {
27
+ Rollbar.error('Turbo Frame missing')
28
+ ev.preventDefault()
29
+ const html = `
30
+ <div>
31
+ <div class="mb-1">
32
+ Ocurrió algo inesperado
33
+ </div>
34
+ Por favor, intentá nuevamente
35
+ <br>
36
+ o <a class="text-decoration-underline" href="/contacto" data-turbo="false">dejá un mensaje</a>
37
+ para que te avisemos
38
+ <br>
39
+ cuando el problema esté resuelto 🙏
40
+ </div>
41
+ `
42
+
43
+ flashMessage(html, 'alert')
44
+ })
25
45
  // document.addEventListener('turbo:before-stream-render', function () { console.log('turbo:before-stream-render') })
26
46
  // document.addEventListener('turbo:render', function () { console.log('turbo:render') })
27
47
  // document.addEventListener('turbo:before-render', function () { console.log('turbo:before-render') })
@@ -28,7 +28,8 @@ html
28
28
  meta name="cable-history-timestamp" content="#{Time.now.to_i}"
29
29
  = csrf_meta_tags
30
30
  = csp_meta_tag
31
- = action_cable_with_jwt_meta_tag
31
+ - if defined? Anycable
32
+ = action_cable_with_jwt_meta_tag
32
33
 
33
34
  = stylesheet_link_tag 'application', 'data-turbo-track': 'reload'
34
35
  = javascript_include_tag 'application', 'data-turbo-track': 'reload', type: 'module'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.3.4'
4
+ VERSION = '7.4.0'
5
5
  end
@@ -1,15 +1,17 @@
1
1
  module PgScaffold
2
2
  class Railtie < ::Rails::Railtie
3
3
  initializer 'configurar_generators', after: 'factory_bot.set_fixture_replacement' do
4
- require_relative 'monkey_patches/mejoras_de_atributos'
5
- require_relative 'monkey_patches/mejoras_a_named_base'
4
+ unless Rails.env.production?
5
+ require_relative 'monkey_patches/mejoras_de_atributos'
6
+ require_relative 'monkey_patches/mejoras_a_named_base'
6
7
 
7
- config.app_generators do |g|
8
- g.test_framework :pg_rspec
9
- g.orm :pg_active_record
8
+ config.app_generators do |g|
9
+ g.test_framework :pg_rspec
10
+ g.orm :pg_active_record
10
11
 
11
- g.fallbacks[:pg_rspec] = :rspec
12
- g.fallbacks[:pg_active_record] = :active_record
12
+ g.fallbacks[:pg_rspec] = :rspec
13
+ g.fallbacks[:pg_active_record] = :active_record
14
+ end
13
15
  end
14
16
  end
15
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.4
4
+ version: 7.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-30 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails