Sha256: eaa250715b00257c67bb55d03d8aaaf5fad5a28cdacce8d2037ce5af4aec448b
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'test_helper' class AssociationsTest < Test::Unit::TestCase context "A model's change" do setup do @user = User.create(:name => 'Steve Richert') end should 'add a version when an has_many associations is added' do project = Project.create(:name => 'Versioned Associations') old_version_count = @user.versions.size @user.user_projects.create!(:project => project) @user.reload #needed for now, not sure how to get this object to reload it's versions after the after_save callback on the associated object assert_equal(old_version_count + 1, @user.versions.size) end should 'add a version when an has_many associations is removed' do project = Project.create(:name => 'Versioned Associations') user_project = @user.user_projects.create!(:project => project) @user.reload old_version_count = @user.versions.size @user.user_projects.delete(user_project) @user.reload assert_equal(old_version_count + 1, @user.versions.size) end should 'add a version when an has_many_through association is added and the :through relationship is versioned' do old_version_count = @user.versions.size @user.projects.create!(:name => 'Versioned Associations') @user.reload assert_equal(old_version_count + 1, @user.versions.size) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
andoq-vestal_versions-0.6.1 | test/associations_test.rb |