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 +4 -4
- data/pg_engine/app/components/page_not_found_component.rb +18 -0
- data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +2 -0
- data/pg_engine/app/controllers/pg_engine/base_controller.rb +10 -0
- data/pg_engine/config/routes.rb +5 -0
- data/pg_engine/lib/pg_engine/engine.rb +4 -0
- data/pg_engine/lib/pg_engine/error.rb +3 -0
- data/pg_engine/spec/components/alert_component_spec.rb +1 -1
- data/pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb +19 -0
- data/pg_engine/spec/controllers/pg_engine/base_controller_spec.rb +1 -1
- data/pg_engine/spec/requests/base_controller_requests_spec.rb +12 -1
- data/pg_engine/spec/system/alerts_spec.rb +1 -1
- data/pg_engine/spec/system/send_mail_spec.rb +1 -1
- data/pg_rails/lib/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eec38e939cd0d6ff81cd8cdf6d90eab6ea2e9ad52e0ac2a037f72708912430b
|
4
|
+
data.tar.gz: f2a4a37206c8593891d74bfc24f2928ee4698f23b1ca89c5e71cf21515e0f486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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
|
data/pg_engine/config/routes.rb
CHANGED
@@ -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
|
@@ -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)
|
@@ -1,6 +1,17 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
|
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
|
|
data/pg_rails/lib/version.rb
CHANGED
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.
|
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-
|
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
|