Commit 1fae552c authored by Eric Davis's avatar Eric Davis

[#467] Fix Journal#journaled to prevent uninitialized constant Journal::Journaled

parent 7c4abeb8
......@@ -23,7 +23,12 @@ class Journal < ActiveRecord::Base
# Make sure each journaled model instance only has unique version ids
validates_uniqueness_of :version, :scope => [:journaled_id, :type]
belongs_to :journaled, :touch => true
# Define a default class_name to prevent `uninitialized constant Journal::Journaled`
# subclasses will be given an actual class name when they are created by aaj
#
# e.g. IssueJournal will get :class_name => 'Issue'
belongs_to :journaled, :touch => true, :class_name => 'Journal'
belongs_to :user
# ActiveRecord::Base#changes is an existing method, so before serializing the +changes+ column,
......
......@@ -94,4 +94,11 @@ class JournalTest < ActiveSupport::TestCase
assert_not_equal start, @issue.reload.updated_on
end
test "accessing #journaled on a Journal should not error (parent class)" do
journal = Journal.new
assert_nothing_raised do
assert_equal nil, journal.journaled
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment