Fix post service spec
* load records to array to check them * test that only 15 people are returned
This commit is contained in:
parent
33e3e3a14d
commit
ff3bd1f59b
1 changed files with 5 additions and 3 deletions
|
|
@ -299,7 +299,7 @@ describe PostService do
|
||||||
include_context "with a current user's friend"
|
include_context "with a current user's friend"
|
||||||
|
|
||||||
it "returns mention suggestions in the correct order" do
|
it "returns mention suggestions in the correct order" do
|
||||||
result = post_service.mentionable_in_comment(post.id, "Ro")
|
result = post_service.mentionable_in_comment(post.id, "Ro").to_a
|
||||||
expect(result.size).to be > 7
|
expect(result.size).to be > 7
|
||||||
# participants: post author, comments, likers
|
# participants: post author, comments, likers
|
||||||
expect(result[0..4]).to eq([post_author, commenter1, commenter2, liker1, liker2])
|
expect(result[0..4]).to eq([post_author, commenter1, commenter2, liker1, liker2])
|
||||||
|
|
@ -396,8 +396,10 @@ describe PostService do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "calls Person.limit" do
|
it "calls Person.limit" do
|
||||||
expect_any_instance_of(Person::ActiveRecord_Relation).to receive(:limit).with(15).and_call_original
|
16.times {
|
||||||
post_service.mentionable_in_comment(post.id, "whatever")
|
FactoryGirl.create(:comment, author: FactoryGirl.create(:person, first_name: "Ro#{r_str}"), post: post)
|
||||||
|
}
|
||||||
|
expect(post_service.mentionable_in_comment(post.id, "Ro").length).to eq(15)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "contains a constraint on a current user" do
|
it "contains a constraint on a current user" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue