X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/2af0840ff314f9d1e0265a4a1b50fc6db4af9047..65ff0828172b28559e9c38c0fcba179fc20ff35c:/test/helpers/changeset_helper_test.rb
diff --git a/test/helpers/changeset_helper_test.rb b/test/helpers/changeset_helper_test.rb
index bf3de4525..9c45b62dc 100644
--- a/test/helpers/changeset_helper_test.rb
+++ b/test/helpers/changeset_helper_test.rb
@@ -1,15 +1,27 @@
require "test_helper"
class ChangesetHelperTest < ActionView::TestCase
- fixtures :changesets, :users
-
def test_changeset_user_link
- assert_equal "test2", changeset_user_link(changesets(:public_user_first_change))
- assert_equal "anonymous", changeset_user_link(changesets(:normal_user_first_change))
+ changeset = create(:changeset)
+ assert_equal %(#{changeset.user.display_name}), changeset_user_link(changeset)
+
+ changeset = create(:changeset, :user => create(:user, :data_public => false))
+ assert_equal "anonymous", changeset_user_link(changeset)
+
+ changeset = create(:changeset, :user => create(:user, :deleted))
+ assert_equal "deleted", changeset_user_link(changeset)
end
def test_changeset_details
- assert_match %r{^Created .* by anonymous$}, changeset_details(changesets(:normal_user_first_change))
- assert_match %r{^Closed .* by test2$}, changeset_details(changesets(:public_user_closed_change))
+ changeset = create(:changeset, :created_at => Time.utc(2007, 1, 1, 0, 0, 0), :user => create(:user, :data_public => false))
+ # We need to explicitly reset the closed_at to some point in the future, and avoid the before_save callback
+ changeset.update_column(:closed_at, Time.now.utc + 1.day) # rubocop:disable Rails/SkipsModelValidations
+
+ assert_match %r{^Created .* by anonymous$}, changeset_details(changeset)
+
+ changeset = create(:changeset, :created_at => Time.utc(2007, 1, 1, 0, 0, 0), :closed_at => Time.utc(2007, 1, 2, 0, 0, 0))
+ user_link = %(#{changeset.user.display_name})
+
+ assert_match %r{^Closed .* by #{user_link}$}, changeset_details(changeset)
end
end