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

This commit is contained in:
Eric Davis 2011-07-08 12:43:03 -07:00
parent 7c4abeb8d3
commit 1fae552c8f
2 changed files with 13 additions and 1 deletions

View File

@ -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,

View File

@ -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