Sha256: c381f71a62f5698dd851c34f121bf8a42110e24b5d3590d1216baec92b6f8be5

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

class TablelessTest < Minitest::Test
  def test_find_all
    assert FileModel.all.to_a.empty?
  end

  def test_where
    assert FileModel.where(name: 'file').to_a.empty?
  end

  def test_where_using_assoc
    assert FileModel.includes(:person).where(people: {name: 'Name'}).to_a.empty?
  end

  def test_count
    assert_equal 0, FileModel.count
  end

  def test_find_by_id
    assert_raises ActiveRecord::RecordNotFound do
      FileModel.find('filename')
    end
  end

  def test_find_with_association
    assert Person.new.files.empty?
    @person = Person.new
    @person.save(validate: false)
    assert !@person.files.empty?
    assert @person.files.all.exists?
    assert_equal @person.id, @person.files.first.person_id
  end

  def test_tableless_assoc_with_dependent
    @person = Person.new
    @person.save(validate: false)
    assert @person.destroy
  end

  def test_find_with_through_association
    assert Building.new.files.empty?
    @building = Building.new
    @building.save(validate: false)
    assert @building.files.empty?
    assert_equal [], @building.files.to_a
  end

  def test_new
    assert FileModel.new
  end

  def test_association
    assert FileModel.new.person.nil?
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
active_scaffold-3.7.12 test/misc/tableless_test.rb
active_scaffold-3.7.11.1 test/misc/tableless_test.rb
active_scaffold-3.7.11 test/misc/tableless_test.rb
active_scaffold-3.7.10 test/misc/tableless_test.rb
active_scaffold-3.7.8 test/misc/tableless_test.rb
active_scaffold-3.7.7 test/misc/tableless_test.rb
active_scaffold-3.7.6 test/misc/tableless_test.rb
active_scaffold-3.7.5 test/misc/tableless_test.rb
active_scaffold-3.7.2 test/misc/tableless_test.rb
active_scaffold-3.7.1 test/misc/tableless_test.rb
active_scaffold-3.7.0 test/misc/tableless_test.rb