Sha256: 28626c0f11b16318366e07526bd5283b7ac4be1fb2771aefa70eda8c03ad454a
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
require 'test_helper' module Automigration class BelongsTest < ActiveSupport::TestCase include ActionDispatch::Assertions::SelectorAssertions setup do @simple = Simple.create @obj = BelongsToModel.create end teardown do Simple.destroy_all end test "properties" do assert_nil @obj.simple assert_nil @obj.simple_id end test "mass assignment by object" do @obj.update_attributes(:simple => @simple) assert_equal @simple.id, @obj.simple_id end test "mass assignment by id" do @obj.update_attributes(:simple_id => @simple.id) assert_equal @simple.id, @obj.simple_id end test "use different class name" do @obj.update_attributes(:some => @simple) assert_equal @simple, @obj.some end test "raise if wrong name" do assert_raise RuntimeError do Fields::Sys::Base.from_meta( :as => :belongs_to, :name => "simple_id" ) end end test "parent and children" do child = BelongsToModel.find(BelongsToModel.create(:parent => @obj).id) assert_equal @obj, child.parent assert_equal @obj.id, child.parent_id end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
automigration-0.2.2 | test/belongs_to_test.rb |
automigration-0.2.1 | test/belongs_to_test.rb |