Merge branch 'master' into next
[rails.git] / test / models / issue_test.rb
index 5af3779b574ba3a1a24cbe855d00d94d20410185..25721295302e28ebdb74e3e1e916ba9b7cc92a8b 100644 (file)
@@ -1,8 +1,17 @@
 require "test_helper"
 
 class IssueTest < ActiveSupport::TestCase
+  def test_assigned_role
+    issue = create(:issue)
+
+    assert issue.valid?
+    issue.assigned_role = "bogus"
+    assert_not issue.valid?
+  end
+
   def test_reported_user
     note = create(:note_comment, :author => create(:user)).note
+    anonymous_note = create(:note_comment, :author => nil).note
     user = create(:user)
     create(:language, :code => "en")
     diary_entry = create(:diary_entry)
@@ -12,11 +21,14 @@ class IssueTest < ActiveSupport::TestCase
     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 = anonymous_note
+    issue.save!
+    assert_nil issue.reported_user
+
     issue.reportable = diary_entry
     issue.save!
     assert_equal issue.reported_user, diary_entry.user