From a59786be2e3113f931c520ebc7f309556bd6940e Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sat, 4 Jun 2016 10:09:01 -0400 Subject: [PATCH] Change single-doc setup to use data-attribute instead of inline script --- assets/javascripts/app/app.coffee | 3 ++- test/app_test.rb | 4 ++-- views/other.erb | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee index e8f083a2..7a9f925b 100644 --- a/assets/javascripts/app/app.coffee +++ b/assets/javascripts/app/app.coffee @@ -27,7 +27,8 @@ @document = new app.views.Document @mobile = new app.views.Mobile if @isMobile() - if @DOC + if document.body.hasAttribute('data-doc') + @DOC = JSON.parse(document.body.getAttribute('data-doc')) @bootOne() else if @DOCS @bootAll() diff --git a/test/app_test.rb b/test/app_test.rb index eebab3aa..50cf78e4 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -185,13 +185,13 @@ class AppTest < MiniTest::Spec it "works when the doc exists" do get '/html~4-foo-bar_42/' assert last_response.ok? - assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~4"' + assert_includes last_response.body, 'data-doc="{"name":"HTML","slug":"html~4"' end it "works when the doc has no version in the path and a version exists" do get '/html-foo-bar_42/' assert last_response.ok? - assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~5"' + assert_includes last_response.body, 'data-doc="{"name":"HTML","slug":"html~5"' end it "returns 404 when the type is blank" do diff --git a/views/other.erb b/views/other.erb index f1b6247c..4c8df481 100644 --- a/views/other.erb +++ b/views/other.erb @@ -13,9 +13,8 @@ <%= javascript_tag 'application', asset_host: false %><% unless App.production? %> <%= javascript_tag 'debug' %><% end %> - - + <%= erb :app %>