- 'app/models/trace.rb'
- 'app/models/tracepoint.rb'
- 'app/models/way.rb'
- - 'test/models/diary_entry_test.rb'
- - 'test/models/trace_test.rb'
- - 'test/models/tracetag_test.rb'
# Offense count: 28
# Cop supports --auto-correct.
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, true)
+ assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
+ assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
I18n.locale = "pt"
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, true)
+ assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
+ assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
I18n.locale = "pt-BR"
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, true)
+ assert_dom_equal "<bdi>Nó teste</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
+ assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
I18n.locale = "de"
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node)
assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}</bdi>)", printable_name(node_v2)
assert_dom_equal node.id.to_s, printable_name(node_v1)
- assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, true)
- assert_dom_equal "#{node.id}, v1", printable_name(node_v1, true)
+ assert_dom_equal "<bdi>Test Node</bdi> (<bdi>#{node.id}, v2</bdi>)", printable_name(node_v2, :version => true)
+ assert_dom_equal "#{node.id}, v1", printable_name(node_v1, :version => true)
assert_dom_equal "<bdi>3.1415926</bdi> (<bdi>#{node_with_ref_without_name.id}</bdi>)", printable_name(node_with_ref_without_name)
end
def test_diary_entry_validations
diary_entry_valid({})
- diary_entry_valid({ :title => "" }, false)
+ diary_entry_valid({ :title => "" }, :valid => false)
diary_entry_valid(:title => "a" * 255)
- diary_entry_valid({ :title => "a" * 256 }, false)
- diary_entry_valid({ :body => "" }, false)
+ diary_entry_valid({ :title => "a" * 256 }, :valid => false)
+ diary_entry_valid({ :body => "" }, :valid => false)
diary_entry_valid(:latitude => 90)
- diary_entry_valid({ :latitude => 90.00001 }, false)
+ diary_entry_valid({ :latitude => 90.00001 }, :valid => false)
diary_entry_valid(:latitude => -90)
- diary_entry_valid({ :latitude => -90.00001 }, false)
+ diary_entry_valid({ :latitude => -90.00001 }, :valid => false)
diary_entry_valid(:longitude => 180)
- diary_entry_valid({ :longitude => 180.00001 }, false)
+ diary_entry_valid({ :longitude => 180.00001 }, :valid => false)
diary_entry_valid(:longitude => -180)
- diary_entry_valid({ :longitude => -180.00001 }, false)
+ diary_entry_valid({ :longitude => -180.00001 }, :valid => false)
end
def test_diary_entry_visible
private
- def diary_entry_valid(attrs, result = true)
+ def diary_entry_valid(attrs, valid: true)
entry = build(:diary_entry, attrs)
- assert_equal result, entry.valid?, "Expected #{attrs.inspect} to be #{result}"
+ assert_equal valid, entry.valid?, "Expected #{attrs.inspect} to be #{valid}"
end
end
def test_validations
trace_valid({})
- trace_valid({ :user_id => nil }, false)
+ trace_valid({ :user_id => nil }, :valid => false)
trace_valid(:name => "a" * 255)
- trace_valid({ :name => "a" * 256 }, false)
- trace_valid({ :description => nil }, false)
+ trace_valid({ :name => "a" * 256 }, :valid => false)
+ trace_valid({ :description => nil }, :valid => false)
trace_valid(:description => "a" * 255)
- trace_valid({ :description => "a" * 256 }, false)
+ trace_valid({ :description => "a" * 256 }, :valid => false)
trace_valid(:visibility => "private")
trace_valid(:visibility => "public")
trace_valid(:visibility => "trackable")
trace_valid(:visibility => "identifiable")
- trace_valid({ :visibility => "foo" }, false)
+ trace_valid({ :visibility => "foo" }, :valid => false)
end
def test_tagstring
assert_equal md5sum, md5sum(create(:trace, :fixture => id).xml_file)
end
- def trace_valid(attrs, result = true)
+ def trace_valid(attrs, valid: true)
entry = build(:trace, attrs)
- assert_equal result, entry.valid?, "Expected #{attrs.inspect} to be #{result}"
+ assert_equal valid, entry.valid?, "Expected #{attrs.inspect} to be #{valid}"
end
def md5sum(io)
class TracetagTest < ActiveSupport::TestCase
def test_validations
tracetag_valid({})
- tracetag_valid({ :tag => nil }, false)
- tracetag_valid({ :tag => "" }, false)
+ tracetag_valid({ :tag => nil }, :valid => false)
+ tracetag_valid({ :tag => "" }, :valid => false)
tracetag_valid(:tag => "a")
tracetag_valid(:tag => "a" * 255)
- tracetag_valid({ :tag => "a" * 256 }, false)
- tracetag_valid({ :tag => "a/b" }, false)
- tracetag_valid({ :tag => "a;b" }, false)
- tracetag_valid({ :tag => "a.b" }, false)
- tracetag_valid({ :tag => "a,b" }, false)
- tracetag_valid({ :tag => "a?b" }, false)
+ tracetag_valid({ :tag => "a" * 256 }, :valid => false)
+ tracetag_valid({ :tag => "a/b" }, :valid => false)
+ tracetag_valid({ :tag => "a;b" }, :valid => false)
+ tracetag_valid({ :tag => "a.b" }, :valid => false)
+ tracetag_valid({ :tag => "a,b" }, :valid => false)
+ tracetag_valid({ :tag => "a?b" }, :valid => false)
end
private
- def tracetag_valid(attrs, result = true)
+ def tracetag_valid(attrs, valid: true)
entry = build(:tracetag)
entry.assign_attributes(attrs)
- assert_equal result, entry.valid?, "Expected #{attrs.inspect} to be #{result}"
+ assert_equal valid, entry.valid?, "Expected #{attrs.inspect} to be #{valid}"
end
end