Commit d1831811 by Kevin Chugh

comment test and thread test path passing, work around 20 hits per limit causing…

comment test and thread test path passing, work around 20 hits per limit causing test failure, remove hits per page override
parent 52f44f99
...@@ -97,7 +97,6 @@ class CommentThread < Content ...@@ -97,7 +97,6 @@ class CommentThread < Content
page = [1, options[:page] || 1].max page = [1, options[:page] || 1].max
per_page = options[:per_page] || 20 per_page = options[:per_page] || 20
per_page = 2
sort_key = options[:sort_key] sort_key = options[:sort_key]
sort_order = options[:sort_order] sort_order = options[:sort_order]
if CommentService.config[:cache_enabled] if CommentService.config[:cache_enabled]
...@@ -144,9 +143,6 @@ class CommentThread < Content ...@@ -144,9 +143,6 @@ class CommentThread < Content
end end
results = search.results results = search.results
puts "PHASE I RESULTS: #{results.collect{|r| r['id']}}"
#if this is a search query, then also search the comments and harvest the matching comments #if this is a search query, then also search the comments and harvest the matching comments
if params["text"] if params["text"]
......
require 'spec_helper' require 'spec_helper'
describe "app" do describe "app" do
describe "search" do describe "thread search" do
describe "GET /api/v1/search/threads" do describe "GET /api/v1/search/threads" do
it "returns thread with query match" do it "returns thread with query match" do
user = User.find 1 user = User.find 1
if not user if user.nil?
user = create_test_user(1) user = create_test_user(1)
end end
commentable = Commentable.new("question_1") commentable = Commentable.new("question_1")
thread = CommentThread.new(title: "Test title", body: "otter", course_id: "1", commentable_id: commentable.id) random_string = (0...8).map{ ('a'..'z').to_a[rand(26)] }.join
thread = CommentThread.new(title: "Test title", body: random_string, course_id: "1", commentable_id: commentable.id)
thread.author = user thread.author = user
thread.save! thread.save!
puts "thread id is #{thread.id}" sleep 3
get "/api/v1/search/threads", text: random_string
last_response.should be_ok
threads = parse(last_response.body)['collection']
threads.select{|t| t["id"].to_s == thread.id.to_s}.first.should_not be_nil
end
end
end
describe "comment search" do
describe "GET /api/v1/search/threads" do
it "returns thread with comment query match" do
user = User.find 1
if user.nil?
user = create_test_user(1)
end
commentable = Commentable.new("question_1")
random_string = (0...8).map{ ('a'..'z').to_a[rand(26)] }.join
thread = CommentThread.new(title: "Test title", body: "elephant otter", course_id: "1", commentable_id: commentable.id)
thread.author = user
thread.save!
sleep 3
comment = Comment.new(body: random_string, course_id: "1", commentable_id: commentable.id)
comment.author = user
comment.comment_thread = thread
comment.save!
sleep 1
get "/api/v1/search/threads", text: "otter" get "/api/v1/search/threads", text: random_string
last_response.should be_ok last_response.should be_ok
threads = parse(last_response.body)['collection'] threads = parse(last_response.body)['collection']
puts "threads: #{threads.collect{|t| t['id']}}"
threads.select{|t| t["id"].to_s == thread.id.to_s}.first.should_not be_nil threads.select{|t| t["id"].to_s == thread.id.to_s}.first.should_not be_nil
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment