@@ -8,6 +8,8 @@ class UnitTests < Sinatra::Application
8
8
9
9
PWD = Pathname . new ( File . expand_path ( File . dirname ( __FILE__ ) ) )
10
10
11
+ UNIQUE_ASSET_STRING = Time . new . to_i
12
+
11
13
set :root , PWD
12
14
set :public_folder , PWD . join ( 'static' )
13
15
@@ -21,7 +23,8 @@ class UnitTests < Sinatra::Application
21
23
raise "You must run `rake dist` before starting the server."
22
24
end
23
25
24
- PATH_TO_TEST_JS = PWD . join ( 'tests' )
26
+ PATH_TO_TEST_JS = PWD . join ( 'tests' )
27
+ PATH_TO_FIXTURES = PWD . join ( 'fixtures' )
25
28
26
29
SUITES = [ ]
27
30
@@ -41,7 +44,12 @@ class UnitTests < Sinatra::Application
41
44
end
42
45
43
46
after do
44
- headers ( 'X-UA-Compatible' => 'IE=edge' )
47
+ headers ( {
48
+ 'X-UA-Compatible' => 'IE=edge' ,
49
+ 'Cache-Control' => 'no-cache, no-store, must-revalidate' ,
50
+ 'Pragma' => 'no-cache' ,
51
+ 'Expires' => '0'
52
+ } )
45
53
end
46
54
47
55
@@ -50,9 +58,14 @@ def self.get_or_post(url, &block)
50
58
post ( url , &block )
51
59
end
52
60
61
+ get '/test' do
62
+ redirect to ( '/test/' )
63
+ end
64
+
53
65
get '/test/:names?' do
54
66
names = params [ :names ]
55
67
@suites = names . nil? ? SUITES : names . split ( /,/ ) . uniq
68
+ @unique_asset_string = UNIQUE_ASSET_STRING . to_s
56
69
erb :tests , :locals => { :suites => @suites }
57
70
end
58
71
@@ -61,6 +74,12 @@ def self.get_or_post(url, &block)
61
74
send_file PATH_TO_PROTOTYPE
62
75
end
63
76
77
+
78
+ # We don't put either of these in the /static directory because
79
+ # (a) they should be more prominent in the directory structure;
80
+ # (b) they should never, ever get cached, and we want to enforce that
81
+ # aggressively.
82
+
64
83
get '/js/tests/:filename' do
65
84
filename = params [ :filename ]
66
85
path = PATH_TO_TEST_JS . join ( filename )
@@ -72,6 +91,11 @@ def self.get_or_post(url, &block)
72
91
end
73
92
end
74
93
94
+ get '/fixtures/:filename' do
95
+ filename = params [ :filename ]
96
+ send_file PATH_TO_FIXTURES . join ( filename )
97
+ end
98
+
75
99
76
100
# Routes for Ajax tests
77
101
0 commit comments