1 # frozen_string_literal: true
5 class RedactionTest < ActiveSupport::TestCase
6 def test_cannot_redact_current
9 assert_not_predicate(n, :redacted?, "Expected node to not be redacted already.")
10 assert_raise(OSM::APICannotRedactError) do
15 def test_cannot_redact_current_via_old
16 node = create(:node, :with_history)
17 node_v1 = node.old_nodes.find_by(:version => 1)
18 r = create(:redaction)
19 assert_not_predicate(node_v1, :redacted?, "Expected node to not be redacted already.")
20 assert_raise(OSM::APICannotRedactError) do
25 def test_can_redact_old
26 node = create(:node, :with_history, :version => 2)
27 node_v1 = node.old_nodes.find_by(:version => 1)
28 node_v2 = node.old_nodes.find_by(:version => 2)
29 r = create(:redaction)
31 assert_not_predicate(node_v1, :redacted?, "Expected node to not be redacted already.")
32 assert_nothing_raised do
35 assert_predicate(node_v1, :redacted?, "Expected node version 1 to be redacted after redact! call.")
36 assert_not_predicate(node_v2, :redacted?, "Expected node version 2 to not be redacted after redact! call.")
39 def test_invalid_with_empty_title
40 redaction = build(:redaction, :title => "")
41 assert_not redaction.valid?
42 assert_includes redaction.errors.messages[:title], "can't be blank"
45 def test_invalid_with_empty_description
46 redaction = build(:redaction, :description => "")
47 assert_not redaction.valid?
48 assert_includes redaction.errors.messages[:description], "can't be blank"