Skip to content

Commit

Permalink
Don't search for missing Page subclasses before bootstrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
seancribbs committed Jun 23, 2008
1 parent 80781ac commit 20d8f44
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
== Change Log

=== Edge
* Don't search for missing Page subclasses before bootstrap. [Sean Cribbs]
* Added tolerance for missing Page class definitions. [Loren Johnson]
* Don't require an authenticity token check on the login action. [Sean Cribbs]
* Make sure region sets are reloaded when activating extensions in development
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ The following people have submitted changes which have been applied to the
core:

=== Edge
* Loren Johnson
* Sean Cribbs
* Thomas Watson Steen
* Loren Johnson

=== 0.6.7 Mordant
* John Long
Expand Down
6 changes: 4 additions & 2 deletions app/models/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ def load_subclasses
Dir["#{RADIANT_ROOT}/app/models/*_page.rb"].each do |page|
$1.camelize.constantize if page =~ %r{/([^/]+)\.rb}
end
Page.find_by_sql("SELECT DISTINCT class_name AS klass_name FROM pages WHERE class_name <> '' AND class_name IS NOT NULL").each do |p|
eval(%Q{class #{p.klass_name} < Page; def self.missing?; true end end}, TOPLEVEL_BINDING) unless Object.const_defined?(p.klass_name)
unless Page.connection.tables.empty? # Haven't bootstrapped yet
Page.connection.select_values("SELECT DISTINCT class_name FROM pages WHERE class_name <> '' AND class_name IS NOT NULL").each do |p|
eval(%Q{class #{p} < Page; def self.missing?; true end end}, TOPLEVEL_BINDING) unless Object.const_defined?(p)
end
end
end

Expand Down
11 changes: 11 additions & 0 deletions spec/models/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,17 @@ def headers

end

describe Page, "loading subclasses before bootstrap" do
before :each do
Page.connection.should_receive(:tables).and_return([])
end

it "should not attempt to search for missing subclasses" do
Page.connection.should_not_receive(:select_values).with("SELECT DISTINCT class_name FROM pages WHERE class_name <> '' AND class_name IS NOT NULL")
Page.load_subclasses
end
end

describe Page, "class which is applied to a page but not defined" do
scenario :pages

Expand Down

1 comment on commit 20d8f44

@aslakhellesoy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix, Sean!

Please sign in to comment.