Sha256: 50dc1f6694c5d7e2b8637487b31221efa38bfe746197f52908c68bf112b94e8b

Contents?: true

Size: 1009 Bytes

Versions: 2

Compression:

Stored size: 1009 Bytes

Contents

require 'spec_helper'

describe 'table relations', type: :request do

  before do
    class RelTest < Tableless
      column :league_id, :integer
      column :division_id, :integer, nil, false
      column :player_id, :integer
      belongs_to :league
      belongs_to :division
      belongs_to :player
      validates_numericality_of(:player_id, only_integer: true)
    end
    @fields = RailsAdmin.config(RelTest).create.fields
  end

  describe 'column with nullable fk and no model validations' do
    it 'is optional' do
      expect(@fields.detect { |f| f.name == :league }.required?).to be_falsey
    end
  end

  describe 'column with non-nullable fk and no model validations' do
    it 'is not required' do
      expect(@fields.detect { |f| f.name == :division }.required?).to be_falsey
    end
  end

  describe 'column with nullable fk and a numericality model validation' do
    it 'is required' do
      expect(@fields.detect { |f| f.name == :player }.required?).to be_truthy
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_admin-0.6.4 spec/integration/relation_spec.rb
rails_admin-0.6.3 spec/integration/relation_spec.rb