History

Simplify version path separator

Ref #25.

Thibaut Courouble committed 10 years ago

Commit 16ddcb11 parent fd2907d6 files · +22 −22Browse files

Showing the changes to test (3 of 6 files). Show all

Unified · Split

3 files
  1. test/app_test.rb +13 −13
  2. test/files/docs.json +1 −1
  3. test/lib/docs/core/doc_test.rb +4 −4
test/app_test.rb+13−13
@@ -80,11 +80,11 @@ class AppTest < MiniTest::Spec · 79 unmodified lines
8080 end
8181
8282 it "works with cookie" do
83− set_cookie('docs=css/html~v5')
83+ set_cookie('docs=css/html~5')
8484 get '/manifest.appcache'
8585 assert last_response.ok?
8686 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'
8888 end
8989
9090 it "ignores invalid docs in the cookie" do
@@ -127,17 +127,17 @@ class AppTest < MiniTest::Spec · 36 unmodified lines
127127
128128 describe "/[doc]" do
129129 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
132132 assert last_response.ok?
133133 end
134134
135135 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
138138 assert last_response.redirect?
139139 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=")
141141 end
142142
143143 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
146146 end
147147
148148 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')
150150 get '/html/', {}, 'HTTP_USER_AGENT' => MODERN_BROWSER
151151 assert last_response.redirect?
152152 assert_equal 'http://example.org/', last_response['Location']
@@ -160,7 +160,7 @@ class AppTest < MiniTest::Spec · 7 unmodified lines
160160 end
161161
162162 it "returns 404 when the doc doesn't exist" do
163− get '/html~v6/'
163+ get '/html~6/'
164164 assert last_response.not_found?
165165 end
166166
@@ -177,15 +177,15 @@ class AppTest < MiniTest::Spec · 10 unmodified lines
177177
178178 describe "/[doc]-[type]" do
179179 it "works when the doc exists" do
180− get '/html~v4-foo-bar_42/'
180+ get '/html~4-foo-bar_42/'
181181 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"'
183183 end
184184
185185 it "works when the doc has no version in the path and a version exists" do
186186 get '/html-foo-bar_42/'
187187 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"'
189189 end
190190
191191 it "returns 404 when the type is blank" do
@@ -199,7 +199,7 @@ class AppTest < MiniTest::Spec · 7 unmodified lines
199199 end
200200
201201 it "returns 404 when the doc doesn't exist" do
202− get '/html~v6-bar/'
202+ get '/html~6-bar/'
203203 assert last_response.not_found?
204204 end
205205
test/files/docs.json+1−1
@@ -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}]
test/lib/docs/core/doc_test.rb+4−4
@@ -45,15 +45,15 @@ class DocsDocTest < MiniTest::Spec · 44 unmodified lines
4545 assert_equal 'doc', Docs::Doc.slug
4646 end
4747
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
4949 stub(Docs::Doc).version { '42' }
50− assert_equal 'doc~v42', Docs::Doc.slug
50+ assert_equal 'doc~42', Docs::Doc.slug
5151 end
5252
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
5454 doc.slug = 'foo'
5555 doc.version = '42'
56− assert_equal 'foo~v42', doc.slug
56+ assert_equal 'foo~42', doc.slug
5757 end
5858 end
5959