pg_rails 7.0.8.pre.alpha.98 → 7.0.8.pre.alpha.99

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: 9c0014c11d92bc7f43c0e78c0548c70b219cfef3feb3a583a0c5c506e28d5159
4
- data.tar.gz: 810494e494d2fd422177237538f72f35f68c0f45c6dbcc9d73319186978e3776
3
+ metadata.gz: 5eec38e939cd0d6ff81cd8cdf6d90eab6ea2e9ad52e0ac2a037f72708912430b
4
+ data.tar.gz: f2a4a37206c8593891d74bfc24f2928ee4698f23b1ca89c5e71cf21515e0f486
5
5
  SHA512:
6
- metadata.gz: e84adee42acd13e15e74c502df44590effbf34aee6c85b11623d4f8d9fa9238b0fb8aa6eaf5d5bd53d597c56591321e2a919a458d8efa7ec4859c84bc0ddb299
7
- data.tar.gz: 491e876d4b9175cb28995bd8b07f8abfb351a805c25c027f0f9a50509c7d5303917447a8b094588d66e7b906f55957cb6e8c1b9d8393913ca50016cf62940628
6
+ metadata.gz: 54e5d70844d9f3b49c9747807ba72a90d764000263497a18e45087ba110d50c5eb090769c1602be21a1705660fefe8f8c0fa8e2ba5916d172c8abb500c88c95e
7
+ data.tar.gz: d40747733ad590ca22b37971ddc724454ec3259422176e50dbec5d7d74168d42600d32586d33e741257bffa6fa2714a40acdba466290519011980c73d0153815
@@ -0,0 +1,18 @@
1
+ class PageNotFoundComponent < BaseComponent
2
+ def alert_wrapped(view_context)
3
+ AlertComponent.new(type: alert_type, dismissible: false)
4
+ .with_content(render_in(view_context))
5
+ end
6
+
7
+ def alert_type
8
+ :warning
9
+ end
10
+
11
+ erb_template <<~ERB
12
+ <div>
13
+ <div class="mb-1">
14
+ La página que buscás no existe
15
+ </div>
16
+ </div>
17
+ ERB
18
+ end
@@ -218,6 +218,8 @@ module PgEngine
218
218
  else
219
219
  @clase_modelo.find(params[:id])
220
220
  end
221
+ rescue ActiveRecord::RecordNotFound
222
+ raise PgEngine::PageNotFoundError
221
223
  end
222
224
 
223
225
  def set_instancia_modelo
@@ -27,6 +27,7 @@ module PgEngine
27
27
  with: :invalid_authenticity_token
28
28
 
29
29
  rescue_from Pundit::NotAuthorizedError, with: :not_authorized
30
+ rescue_from PgEngine::PageNotFoundError, with: :page_not_found
30
31
  rescue_from Redirect do |e|
31
32
  redirect_to e.url
32
33
  end
@@ -43,6 +44,15 @@ module PgEngine
43
44
  render_my_component(BadRequestComponent.new, :bad_request)
44
45
  end
45
46
 
47
+ def page_not_found
48
+ render_my_component(PageNotFoundComponent.new, :not_found)
49
+ end
50
+
51
+ # Para cachear el html y guardarlo en public/500.html
52
+ def internal_error_but_with_status200
53
+ render_my_component(InternalErrorComponent.new, :ok)
54
+ end
55
+
46
56
  before_action do
47
57
  Current.user = current_user
48
58
  end
@@ -2,6 +2,11 @@ include PgEngine::RouteHelpers
2
2
 
3
3
  Rails.application.routes.draw do
4
4
  get "pg_engine/health" => "pg_engine/health#show", as: :pg_engine_health_check
5
+
6
+ get '404', to: 'pg_engine/base#page_not_found'
7
+ get '500', to: 'pg_engine/base#internal_error'
8
+ get 'internal_error_but_with_status200', to: 'pg_engine/base#internal_error_but_with_status200'
9
+
5
10
  namespace :public, path: '' do
6
11
  pg_resource(:mensaje_contactos, only: [:new, :create], path: 'contacto')
7
12
  post 'webhook/mailgun', to: 'webhooks#mailgun'
@@ -13,6 +13,10 @@ module PgEngine
13
13
  g.fallbacks[:pg_active_record] = :active_record
14
14
  end
15
15
 
16
+ initializer 'pg_engine.set_exceptions_app' do
17
+ Rails.application.config.exceptions_app = Rails.application.routes
18
+ end
19
+
16
20
  initializer 'pg_engine.set_factory_paths', after: 'factory_bot.set_factory_paths' do
17
21
  # Para que tome las factories de pg_engine/spec/factories
18
22
  # además de las de dummy/spec/factories
@@ -1,4 +1,7 @@
1
1
  module PgEngine
2
2
  class Error < StandardError
3
3
  end
4
+
5
+ class PageNotFoundError < Error
6
+ end
4
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rails_helper'
4
4
 
5
- RSpec.fdescribe AlertComponent, type: :component do
5
+ RSpec.describe AlertComponent, type: :component do
6
6
  subject do
7
7
  render_inline(alert).to_html
8
8
  end
@@ -3,6 +3,25 @@ require 'rails_helper'
3
3
  describe PgEngine::Resource do
4
4
  let(:instancia) { Admin::CategoriaDeCosasController.new }
5
5
 
6
+ describe '#buscar_instancia cuando no existe el record' do
7
+ subject do
8
+ instancia.send(:buscar_instancia)
9
+ end
10
+
11
+ let(:request) { double }
12
+
13
+ before do
14
+ allow(request).to receive_messages(filtered_parameters: { id: 321 },
15
+ parameters: { id: 321 })
16
+ allow(instancia).to receive(:request).and_return(request)
17
+ instancia.set_clase_modelo
18
+ end
19
+
20
+ fit do
21
+ expect { subject }.to raise_error(PgEngine::PageNotFoundError)
22
+ end
23
+ end
24
+
6
25
  describe '#buscar_instancia' do
7
26
  subject do
8
27
  instancia.send(:buscar_instancia)
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  # rubocop:disable RSpec/FilePath
24
24
  # rubocop:disable RSpec/SpecFilePathFormat
25
- fdescribe DummyBaseController do
25
+ describe DummyBaseController do
26
26
  render_views
27
27
 
28
28
  describe 'PgEngine::BaseController::Redirect' do
@@ -1,6 +1,17 @@
1
1
  require 'rails_helper'
2
2
 
3
- fdescribe 'Base requests' do
3
+ describe 'Base requests' do
4
+ describe 'internal_error_but_with_status200' do
5
+ subject do
6
+ get '/internal_error_but_with_status200'
7
+ end
8
+
9
+ it do
10
+ subject
11
+ expect(response).to have_http_status(:ok)
12
+ end
13
+ end
14
+
4
15
  describe 'invalid authenticity token' do
5
16
  subject { get '/admin/cosas', headers: }
6
17
 
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- fdescribe 'Alertas' do
3
+ describe 'Alertas' do
4
4
  before do
5
5
  driven_by ENV['DRIVER']&.to_sym || :selenium_chrome_headless_iphone
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- fdescribe 'Enviar email' do
3
+ describe 'Enviar email' do
4
4
  include ActiveJob::TestHelper
5
5
 
6
6
  subject do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.98'
4
+ VERSION = '7.0.8-alpha.99'
5
5
  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.0.8.pre.alpha.98
4
+ version: 7.0.8.pre.alpha.99
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-06-13 00:00:00.000000000 Z
11
+ date: 2024-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -991,6 +991,7 @@ files:
991
991
  - pg_engine/app/components/flash_container_component.rb
992
992
  - pg_engine/app/components/internal_error_component.rb
993
993
  - pg_engine/app/components/notification_component.rb
994
+ - pg_engine/app/components/page_not_found_component.rb
994
995
  - pg_engine/app/controllers/admin/accounts_controller.rb
995
996
  - pg_engine/app/controllers/admin/email_logs_controller.rb
996
997
  - pg_engine/app/controllers/admin/emails_controller.rb