pg_rails 7.0.8.pre.alpha.98 → 7.0.8.pre.alpha.100
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 +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: '0896ed88c290ad3d15d1b4edc18af987081ce34e1a0ae2cbf9e3620b4f217d04'
         | 
| 4 | 
            +
              data.tar.gz: 9fa01a280e302e3f9f5c01edadf6cc5d526637e944b312162fe54c3518219794
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2304afeed57445774e783dd2e14be001b3b732564b7d212cd4fe79f5d26f45a3f770f8b7ca1789e6ce12656c16c228afba2b2c483ea20f53f1c552a2c82aff0e
         | 
| 7 | 
            +
              data.tar.gz: 5212a262a94cf9a81d140cedde07d16e719d5731913c80106265c94c7b1abc2c5719c65face0257381c42252285fb7c3f96c60e4f79d0f9e4119e0d2a51eb2e0
         | 
| @@ -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: 'application#page_not_found'
         | 
| 7 | 
            +
              get '500', to: 'application#internal_error'
         | 
| 8 | 
            +
              get 'internal_error_but_with_status200', to: 'application#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.100
         | 
| 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
         |