]> git.openstreetmap.org Git - rails.git/blobdiff - test/models/issue_test.rb
Merge branch 'master' into moderation
[rails.git] / test / models / issue_test.rb
index 7e15ee90cf51075e5ed3012c5b74fc1cd334b201..7ee700124c7448a84a6bc02fa08a59f66069a6cd 100644 (file)
@@ -1,7 +1,24 @@
 require "test_helper"
 
 class IssueTest < ActiveSupport::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
+  def test_reported_user
+    note = create(:note_comment, :author => create(:user)).note
+    user = create(:user)
+    create(:language, :code => "en")
+    diary_entry = create(:diary_entry)
+    issue = Issue.new
+
+    issue.reportable = user
+    issue.save!
+    assert_equal issue.reported_user, user
+
+    # FIXME: doesn't handle anonymous notes
+    issue.reportable = note
+    issue.save!
+    assert_equal issue.reported_user, note.author
+
+    issue.reportable = diary_entry
+    issue.save!
+    assert_equal issue.reported_user, diary_entry.user
+  end
 end