Create a redactions factory and use for model tests.

This commit is contained in:
Andy Allan 2017-03-15 16:24:39 +00:00
parent 8ccd7364cd
commit 006627789f
2 changed files with 11 additions and 4 deletions

View file

@ -0,0 +1,8 @@
FactoryGirl.define do
factory :redaction do
sequence(:title) { |n| "Redaction #{n}" }
sequence(:description) { |n| "Description of redaction #{n}" }
user
end
end

View file

@ -3,11 +3,10 @@ require "osm"
class RedactionTest < ActiveSupport::TestCase
api_fixtures
fixtures :redactions
def test_cannot_redact_current
n = current_nodes(:node_with_versions)
r = redactions(:example)
r = create(:redaction)
assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
assert_raise(OSM::APICannotRedactError) do
n.redact!(r)
@ -16,7 +15,7 @@ class RedactionTest < ActiveSupport::TestCase
def test_cannot_redact_current_via_old
n = nodes(:node_with_versions_v4)
r = redactions(:example)
r = create(:redaction)
assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
assert_raise(OSM::APICannotRedactError) do
n.redact!(r)
@ -25,7 +24,7 @@ class RedactionTest < ActiveSupport::TestCase
def test_can_redact_old
n = nodes(:node_with_versions_v3)
r = redactions(:example)
r = create(:redaction)
assert_equal(false, n.redacted?, "Expected node to not be redacted already.")
assert_nothing_raised(OSM::APICannotRedactError) do
n.redact!(r)