Permalink
Browse files

Correctly register publisher artefacts with router

Publisher will set the owning_app to "publisher", and the rendering_app
to "frontend". This means that the router will route requests to
frontend.*.alphagov.co.uk rather than publisher.*.alphagov.co.uk
  • Loading branch information...
1 parent c2a1213 commit 6e315808bf582e52ac2a2254114c5298714e2c6e @jamiecobbett jamiecobbett committed Jul 12, 2012
Showing with 10 additions and 5 deletions.
  1. +1 −1 app/models/enhancements/artefact.rb
  2. +9 −4 app/models/routable_artefact.rb
@@ -3,5 +3,5 @@
class Artefact
# Add a non-field attribute so we can pass indexable content over to Rummager
# without persisting it
- attr_accessor :indexable_content, :paths, :prefixes
+ attr_accessor :indexable_content, :paths, :prefixes, :rendering_app
end
@@ -15,8 +15,8 @@ def router
end
def ensure_application_exists
- backend_url = Plek.current.find(@artefact.owning_app)
- router.update_application(@artefact.owning_app, backend_url)
+ backend_url = Plek.current.find(rendering_app)
+ router.update_application(rendering_app, backend_url)
end
def submit
@@ -27,10 +27,15 @@ def submit
paths << @artefact.slug
end
paths.uniq.each do |path|
- @router.create_route(path, "full", @artefact.owning_app)
+ @router.create_route(path, "full", rendering_app)
end
prefixes.each do |prefix|
- @router.create_route(prefix, "prefix", @artefact.owning_app)
+ @router.create_route(prefix, "prefix", rendering_app)
end
end
+
+ private
+ def rendering_app
+ @artefact.rendering_app || @artefact.owning_app
+ end
end

0 comments on commit 6e31580

Please sign in to comment.