]> git.openstreetmap.org Git - rails.git/blob - test/models/issue_test.rb
Merge branch 'master' into moderation
[rails.git] / test / models / issue_test.rb
1 require "test_helper"
2
3 class IssueTest < ActiveSupport::TestCase
4   def test_reported_user
5     note = create(:note_comment, :author => create(:user)).note
6     user = create(:user)
7     create(:language, :code => "en")
8     diary_entry = create(:diary_entry)
9     issue = Issue.new
10
11     issue.reportable = user
12     issue.save!
13     assert_equal issue.reported_user, user
14
15     # FIXME: doesn't handle anonymous notes
16     issue.reportable = note
17     issue.save!
18     assert_equal issue.reported_user, note.author
19
20     issue.reportable = diary_entry
21     issue.save!
22     assert_equal issue.reported_user, diary_entry.user
23   end
24
25   def test_default_assigned_role
26     create(:language, :code => "en")
27     diary_entry = create(:diary_entry)
28     note = create(:note_with_comments)
29
30     issue = Issue.new
31     issue.reportable = diary_entry
32     issue.save!
33     assert_equal "administrator", issue.assigned_role
34
35     issue = Issue.new
36     issue.reportable = note
37     issue.save!
38     assert_equal "moderator", issue.assigned_role
39
40     # check the callback doesn't override an explicitly set role
41     issue.assigned_role = "administrator"
42     issue.save!
43     issue.reload
44     assert_equal "administrator", issue.assigned_role
45   end
46 end