Skip to content

Commit 0aa52e3

Browse files
committed
Fix JavasScript test suite
1 parent ef18057 commit 0aa52e3

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

test/javascript/server.rb

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,48 @@
22
require 'json'
33
require 'ruby-debug'
44

5-
use Rack::Static, :urls => ['/vendor/assets/javascripts'], :root => File.expand_path('../..', settings.root)
5+
class AssetPath
6+
def initialize(app, options={})
7+
@app = app
8+
@urls = options[:urls] || ["/favicon.ico"]
9+
@index = options[:index]
10+
root = options[:root] || Dir.pwd
11+
cache_control = options[:cache_control]
12+
@file_server = Rack::File.new(root, cache_control)
13+
end
14+
15+
def overwrite_file_path(path)
16+
@urls.kind_of?(Hash) && @urls.key?(path) || @index && path == '/'
17+
end
18+
19+
def route_file(path)
20+
@urls.kind_of?(Array) && @urls.any? { |url| path.index(url) == 0 }
21+
end
22+
23+
def can_serve(path)
24+
route_file(path) || overwrite_file_path(path)
25+
end
26+
27+
def call(env)
28+
path = env["PATH_INFO"]
29+
30+
if can_serve(path)
31+
env["PATH_INFO"] = (path == '/' ? @index : @urls[path]) if overwrite_file_path(path)
32+
response = @file_server.call(env)
33+
if response.first == 404
34+
@app.call(env)
35+
else
36+
response
37+
end
38+
else
39+
@app.call(env)
40+
end
41+
end
42+
end
43+
44+
use AssetPath, :urls => ['/vendor/assets/javascripts'], :root => File.expand_path('../..', settings.root)
645

7-
JQUERY_VERSIONS = %w[ 1.6 1.6.1 1.6.2 1.6.3 1.6.4 ].freeze
46+
JQUERY_VERSIONS = %w[ 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.7 1.7.1 ].freeze
847

948
helpers do
1049
def jquery_link version
@@ -45,7 +84,7 @@ def jquery_versions
4584
end
4685

4786
get '/' do
48-
params[:version] ||= '1.6'
87+
params[:version] ||= '1.7.1'
4988
erb :index
5089
end
5190

test/javascript/views/index.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% @title = "client-side-validations test" %>
1+
<% @title = "client_side_validations test" %>
22

33
<%= test_base %>
44
<%= script_tag 'validateElement' %>

vendor/assets/javascripts/rails.validations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Rails 3 Client Side Validations - v3.1.0
2+
* Rails 3 Client Side Validations - v3.2.0.beta.1
33
* https://github.com/bcardarella/client_side_validations
44
*
55
* Copyright (c) 2011 Brian Cardarella

0 commit comments

Comments
 (0)