[#467] Fix Journal#journaled to prevent uninitialized constant Journal::Journaled
This commit is contained in:
parent
7c4abeb8d3
commit
1fae552c8f
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user