Sha256: 04d9e36925bfe9de9032814c7a3a20aa33d40c7cbae4f99a7fe604fc46495129
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require 'assert' require 'mr/factory/record_stack' require 'test/support/setup_test_db' require 'test/support/models/comment' class MR::Factory::RecordStack class SystemTests < DbTests desc "MR::Factory::RecordStack" setup do @comment_record = CommentRecord.new(:parent_type => 'UserRecord') @factory_config = MR::Factory::RecordFactory::Config.new(@comment_record.class) @record_stack = MR::Factory::RecordStack.for_record( @comment_record, @factory_config ) end subject{ @record_stack } should "build an instance of the model with all " \ "belongs to associations set" do assert_instance_of CommentRecord, @comment_record assert_true @comment_record.new_record? assert_instance_of UserRecord, @comment_record.parent assert_true @comment_record.parent.new_record? assert_instance_of AreaRecord, @comment_record.parent.area assert_true @comment_record.parent.area.new_record? end should "be able to create all the records and set foreign keys" do assert_nothing_raised{ subject.create } assert_false @comment_record.new_record? assert_false @comment_record.parent.new_record? assert_equal @comment_record.parent.id, @comment_record.parent_id assert_false @comment_record.parent.area.new_record? assert_equal @comment_record.parent.area_id, @comment_record.parent.area.id end should "be able to destroy all the records" do subject.create assert_nothing_raised{ subject.destroy } assert_true @comment_record.destroyed? assert_true @comment_record.parent.destroyed? assert_true @comment_record.parent.area.destroyed? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mr-0.35.2 | test/system/factory/record_stack_tests.rb |