3 class RedactionTest < ActiveSupport::TestCase
 
   4   def test_cannot_redact_current
 
   7     assert_not_predicate(n, :redacted?, "Expected node to not be redacted already.")
 
   8     assert_raise(OSM::APICannotRedactError) do
 
  13   def test_cannot_redact_current_via_old
 
  14     node = create(:node, :with_history)
 
  15     node_v1 = node.old_nodes.find_by(:version => 1)
 
  16     r = create(:redaction)
 
  17     assert_not_predicate(node_v1, :redacted?, "Expected node to not be redacted already.")
 
  18     assert_raise(OSM::APICannotRedactError) do
 
  23   def test_can_redact_old
 
  24     node = create(:node, :with_history, :version => 2)
 
  25     node_v1 = node.old_nodes.find_by(:version => 1)
 
  26     node_v2 = node.old_nodes.find_by(:version => 2)
 
  27     r = create(:redaction)
 
  29     assert_not_predicate(node_v1, :redacted?, "Expected node to not be redacted already.")
 
  30     assert_nothing_raised do
 
  33     assert_predicate(node_v1, :redacted?, "Expected node version 1 to be redacted after redact! call.")
 
  34     assert_not_predicate(node_v2, :redacted?, "Expected node version 2 to not be redacted after redact! call.")
 
  37   def test_invalid_with_empty_title
 
  38     redaction = build(:redaction, :title => "")
 
  39     assert_not redaction.valid?
 
  40     assert_includes redaction.errors.messages[:title], "can't be blank"
 
  43   def test_invalid_with_empty_description
 
  44     redaction = build(:redaction, :description => "")
 
  45     assert_not redaction.valid?
 
  46     assert_includes redaction.errors.messages[:description], "can't be blank"