Skip to content

Commit

Permalink
Version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
milaaraujo committed Jul 22, 2018
1 parent 7a8aa50 commit 4ab4f06
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 1 addition & 3 deletions app/services/search_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def textSearch_profiles(srchString)
sresult
end

#####################################################################################
# Search for more recently updated profiles for matching text
def textSearch_recentProfiles(srchString)
sresult = DocList.new
Expand All @@ -155,7 +154,6 @@ def textSearch_recentProfiles(srchString)

sresult
end
#####################################################################################

# Search notes for matching strings
def textSearch_notes(srchString)
Expand Down Expand Up @@ -280,7 +278,7 @@ def recentPeople(srchString, tagName = nil)
end
end
users = users.uniq
count = 0 # TODO: fazer de maneira mais bonita em Ruby
count = 0
users.each do |user|
next unless user.has_power_tag("lat") && user.has_power_tag("lon")
blurred = false
Expand Down
24 changes: 24 additions & 0 deletions test/functional/search_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,30 @@ def app

end

test 'search recent profiles functionality' do
get '/api/srch/recentprofiles?srchString=Jeff'
assert last_response.ok?

# Expected search pattern
pattern = {
srchParams: {
srchString: 'Jeff',
seq: nil,
}.ignore_extra_keys!
}.ignore_extra_keys!

matcher = JsonExpressions::Matcher.new(pattern)

json = JSON.parse(last_response.body)

assert_equal "/profile/jeff", json['items'][0]['docUrl']
assert_equal "jeff", json['items'][0]['docTitle']
assert_equal "user", json['items'][0]['docType']

assert matcher =~ json

end

test 'search notes functionality' do
get '/api/srch/notes?srchString=Blog'
assert last_response.ok?
Expand Down

0 comments on commit 4ab4f06

Please sign in to comment.