]> git.openstreetmap.org Git - rails.git/blob - test/models/tracetag_test.rb
Add a system test to do an end-end test of changing email
[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 }, :valid => false)
7     tracetag_valid({ :tag => "" }, :valid => false)
8     tracetag_valid({ :tag => "a" })
9     tracetag_valid({ :tag => "a" * 255 })
10     tracetag_valid({ :tag => "a" * 256 }, :valid => false)
11     tracetag_valid({ :tag => "a/b" }, :valid => false)
12     tracetag_valid({ :tag => "a;b" }, :valid => false)
13     tracetag_valid({ :tag => "a.b" }, :valid => false)
14     tracetag_valid({ :tag => "a,b" }, :valid => false)
15     tracetag_valid({ :tag => "a?b" }, :valid => false)
16   end
17
18   private
19
20   def tracetag_valid(attrs, valid: true)
21     entry = build(:tracetag)
22     entry.assign_attributes(attrs)
23     assert_equal valid, entry.valid?, "Expected #{attrs.inspect} to be #{valid}"
24   end
25 end