From: Aditya Prakash Date: Mon, 15 Feb 2016 12:58:33 +0000 (+0530) Subject: Do not hyperlink profiles of deleted users X-Git-Tag: live~4461^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/341f6cd9feed774f0abdb337f36272d5ecc92549?hp=be624d64f395c40a78249754825cecdd9b050398 Do not hyperlink profiles of deleted users --- diff --git a/app/helpers/changeset_helper.rb b/app/helpers/changeset_helper.rb index c3141297c..8d49597f7 100644 --- a/app/helpers/changeset_helper.rb +++ b/app/helpers/changeset_helper.rb @@ -1,6 +1,6 @@ module ChangesetHelper def changeset_user_link(changeset) - if changeset.user.data_public? + if changeset.user.status != "deleted" && changeset.user.data_public? link_to(changeset.user.display_name, user_path(changeset.user.display_name)) else t("browse.anonymous") diff --git a/app/helpers/note_helper.rb b/app/helpers/note_helper.rb index 87bd86f42..2eb809572 100644 --- a/app/helpers/note_helper.rb +++ b/app/helpers/note_helper.rb @@ -17,6 +17,8 @@ module NoteHelper def note_author(author, link_options = {}) if author.nil? "" + elsif author.status == "deleted" + t("browse.anonymous") else link_to h(author.display_name), link_options.merge(:controller => "user", :action => "view", :display_name => author.display_name) end diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index 4ce264d62..5b1dfdbe4 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -1574,7 +1574,7 @@ EOF get :query, :closed => "true" assert_response :success, "can't get changesets by closed-ness" - assert_changesets [3, 5, 6, 7, 8] + assert_changesets [3, 5, 6, 7, 8, 9] get :query, :closed => "true", :user => users(:normal_user).id assert_response :success, "can't get changesets by closed-ness and user" diff --git a/test/fixtures/changesets.yml b/test/fixtures/changesets.yml index 3cfec5bbb..2d5ce4e2a 100644 --- a/test/fixtures/changesets.yml +++ b/test/fixtures/changesets.yml @@ -21,6 +21,13 @@ public_user_first_change: closed_at: <%= Time.now.utc + 86400 %> num_changes: 0 +deleted_user_first_change: + id: 9 + user_id: 11 + created_at: "2007-01-01 00:00:00" + closed_at: "2007-01-02 00:00:00" + num_changes: 0 + normal_user_closed_change: id: 3 user_id: 1 diff --git a/test/helpers/changeset_helper_test.rb b/test/helpers/changeset_helper_test.rb index bf3de4525..e7ca138b6 100644 --- a/test/helpers/changeset_helper_test.rb +++ b/test/helpers/changeset_helper_test.rb @@ -6,6 +6,7 @@ class ChangesetHelperTest < ActionView::TestCase 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 "anonymous", changeset_user_link(changesets(:deleted_user_first_change)) end def test_changeset_details diff --git a/test/helpers/note_helper_test.rb b/test/helpers/note_helper_test.rb index eb7b99938..e946f6f05 100644 --- a/test/helpers/note_helper_test.rb +++ b/test/helpers/note_helper_test.rb @@ -15,6 +15,7 @@ class NoteHelperTest < ActionView::TestCase def test_note_author assert_equal "", note_author(nil) + assert_equal "anonymous", note_author(users(:deleted_user)) assert_equal "test2", note_author(users(:public_user)) assert_equal "test2", note_author(users(:public_user), :only_path => false) end diff --git a/test/models/changeset_test.rb b/test/models/changeset_test.rb index b4229b203..89200c9b5 100644 --- a/test/models/changeset_test.rb +++ b/test/models/changeset_test.rb @@ -4,7 +4,7 @@ class ChangesetTest < ActiveSupport::TestCase api_fixtures def test_changeset_count - assert_equal 8, Changeset.count + assert_equal 9, Changeset.count end def test_from_xml_no_text