Virtual Domain extension for mental

I’ve updated the Virtual Domain behavior to be a page type in
mental. I’ve uploaded a tar.gz for people to try (I don’t have svn
on my server and don’t feel the need to set it up for thist):

http://silverinsanity.com/~benji/virtual_domain.tar.gz

Should work near identically to the original, except that it works on
mental of course. Be sure to read the README for instructions on how
to install the needed patch to Radiant.

If anyone could figure out why I’m getting the following error in two
of the tests, I’d appreciate it:

ArgumentError: vendor/rails/activesupport/lib/active_support/
dependencies.rb:399:in `to_constant_name’: Anonymous modules have no
name to be referenced by

~~ Brian

On Dec 14, 2006, at 9:59 PM, Brian G. wrote:

ArgumentError: vendor/rails/activesupport/lib/active_support/
dependencies.rb:399:in `to_constant_name’: Anonymous modules have no
name to be referenced by

This happens, I think, when there is an undefined constant referenced
in a method. Could you please indicate which two tests you are seeing
this in? Is it when your behavior is installed only?

aiwilliams

On Dec 15, 2006, at 9:17 AM, Adam W. wrote:

On Dec 14, 2006, at 9:59 PM, Brian G. wrote:

ArgumentError: vendor/rails/activesupport/lib/active_support/
dependencies.rb:399:in `to_constant_name’: Anonymous modules have no
name to be referenced by

This happens, I think, when there is an undefined constant referenced
in a method. Could you please indicate which two tests you are seeing
this in? Is it when your behavior is installed only?

It’s in the tests for VirtualDomainPage in the plugin (mostly
unchanged from the tests for VirtualDomainBehavior). Specifically,
it’s from:

virtual_domain_page_test.rb:88:in `test_default_sitemap’
default_map = @page.children.inject({}) { |memo, page| memo
[page.slug] = page.slug; memo }

virtual_domain_page_test.rb:42:in
`test_find_first_child_for_no_config_unknown_host’
assert_equal @page.children.find(:all).find { |child|
child.published?}, Page.find_by_url("/")

As far as I can tell from mucking with the code, I get the error any
time I call any method on @page.children, where @page is a
VirtualDomainPage. But, thankfully, only in the tests. (The
extension works properly, AFAICT.)

~~ Brian

On Dec 15, 2006, at 9:55 AM, Brian G. wrote:

As far as I can tell from mucking with the code, I get the error any
time I call any method on @page.children, where @page is a
VirtualDomainPage.

It’s interesting to me that in VirtualDomainPageTest#setup, a Page
instance is created, it’s class_name set to VirtualDomainPage, and
then it is reloaded as a VirtualDomainPage instance. Immediately
afterward, @page.children.create is invoked, which doesn’t blow up.

Looking closer, I found that the ‘Anonymous module’ that has ‘no name
to be referenced by’ is NoCachePage, defined in the PageTestHelper.
The stack and ruby-debug output is below. I confess that I don’t know
enough at the moment about all the interactions of your tests with
the PageTestHelper, but this might help someone else, or you, figure
out wazzup.


#5 /Users/aiwilliams/Documents/workspace/radiantextensions/test/…/
config/…/vendor/rails/activerecord/lib/active_record/base.rb:1066:in
`instantiate_without_callbacks’
(rdb:1) l=
[1061, 1070] in /Users/aiwilliams/Documents/workspace/
radiantextensions/test/…/config/…/vendor/rails/activerecord/lib/
active_record/base.rb
1061 unless columns_hash.include?
(inheritance_column)
1062 allocate
1063
1064 else
1065 begin
=> 1066 compute_type(subclass_name).allocate
1067 rescue NameError
1068 raise SubclassNotFound,
1069 "The single-table inheritance
mechanism failed to locate the subclass: ‘#{record
[inheritance_column]}’. " +
1070 "This error is raised because the
column ‘#{inheritance_column}’ is reserved for storing the class in
case of inheritance. " +
(rdb:1) p subclass_name
“NoCachePage”
(rdb:1)

HTH,

aiwilliams

On Dec 15, 2006, at 10:47 AM, Adam W. wrote:

It’s interesting to me that in VirtualDomainPageTest#setup, a Page
instance is created, it’s class_name set to VirtualDomainPage, and
then it is reloaded as a VirtualDomainPage instance. Immediately
afterward, @page.children.create is invoked, which doesn’t blow up.

The back and forth was the easiest way I could find to get the
correct class for the Page without writing new fixtures myself. And
it was the closest analogue to the way the original set the behavior
before beginning the tests.

I tried playing around with that @page.children.create, which didn’t
change anything (much to my surprise). It was only when I tried to
access @page.children.* in the tests that it bombed.

I might just try to re-write the tests completely. Currently I’m
just trying to make the smallest changes needed to get the 0.5
behavior to work properly as a mental page type. I don’t want to
make any large changes as it’s not originally mine… And now that I
look at it, there’s no licensing information in the original code.
Hmmm…

Looking closer, I found that the ‘Anonymous module’ that has ‘no name
to be referenced by’ is NoCachePage, defined in the PageTestHelper.
The stack and ruby-debug output is below. I confess that I don’t know
enough at the moment about all the interactions of your tests with
the PageTestHelper, but this might help someone else, or you, figure
out wazzup.

[cut debug output]

Ah! A ruby debugger! How the heck could I have forgotten it
existed! Bad me! Especially after the hours I’ve spent with gdb…

The PageTestHelper must be mucking with something before the tests to
add the NoCachePage. I’ll have to see what’s going on, and it’ll be
much faster with a debugger at my fingertips.

~~ Brian

On Dec 15, 2006, at 12:47 PM, Brian G. wrote:

The PageTestHelper must be mucking with something before the tests to
add the NoCachePage. I’ll have to see what’s going on, and it’ll be
much faster with a debugger at my fingertips.

Close, but no cigar. I think PageTestHelper is never getting loaded,
but the fixtures use the classes inside. Bingo. Added a require for
page_test_helper, and viola!

New version of extension (with correctly running tests!) uploaded to:

http://silverinsanity.com/~benji/virtual_domain.tar.gz

And, as a side note, I can’t get “ruby -rdebug” or ruby-debug to work
on virtual_domain_page_test or page_test. It dies on “uninitialized
constant Radiant”, in config/boot.rb:50. But it runs without the
debug module just fine.

~~ Brian