Sha256: 57f94d97403ce31bbe9bf6367ce3fd7eb19c4fb708baf21ac5637aa9def7f34a

Contents?: true

Size: 1.32 KB

Versions: 16

Compression:

Stored size: 1.32 KB

Contents

require 'rails_helper'

describe PgEngine::Resource do
  let(:instancia) { Admin::CategoriaDeCosasController.new }

  describe '#buscar_instancia cuando no existe el record' do
    subject do
      instancia.send(:buscar_instancia)
    end

    let(:request) { double }

    before do
      allow(request).to receive_messages(filtered_parameters: { id: 321 },
                                         parameters: { id: 321 })
      allow(instancia).to receive(:request).and_return(request)
      instancia.set_clase_modelo
    end

    it do
      expect { subject }.to raise_error(PgEngine::PageNotFoundError)
    end
  end

  describe '#buscar_instancia' do
    subject do
      instancia.send(:buscar_instancia)
    end

    let!(:categoria_de_cosa) { create :categoria_de_cosa }
    let(:request) { double }

    before do
      allow(request).to receive_messages(filtered_parameters: { id: categoria_de_cosa.to_param },
                                         parameters: { id: categoria_de_cosa.to_param })
      allow(instancia).to receive(:request).and_return(request)
      instancia.set_clase_modelo
    end

    it do
      allow(CategoriaDeCosa).to receive(:find_by_hashid!)
      subject
      expect(CategoriaDeCosa).to have_received(:find_by_hashid!)
    end

    it do
      expect(subject).to eq categoria_de_cosa
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pg_rails-7.3.0 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.2.3 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.2.2 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.2.1 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.2.0 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.16 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.15 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.14 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.13 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.12 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.11 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.10 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.9 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.8 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.7 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb
pg_rails-7.1.6 pg_engine/spec/controllers/concerns/pg_engine/resource_helper_spec.rb