]> git.openstreetmap.org Git - rails.git/commitdiff
Do not hyperlink profiles of deleted users
authorAditya Prakash <aditya.prakash132@gmail.com>
Mon, 15 Feb 2016 12:58:33 +0000 (18:28 +0530)
committerAditya Prakash <aditya.prakash132@gmail.com>
Mon, 15 Feb 2016 15:17:53 +0000 (20:47 +0530)
app/helpers/changeset_helper.rb
app/helpers/note_helper.rb
test/controllers/changeset_controller_test.rb
test/fixtures/changesets.yml
test/helpers/changeset_helper_test.rb
test/helpers/note_helper_test.rb
test/models/changeset_test.rb

index c3141297ce537c5ebcdfd2fecfd42af928313b21..8d49597f7527fed16670a40710788a82d4b01044 100644 (file)
@@ -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")
index 87bd86f428e4edd7e1e821d84a9840694c8758c7..2eb809572cd51be66eaae9a62d859d30e671a313 100644 (file)
@@ -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
index 4ce264d62dfb4c1f0b0802bdd6269e3e73d70097..5b1dfdbe43afb7c062f5c2f0c975f85199d47c63 100644 (file)
@@ -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"
index 3cfec5bbb089f7c97aed2ec6232bfafa5177d305..2d5ce4e2aaf7703922d081e149555876afdb9d28 100644 (file)
@@ -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
index bf3de4525e2a5a3f5cdfca687ebada03a65b934b..e7ca138b665f1b6348c1db97661356375fe9abeb 100644 (file)
@@ -6,6 +6,7 @@ class ChangesetHelperTest < ActionView::TestCase
   def test_changeset_user_link
     assert_equal "<a href=\"/user/test2\">test2</a>", 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
index eb7b999385fb78268c187c78abf1acf3ced63d92..e946f6f050f31939bd04a8657a651c7a7ece20f1 100644 (file)
@@ -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 "<a href=\"/user/test2\">test2</a>", note_author(users(:public_user))
     assert_equal "<a href=\"http://test.host/user/test2\">test2</a>", note_author(users(:public_user), :only_path => false)
   end
index b4229b20324b164d1959beddb67cbcf1e4754bf4..89200c9b5bfc1dd8a8073d91a49b56c41c9af752 100644 (file)
@@ -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