Skip to content

Commit

Permalink
Site callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh French committed Jun 24, 2008
1 parent 2322d34 commit a790f04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/models/site.rb
Expand Up @@ -16,6 +16,7 @@ def find_for_host(hostname = '')
validates_uniqueness_of :domain

after_create :create_homepage
after_save :reload_routes

def url(path = "/")
uri = URI.join("http://#{self.base_domain}", path)
Expand All @@ -36,4 +37,8 @@ def create_homepage
save
end
end

def reload_routes
ActionController::Routing::Routes.reload
end
end
11 changes: 9 additions & 2 deletions spec/models/multi_site_site_spec.rb
Expand Up @@ -54,8 +54,15 @@
end

it "should generate dev site url form path" do
sites(:mysite).dev_url.should eql("http://preview.mysite.domain.com/")
sites(:mysite).dev_url("/about").should eql("http://preview.mysite.domain.com/about")
sites(:mysite).dev_url.should eql("http://preview.mysite.domain.com/")
sites(:mysite).dev_url("/about").should eql("http://preview.mysite.domain.com/about")
end

describe "#save" do
it "should reload routes" do
ActionController::Routing::Routes.should_receive(:reload)
@site.save
end
end

end

0 comments on commit a790f04

Please sign in to comment.