X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/860887de5272c3e2a39cb7e0c9db6f0acba1b4c6..21683db838d66d5b14da08dd5fd467fae09515d4:/test/helpers/changeset_helper_test.rb?ds=sidebyside 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