3 class IssueTest < ActiveSupport::TestCase
8 issue.assigned_role = "bogus"
12 def test_reported_user
13 note = create(:note_comment, :author => create(:user)).note
14 anonymous_note = create(:note_comment, :author => nil).note
16 create(:language, :code => "en")
17 diary_entry = create(:diary_entry)
20 issue.reportable = user
22 assert_equal issue.reported_user, user
24 issue.reportable = note
26 assert_equal issue.reported_user, note.author
28 issue.reportable = anonymous_note
30 assert_nil issue.reported_user
32 issue.reportable = diary_entry
34 assert_equal issue.reported_user, diary_entry.user
37 def test_default_assigned_role
38 create(:language, :code => "en")
39 diary_entry = create(:diary_entry)
40 note = create(:note_with_comments)
43 issue.reportable = diary_entry
45 assert_equal "administrator", issue.assigned_role
48 issue.reportable = note
50 assert_equal "moderator", issue.assigned_role
52 # check the callback doesn't override an explicitly set role
53 issue.assigned_role = "administrator"
56 assert_equal "administrator", issue.assigned_role