X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/043d29fd7eb72048cf5d07edfbc20ec5c25af708..d593d3d2dd6986aa07f5d5268d3e0d7b808590db:/test/helpers/changeset_helper_test.rb diff --git a/test/helpers/changeset_helper_test.rb b/test/helpers/changeset_helper_test.rb index 8342f99d2..d932138f8 100644 --- a/test/helpers/changeset_helper_test.rb +++ b/test/helpers/changeset_helper_test.rb @@ -1,16 +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)) - assert_equal "deleted", changeset_user_link(changesets(:deleted_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