Ref #25.
Unified · Split
| @@ -4,7 +4,7 @@ class app.models.Doc extends app.Model · 3 unmodified lines | ||
| 4 | 4 | constructor: -> |
| 5 | 5 | super |
| 6 | 6 | @reset @ |
| 7 | − @slug_without_version = @slug.split('~v')[0] | |
| 7 | + @slug_without_version = @slug.split('~')[0] | |
| 8 | 8 | @fullName = "#{@name}" + if @version then " #{@version}" else '' |
| 9 | 9 | @icon = @slug_without_version |
| 10 | 10 | @text = @toEntry().text |
| @@ -123,7 +123,7 @@ class App < Sinatra::Application · 122 unmodified lines | ||
| 123 | 123 | |
| 124 | 124 | def find_doc(slug) |
| 125 | 125 | settings.docs[slug] || begin |
| 126 | − slug = "#{slug}~v" | |
| 126 | + slug = "#{slug}~" | |
| 127 | 127 | settings.docs.each do |_slug, _doc| |
| 128 | 128 | return _doc if _slug.start_with?(slug) |
| 129 | 129 | end |
| @@ -133,7 +133,7 @@ class App < Sinatra::Application · 3 unmodified lines | ||
| 133 | 133 | |
| 134 | 134 | def user_has_docs?(slug) |
| 135 | 135 | docs.include?(slug) || begin |
| 136 | − slug = "#{slug}~v" | |
| 136 | + slug = "#{slug}~" | |
| 137 | 137 | docs.any? { |_slug| _slug.start_with?(slug) } |
| 138 | 138 | end |
| 139 | 139 | end |
| @@ -48,7 +48,7 @@ module Docs · 47 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | def slug |
| 50 | 50 | slug = @slug || name.try(:downcase) |
| 51 | − version? ? "#{slug}~v#{version}" : slug | |
| 51 | + version? ? "#{slug}~#{version}" : slug | |
| 52 | 52 | end |
| 53 | 53 | |
| 54 | 54 | def path |
| @@ -80,11 +80,11 @@ class AppTest < MiniTest::Spec · 79 unmodified lines | ||
| 80 | 80 | end |
| 81 | 81 | |
| 82 | 82 | it "works with cookie" do |
| 83 | − set_cookie('docs=css/html~v5') | |
| 83 | + set_cookie('docs=css/html~5') | |
| 84 | 84 | get '/manifest.appcache' |
| 85 | 85 | assert last_response.ok? |
| 86 | 86 | assert_includes last_response.body, '/css/index.json?1420139788' |
| 87 | − assert_includes last_response.body, '/html~v5/index.json?1420139791' | |
| 87 | + assert_includes last_response.body, '/html~5/index.json?1420139791' | |
| 88 | 88 | end |
| 89 | 89 | |
| 90 | 90 | it "ignores invalid docs in the cookie" do |
| @@ -127,17 +127,17 @@ class AppTest < MiniTest::Spec · 36 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | describe "/[doc]" do |
| 129 | 129 | it "renders when the doc exists and isn't enabled" do |
| 130 | − set_cookie('docs=html~v5') | |
| 131 | − get '/html~v4/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | |
| 130 | + set_cookie('docs=html~5') | |
| 131 | + get '/html~4/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | |
| 132 | 132 | assert last_response.ok? |
| 133 | 133 | end |
| 134 | 134 | |
| 135 | 135 | it "redirects via JS cookie when the doc exists and is enabled" do |
| 136 | − set_cookie('docs=html~v5') | |
| 137 | − get '/html~v5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | |
| 136 | + set_cookie('docs=html~5') | |
| 137 | + get '/html~5/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER | |
| 138 | 138 | assert last_response.redirect? |
| 139 | 139 | assert_equal 'http://example.org/', last_response['Location'] |
| 140 | − assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%7Ev5%2F; path=/; expires=") | |
| 140 | + assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%7E5%2F; path=/; expires=") | |
| 141 | 141 | end |
| 142 | 142 | |
| 143 | 143 | it "renders when the doc exists, has no version in the path, and isn't enabled" do |
| @@ -146,7 +146,7 @@ class AppTest < MiniTest::Spec · 2 unmodified lines | ||
| 146 | 146 | end |
| 147 | 147 | |
| 148 | 148 | it "redirects via JS cookie when the doc exists, has no version in the path, and a version is enabled" do |
| 149 | − set_cookie('docs=html~v5') | |
| 149 | + set_cookie('docs=html~5') | |
| 150 | 150 | get '/html/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER |
| 151 | 151 | assert last_response.redirect? |
| 152 | 152 | assert_equal 'http://example.org/', last_response['Location'] |
| @@ -160,7 +160,7 @@ class AppTest < MiniTest::Spec · 7 unmodified lines | ||
| 160 | 160 | end |
| 161 | 161 | |
| 162 | 162 | it "returns 404 when the doc doesn't exist" do |
| 163 | − get '/html~v6/' | |
| 163 | + get '/html~6/' | |
| 164 | 164 | assert last_response.not_found? |
| 165 | 165 | end |
| 166 | 166 | |
| @@ -177,15 +177,15 @@ class AppTest < MiniTest::Spec · 10 unmodified lines | ||
| 177 | 177 | |
| 178 | 178 | describe "/[doc]-[type]" do |
| 179 | 179 | it "works when the doc exists" do |
| 180 | − get '/html~v4-foo-bar_42/' | |
| 180 | + get '/html~4-foo-bar_42/' | |
| 181 | 181 | assert last_response.ok? |
| 182 | − assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~v4"' | |
| 182 | + assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~4"' | |
| 183 | 183 | end |
| 184 | 184 | |
| 185 | 185 | it "works when the doc has no version in the path and a version exists" do |
| 186 | 186 | get '/html-foo-bar_42/' |
| 187 | 187 | assert last_response.ok? |
| 188 | − assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~v5"' | |
| 188 | + assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~5"' | |
| 189 | 189 | end |
| 190 | 190 | |
| 191 | 191 | it "returns 404 when the type is blank" do |
| @@ -199,7 +199,7 @@ class AppTest < MiniTest::Spec · 7 unmodified lines | ||
| 199 | 199 | end |
| 200 | 200 | |
| 201 | 201 | it "returns 404 when the doc doesn't exist" do |
| 202 | − get '/html~v6-bar/' | |
| 202 | + get '/html~6-bar/' | |
| 203 | 203 | assert last_response.not_found? |
| 204 | 204 | end |
| 205 | 205 | |
| @@ -1 +1 @@ | ||
| 1 | −[{"name":"CSS","slug":"css","type":"mdn","release":null,"mtime":1420139788,"db_size":3460507},{"name":"DOM","slug":"dom","type":"mdn","release":null,"mtime":1420139789,"db_size":11399128},{"name":"DOM Events","slug":"dom_events","type":"mdn","release":null,"mtime":1420139790,"db_size":889020},{"name":"HTML","slug":"html~v5","type":"mdn","version":"5","mtime":1420139791,"db_size":1835647},{"name":"HTML","slug":"html~v4","type":"mdn","version":"4","mtime":1420139790,"db_size":1835646},{"name":"HTTP","slug":"http","type":"rfc","release":null,"mtime":1420139790,"db_size":183083},{"name":"JavaScript","slug":"javascript","type":"mdn","release":null,"mtime":1420139791,"db_size":4125477}] | |
| 1 | +[{"name":"CSS","slug":"css","type":"mdn","release":null,"mtime":1420139788,"db_size":3460507},{"name":"DOM","slug":"dom","type":"mdn","release":null,"mtime":1420139789,"db_size":11399128},{"name":"DOM Events","slug":"dom_events","type":"mdn","release":null,"mtime":1420139790,"db_size":889020},{"name":"HTML","slug":"html~5","type":"mdn","version":"5","mtime":1420139791,"db_size":1835647},{"name":"HTML","slug":"html~4","type":"mdn","version":"4","mtime":1420139790,"db_size":1835646},{"name":"HTTP","slug":"http","type":"rfc","release":null,"mtime":1420139790,"db_size":183083},{"name":"JavaScript","slug":"javascript","type":"mdn","release":null,"mtime":1420139791,"db_size":4125477}] | |
| @@ -45,15 +45,15 @@ class DocsDocTest < MiniTest::Spec · 44 unmodified lines | ||
| 45 | 45 | assert_equal 'doc', Docs::Doc.slug |
| 46 | 46 | end |
| 47 | 47 | |
| 48 | − it "returns 'doc~v42' when the class is Docs::Doc and its #version is '42'" do | |
| 48 | + it "returns 'doc~42' when the class is Docs::Doc and its #version is '42'" do | |
| 49 | 49 | stub(Docs::Doc).version { '42' } |
| 50 | − assert_equal 'doc~v42', Docs::Doc.slug | |
| 50 | + assert_equal 'doc~42', Docs::Doc.slug | |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | − it "returns 'foo~v42' when #slug has been set to 'foo' and #version to '42'" do | |
| 53 | + it "returns 'foo~42' when #slug has been set to 'foo' and #version to '42'" do | |
| 54 | 54 | doc.slug = 'foo' |
| 55 | 55 | doc.version = '42' |
| 56 | − assert_equal 'foo~v42', doc.slug | |
| 56 | + assert_equal 'foo~42', doc.slug | |
| 57 | 57 | end |
| 58 | 58 | end |
| 59 | 59 | |