3 class IssueTest < ActiveSupport::TestCase
8 issue.assigned_role = "bogus"
9 assert_not issue.valid?
12 def test_reported_user
13 create(:language, :code => "en")
15 note = create(:note_comment, :author => create(:user)).note
16 anonymous_note = create(:note_comment, :author => nil).note
17 diary_entry = create(:diary_entry)
18 diary_comment = create(:diary_comment, :diary_entry => diary_entry)
20 issue = Issue.new(:reportable => user)
22 assert_equal issue.reported_user, user
24 issue = Issue.new(:reportable => note)
26 assert_equal issue.reported_user, note.author
28 issue = Issue.new(:reportable => anonymous_note)
30 assert_nil issue.reported_user
32 issue = Issue.new(:reportable => diary_entry)
34 assert_equal issue.reported_user, diary_entry.user
36 issue = Issue.new(:reportable => diary_comment)
38 assert_equal issue.reported_user, diary_comment.user
41 def test_default_assigned_role
42 create(:language, :code => "en")
44 note = create(:note_with_comments)
45 diary_entry = create(:diary_entry)
46 diary_comment = create(:diary_comment, :diary_entry => diary_entry)
48 issue = Issue.new(:reportable => user)
50 assert_equal "administrator", issue.assigned_role
52 issue = Issue.new(:reportable => note)
54 assert_equal "moderator", issue.assigned_role
56 issue = Issue.new(:reportable => diary_entry)
58 assert_equal "administrator", issue.assigned_role
60 issue = Issue.new(:reportable => diary_comment)
62 assert_equal "administrator", issue.assigned_role
65 def test_no_default_explicit_role
66 create(:language, :code => "en")
68 note = create(:note_with_comments)
69 diary_entry = create(:diary_entry)
70 diary_comment = create(:diary_comment, :diary_entry => diary_entry)
72 issue = Issue.new(:reportable => user, :assigned_role => "moderator")
74 assert_equal "moderator", issue.reload.assigned_role
76 issue = Issue.new(:reportable => note, :assigned_role => "administrator")
78 assert_equal "administrator", issue.reload.assigned_role
80 issue = Issue.new(:reportable => diary_entry, :assigned_role => "moderator")
82 assert_equal "moderator", issue.reload.assigned_role
84 issue = Issue.new(:reportable => diary_comment, :assigned_role => "moderator")
86 assert_equal "moderator", issue.reload.assigned_role