3 class NodeTagTest < ActiveSupport::TestCase
6 def test_length_key_valid
7 tag = create(:node_tag)
14 def test_length_value_valid
15 tag = create(:node_tag)
22 def test_length_key_invalid
23 tag = create(:node_tag)
25 assert !tag.valid?, "Key should be too long"
26 assert tag.errors[:k].any?
29 def test_length_value_invalid
30 tag = create(:node_tag)
32 assert !tag.valid?, "Value should be too long"
33 assert tag.errors[:v].any?
36 def test_empty_node_tag_invalid
38 assert !tag.valid?, "Empty tag should be invalid"
39 assert tag.errors[:node].any?
43 existing = create(:node_tag)
45 tag.node_id = existing.node_id
48 assert tag.new_record?
50 assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
51 assert tag.new_record?