Sha256: 76314bb634ea7c6740a80ee896b5343f66fa38dd80c91ec3e22c128f3f18e8d2
Contents?: true
Size: 1.96 KB
Versions: 13
Compression:
Stored size: 1.96 KB
Contents
require 'test_helper' # Test Relation. RelationProxy is tested in its own file. class RelationTest < Zena::Unit::TestCase def test_cannot_create login(:ant) # not an admin relation = Relation.create(:source_role => 'wife', :target_role => 'husband', :source_kpath => 'NRC', :target_kpath => 'NRC', :source_icon => "<img src='/img/user_pink.png'/>", :target_icon => "<img src='/img/user_blue.png'/>") assert relation.new_record? assert_equal 'You do not have the rights to do this.', relation.errors[:base] end def test_cannot_update login(:ant) # not an admin relation = relations(:node_has_tags) assert !relation.update_attributes(:target_kpath => 'NP') assert_equal 'You do not have the rights to do this.', relation.errors[:base] end def test_can_create login(:lion) # admin relation = Relation.create(:source_role => 'wife', :target_role => 'husband', :source_kpath => 'NRC', :target_kpath => 'NRC', :source_icon => "<img src='/img/user_pink.png'/>", :target_icon => "<img src='/img/user_blue.png'/>") assert !relation.new_record? assert_equal sites_id(:zena), relation[:site_id] end def test_cannot_set_site_id login(:lion) # admin relation = Relation.create(:source_role => 'wife', :target_role => 'husband', :source_kpath => 'NRC', :target_kpath => 'NRC', :source_icon => "<img src='/img/user_pink.png'/>", :target_icon => "<img src='/img/user_blue.png'/>", :site_id => sites_id(:ocean)) assert !relation.new_record? assert_equal sites_id(:zena), relation[:site_id] end def test_set_site_id login(:lion) # admin relation = relations(:node_has_tags) original_site_id = relation.site_id relation.update_attributes(:site_id => 1234) assert_equal original_site_id, relation.site_id end def test_can_update login(:lion) # admin relation = relations(:node_has_tags) assert relation.update_attributes(:target_kpath => 'NP') assert_equal 'NP', relation.target_kpath end end
Version data entries
13 entries across 13 versions & 1 rubygems