]> git.openstreetmap.org Git - rails.git/blob - test/models/issue_test.rb
Merge remote-tracking branch 'upstream/pull/4565'
[rails.git] / test / models / issue_test.rb
1 require "test_helper"
2
3 class IssueTest < ActiveSupport::TestCase
4   def test_assigned_role
5     issue = create(:issue)
6
7     assert_predicate issue, :valid?
8     issue.assigned_role = "bogus"
9     assert_not_predicate issue, :valid?
10   end
11
12   def test_reported_user
13     create(:language, :code => "en")
14     user = create(:user)
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)
19
20     issue = build(:issue, :reportable => user, :assigned_role => "administrator")
21     issue.save!
22     assert_equal issue.reported_user, user
23
24     issue = build(:issue, :reportable => note, :assigned_role => "administrator")
25     issue.save!
26     assert_equal issue.reported_user, note.author
27
28     issue = build(:issue, :reportable => anonymous_note, :assigned_role => "administrator")
29     issue.save!
30     assert_nil issue.reported_user
31
32     issue = build(:issue, :reportable => diary_entry, :assigned_role => "administrator")
33     issue.save!
34     assert_equal issue.reported_user, diary_entry.user
35
36     issue = build(:issue, :reportable => diary_comment, :assigned_role => "administrator")
37     issue.save!
38     assert_equal issue.reported_user, diary_comment.user
39   end
40 end