Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
d517169d
Commit
d517169d
authored
Jan 01, 2016
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Query spec
-Using factories to generate data - Using single quotes
parent
a7aed5a1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
43 deletions
+25
-43
spec/api/query_spec.rb
+25
-43
No files found.
spec/api/query_spec.rb
View file @
d517169d
require
'spec_helper'
require
'spec_helper'
require
'faker'
describe
"app"
do
before
(
:each
)
{
set_api_key_header
}
describe
'app'
do
before
(
:each
)
{
set_api_key_header
}
let
(
:body
)
{
Faker
::
Lorem
.
word
}
let
(
:author
)
{
create_test_user
(
1
)
}
describe
'GET /api/v1/search/threads'
do
describe
"thread search"
do
describe
"GET /api/v1/search/threads"
do
it
"returns thread with query match"
do
commentable
=
Commentable
.
new
(
"question_1"
)
random_string
=
(
0
...
8
).
map
{
(
'a'
..
'z'
).
to_a
[
rand
(
26
)]
}.
join
shared_examples_for
'a search endpoint'
do
subject
do
refresh_es_index
get
'/api/v1/search/threads'
,
text:
body
end
thread
=
CommentThread
.
new
(
title:
"Test title"
,
body:
random_string
,
course_id:
"1"
,
commentable_id:
commentable
.
id
)
let
(
:matched_thread
)
{
parse
(
subject
.
body
)[
'collection'
].
select
{
|
t
|
t
[
'id'
]
==
thread
.
id
.
to_s
}.
first
}
thread
.
thread_type
=
:discussion
thread
.
author
=
author
thread
.
save!
sleep
3
it
{
should
be_ok
}
get
"/api/v1/search/threads"
,
text:
random_string
it
'returns thread with query match'
do
last_response
.
should
be_ok
expect
(
matched_thread
).
to_not
be_nil
threads
=
parse
(
last_response
.
body
)[
'collection'
]
check_thread_result_json
(
nil
,
thread
,
matched_thread
)
check_thread_result_json
(
nil
,
thread
,
threads
.
select
{
|
t
|
t
[
"id"
]
==
thread
.
id
.
to_s
}.
first
)
end
end
end
end
end
describe
"comment search"
do
describe
"GET /api/v1/search/threads"
do
it
"returns thread with comment query match"
do
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
)
context
'when searching on thread content'
do
thread
.
thread_type
=
:discussion
let!
(
:thread
)
{
create
(
:comment_thread
,
body:
body
)
}
thread
.
author
=
author
thread
.
save!
sleep
3
it_behaves_like
'a search endpoint'
end
comment
=
Comment
.
new
(
body:
random_string
,
course_id:
"1"
)
comment
.
commentable_id
=
commentable
.
id
comment
.
author
=
author
comment
.
comment_thread
=
thread
comment
.
save!
sleep
1
get
"/api/v1/search/threads"
,
text:
random_string
context
'when searching on comment content'
do
last_response
.
should
be_ok
let!
(
:thread
)
do
threads
=
parse
(
last_response
.
body
)[
'collection'
]
comment
=
create
(
:comment
,
body:
body
)
check_thread_result_json
(
nil
,
thread
,
threads
.
select
{
|
t
|
t
[
"id"
]
==
thread
.
id
.
to_s
}.
first
)
thread
=
comment
.
comment_thread
end
end
it_behaves_like
'a search endpoint'
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment