Skip to content

Commit fa2fcdb

Browse files
Move the fixtures out of the static folder.
This way we can ensure they’re not cached. This fixed a failing test in IE 6-7.
1 parent 3b67bef commit fa2fcdb

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

test.new/server.rb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class UnitTests < Sinatra::Application
88

99
PWD = Pathname.new( File.expand_path( File.dirname(__FILE__) ) )
1010

11+
UNIQUE_ASSET_STRING = Time.new.to_i
12+
1113
set :root, PWD
1214
set :public_folder, PWD.join('static')
1315

@@ -21,7 +23,8 @@ class UnitTests < Sinatra::Application
2123
raise "You must run `rake dist` before starting the server."
2224
end
2325

24-
PATH_TO_TEST_JS = PWD.join('tests')
26+
PATH_TO_TEST_JS = PWD.join('tests')
27+
PATH_TO_FIXTURES = PWD.join('fixtures')
2528

2629
SUITES = []
2730

@@ -41,7 +44,12 @@ class UnitTests < Sinatra::Application
4144
end
4245

4346
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+
})
4553
end
4654

4755

@@ -50,9 +58,14 @@ def self.get_or_post(url, &block)
5058
post(url, &block)
5159
end
5260

61+
get '/test' do
62+
redirect to('/test/')
63+
end
64+
5365
get '/test/:names?' do
5466
names = params[:names]
5567
@suites = names.nil? ? SUITES : names.split(/,/).uniq
68+
@unique_asset_string = UNIQUE_ASSET_STRING.to_s
5669
erb :tests, :locals => { :suites => @suites }
5770
end
5871

@@ -61,6 +74,12 @@ def self.get_or_post(url, &block)
6174
send_file PATH_TO_PROTOTYPE
6275
end
6376

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+
6483
get '/js/tests/:filename' do
6584
filename = params[:filename]
6685
path = PATH_TO_TEST_JS.join(filename)
@@ -72,6 +91,11 @@ def self.get_or_post(url, &block)
7291
end
7392
end
7493

94+
get '/fixtures/:filename' do
95+
filename = params[:filename]
96+
send_file PATH_TO_FIXTURES.join(filename)
97+
end
98+
7599

76100
# Routes for Ajax tests
77101

0 commit comments

Comments
 (0)