Sha256: db69eac1f5e032f46ca9ad4af10cae6012a0e032610b459a12ec80fa2b7146f1
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require "abstract_unit" require "fixtures/person" require "fixtures/beast" require "fixtures/customer" class ActiveResource::Associations::Builder::BelongsToTest < ActiveSupport::TestCase def setup @klass = ActiveResource::Associations::Builder::BelongsTo end def test_validations_for_instance object = @klass.new(Person, :customer, {}) assert_equal({}, object.send(:validate_options)) end def test_instance_build object = @klass.new(Person, :customer, {}) Person.expects(:defines_belongs_to_finder_method).with(kind_of(ActiveResource::Reflection::AssociationReflection)) reflection = object.build assert_kind_of ActiveResource::Reflection::AssociationReflection, reflection assert_equal :customer, reflection.name assert_equal Customer, reflection.klass assert_equal "customer_id", reflection.foreign_key end def test_valid_options assert @klass.build(Person, :customer, class_name: "Person") assert @klass.build(Person, :customer, foreign_key: "person_id") assert_raise ArgumentError do @klass.build(Person, :customer, soo_invalid: true) end end end
Version data entries
2 entries across 2 versions & 1 rubygems