Skip to content

Commit

Permalink
Fixed failing see also test
Browse files Browse the repository at this point in the history
  • Loading branch information
zk committed Oct 11, 2010
1 parent d262bc0 commit 03cb2ea
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/see_also_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ def vote
def lookup
l = params[:library]
q = params[:term]
version = Library.find_by_name_and_current(l, true).version
version = Library.find_by_name_and_current(l, true).version rescue nil

if not q
render :json => []
return
end

name = q + "%"

@functions = Function.find(:all, :conditions => ['name like ? and version = ?', name, version]).sort{|a,b| Levenshtein.distance(q, a.name) <=> Levenshtein.distance(q, b.name)}.uniq

if @functions.size > 10
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ f should accept number-of-colls arguments.\"
created_at: 2010-07-14 20:22:06
updated_at: 2010-07-21 02:31:05
shortdoc: Returns a lazy sequence consisting of the result of applying f to the
version: "1.2.0"

dummy:
id: 2
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/namespaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
clojure_core:
id: 1
library_id: 1
version: "1.2.0"
name: clojure.core
doc: "Fundamental library of the Clojure language"

Expand Down
2 changes: 1 addition & 1 deletion test/functional/management_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'test_helper'

class ManagementControllerTest < ActionController::TestCase
should_succeed :index, :lib => 'Clojure Core'
should_succeed :index, :lib => 'clojure_core'
end
2 changes: 1 addition & 1 deletion test/functional/see_also_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SeeAlsoControllerTest < ActionController::TestCase

context "with a query matching an existing var name" do
setup do
get :lookup, :term => 'ma'
get :lookup, :term => 'ma', :library => 'Clojure Core'
end

should "respond with the map var" do
Expand Down

0 comments on commit 03cb2ea

Please sign in to comment.