class FoxyFixturesTest

Constants

TIMESTAMP_COLUMNS

Public Instance Methods

test_automatically_sets_primary_key() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 915
def test_automatically_sets_primary_key
  assert_not_nil(ships(:black_pearl))
end
test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 882
def test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false
  TIMESTAMP_COLUMNS.each do |property|
    assert_nil(ships(:black_pearl).send(property), "should not set #{property}")
  end
end
test_generates_unique_ids() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 910
def test_generates_unique_ids
  assert_not_nil(parrots(:george).id)
  assert_not_equal(parrots(:george).id, parrots(:louis).id)
end
test_identifies_consistently() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 866
def test_identifies_consistently
  assert_equal 207281424, ActiveRecord::FixtureSet.identify(:ruby)
  assert_equal 1066363776, ActiveRecord::FixtureSet.identify(:sapphire_2)

  assert_equal "f92b6bda-0d0d-5fe1-9124-502b18badded", ActiveRecord::FixtureSet.identify(:daddy, :uuid)
  assert_equal "b4b10018-ad47-595d-b42f-d8bdaa6d01bf", ActiveRecord::FixtureSet.identify(:sonny, :uuid)
end
test_identifies_strings() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 857
def test_identifies_strings
  assert_equal(ActiveRecord::FixtureSet.identify("foo"), ActiveRecord::FixtureSet.identify("foo"))
  assert_not_equal(ActiveRecord::FixtureSet.identify("foo"), ActiveRecord::FixtureSet.identify("FOO"))
end
test_identifies_symbols() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 862
def test_identifies_symbols
  assert_equal(ActiveRecord::FixtureSet.identify(:foo), ActiveRecord::FixtureSet.identify(:foo))
end
test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 927
def test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same
  assert_equal(developers(:david), computers(:workstation).developer)
end
test_namespaced_models() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 995
def test_namespaced_models
  assert_includes admin_accounts(:signals37).users, admin_users(:david)
  assert_equal 2, admin_accounts(:signals37).users.size
end
test_only_generates_a_pk_if_necessary() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 978
def test_only_generates_a_pk_if_necessary
  m = Matey.first
  m.pirate = pirates(:blackbeard)
  m.target = pirates(:redbeard)
end
test_only_populates_columns_that_exist() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 900
def test_only_populates_columns_that_exist
  assert_not_nil(pirates(:blackbeard).created_on)
  assert_not_nil(pirates(:blackbeard).updated_on)
end
test_populates_all_columns_with_the_same_time() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 888
def test_populates_all_columns_with_the_same_time
  last = nil

  TIMESTAMP_COLUMNS.each do |property|
    current = parrots(:george).send(property)
    last ||= current

    assert_equal(last, current)
    last = current
  end
end
test_populates_timestamp_columns() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 876
def test_populates_timestamp_columns
  TIMESTAMP_COLUMNS.each do |property|
    assert_not_nil(parrots(:george).send(property), "should set #{property}")
  end
end
test_preserves_existing_fixture_data() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 905
def test_preserves_existing_fixture_data
  assert_equal(2.weeks.ago.to_date, pirates(:redbeard).created_on.to_date)
  assert_equal(2.weeks.ago.to_date, pirates(:redbeard).updated_on.to_date)
end
test_preserves_existing_primary_key() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 919
def test_preserves_existing_primary_key
  assert_equal(2, ships(:interceptor).id)
end
test_resolves_belongs_to_symbols() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 923
def test_resolves_belongs_to_symbols
  assert_equal(parrots(:george), pirates(:blackbeard).parrot)
end
test_resolves_enums() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 1000
def test_resolves_enums
  assert books(:awdr).published?
  assert books(:awdr).read?
  assert books(:rfr).proposed?
  assert books(:ddd).published?
end
test_strips_DEFAULTS_key() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 954
def test_strips_DEFAULTS_key
  assert_raise(StandardError) { parrots(:DEFAULTS) }

  # this lets us do YAML defaults and not have an extra fixture entry
  %w(sapphire ruby).each { |t| assert(parrots(:davey).treasures.include?(treasures(t))) }
end
test_supports_inline_habtm() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 937
def test_supports_inline_habtm
  assert(parrots(:george).treasures.include?(treasures(:diamond)))
  assert(parrots(:george).treasures.include?(treasures(:sapphire)))
  assert(!parrots(:george).treasures.include?(treasures(:ruby)))
end
test_supports_inline_habtm_with_specified_id() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 943
def test_supports_inline_habtm_with_specified_id
  assert(parrots(:polly).treasures.include?(treasures(:ruby)))
  assert(parrots(:polly).treasures.include?(treasures(:sapphire)))
  assert(!parrots(:polly).treasures.include?(treasures(:diamond)))
end
test_supports_join_tables() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 931
def test_supports_join_tables
  assert(pirates(:blackbeard).parrots.include?(parrots(:george)))
  assert(pirates(:blackbeard).parrots.include?(parrots(:louis)))
  assert(parrots(:george).pirates.include?(pirates(:blackbeard)))
end
test_supports_label_interpolation() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 961
def test_supports_label_interpolation
  assert_equal("frederick", parrots(:frederick).name)
end
test_supports_label_interpolation_for_integer_label() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 969
def test_supports_label_interpolation_for_integer_label
  assert_equal("#1 pirate!", pirates(1).catchphrase)
end
test_supports_label_string_interpolation() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 965
def test_supports_label_string_interpolation
  assert_equal("X marks the spot!", pirates(:mark).catchphrase)
end
test_supports_polymorphic_belongs_to() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 973
def test_supports_polymorphic_belongs_to
  assert_equal(pirates(:redbeard), treasures(:sapphire).looter)
  assert_equal(parrots(:louis), treasures(:ruby).looter)
end
test_supports_sti() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 984
def test_supports_sti
  assert_kind_of DeadParrot, parrots(:polly)
  assert_equal pirates(:blackbeard), parrots(:polly).killer
end
test_supports_sti_with_respective_files() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 989
def test_supports_sti_with_respective_files
  assert_kind_of LiveParrot, live_parrots(:dusty)
  assert_kind_of DeadParrot, dead_parrots(:deadbird)
  assert_equal pirates(:blackbeard), dead_parrots(:deadbird).killer
end
test_supports_yaml_arrays() click to toggle source
# File activerecord/test/cases/fixtures_test.rb, line 949
def test_supports_yaml_arrays
  assert(parrots(:louis).treasures.include?(treasures(:diamond)))
  assert(parrots(:louis).treasures.include?(treasures(:sapphire)))
end