Sha256: 021e80891131e699d1645cef1e5bd9fe31d29f4fda2cc49d0945be5e0e9e032d

Contents?: true

Size: 1.03 KB

Versions: 63

Compression:

Stored size: 1.03 KB

Contents

require 'rails_helper'

describe PgEngine::FormHelper do
  subject do
    view_context.pg_form_for(cosa, **options) do |f|
      f.submit 'ACEPTAR'
    end
  end

  let(:options) do
    {}
  end

  let(:view_context) do
    cont = Admin::CosasController.new
    cont.request = ActionDispatch::TestRequest.create
    cont.view_context
  end
  let(:cosa) { Cosa.new }

  before do
    Current.namespace = :admin
  end

  it 'renders the form and the button' do
    expect(subject).to include 'ACEPTAR'
    expect(subject).to include '<form'
  end

  context 'when there are errors' do
    let(:cosa) do
      ret = Cosa.new(nombre: nil)
      ret.validate
      ret
    end

    it 'renders the errors' do
      expect(subject).to include 'Por favor, revisá los campos obligatorios'
    end

    context 'and its requested not to render errors' do
      let(:options) do
        { render_errors: false }
      end

      it 'renders the errors' do
        expect(subject).not_to include 'Por favor, revisá los campos obligatorios'
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
pg_rails-7.6.21.pre.5 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.21.pre.4 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.21.pre.3 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.21.pre.2 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.21.pre.1 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.20 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.19 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.18 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.17 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.16 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.15 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.14 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.13 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.12 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.11 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.10 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.9 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.8 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.7 pg_engine/spec/lib/pg_engine/form_helper_spec.rb
pg_rails-7.6.6 pg_engine/spec/lib/pg_engine/form_helper_spec.rb