]> git.openstreetmap.org Git - rails.git/blob - test/models/redaction_test.rb
Merge remote-tracking branch 'openstreetmap/pull/1495'
[rails.git] / test / models / redaction_test.rb
1 require "test_helper"
2 require "osm"
3
4 class RedactionTest < ActiveSupport::TestCase
5   api_fixtures
6
7   def test_cannot_redact_current
8     n = current_nodes(:node_with_versions)
9     r = create(:redaction)
10     assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
11     assert_raise(OSM::APICannotRedactError) do
12       n.redact!(r)
13     end
14   end
15
16   def test_cannot_redact_current_via_old
17     n = nodes(:node_with_versions_v4)
18     r = create(:redaction)
19     assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
20     assert_raise(OSM::APICannotRedactError) do
21       n.redact!(r)
22     end
23   end
24
25   def test_can_redact_old
26     n = nodes(:node_with_versions_v3)
27     r = create(:redaction)
28     assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
29     assert_nothing_raised(OSM::APICannotRedactError) do
30       n.redact!(r)
31     end
32     assert_equal(true, n.redacted?, "Expected node to be redacted after redact! call.")
33   end
34 end