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