]> git.openstreetmap.org Git - rails.git/blob - test/models/tracetag_test.rb
Refactor remaining relation model tests to use factories.
[rails.git] / test / models / tracetag_test.rb
1 require "test_helper"
2
3 class TracetagTest < ActiveSupport::TestCase
4   def test_validations
5     tracetag_valid({})
6     tracetag_valid({ :tag => nil }, false)
7     tracetag_valid({ :tag => "" }, false)
8     tracetag_valid(:tag => "a")
9     tracetag_valid(:tag => "a" * 255)
10     tracetag_valid({ :tag => "a" * 256 }, false)
11     tracetag_valid({ :tag => "a/b" }, false)
12     tracetag_valid({ :tag => "a;b" }, false)
13     tracetag_valid({ :tag => "a.b" }, false)
14     tracetag_valid({ :tag => "a,b" }, false)
15     tracetag_valid({ :tag => "a?b" }, false)
16   end
17
18   private
19
20   def tracetag_valid(attrs, result = true)
21     entry = build(:tracetag)
22     entry.assign_attributes(attrs)
23     assert_equal result, entry.valid?, "Expected #{attrs.inspect} to be #{result}"
24   end
25 end