]> git.openstreetmap.org Git - rails.git/blob - test/models/issue_test.rb
Set the reported_user in a callback
[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 end