Skip to content

Commit 56158e0

Browse files
committed
Added tests with abuse types specified
1 parent c1bf6c2 commit 56158e0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

spec/unit/client_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,28 @@ def fully_qualified_api_endpoint
323323
end
324324

325325

326+
it "Successfully executes client.get_user_score() with abuse types specified" do
327+
api_key = "foobar"
328+
response_json = user_score_response_json
329+
330+
stub_request(:get, "https://api.siftscience.com/v205/users/247019/score" +
331+
"?api_key=foobar&abuse_types=content_abuse,payment_abuse")
332+
.to_return(:status => 200, :body => MultiJson.dump(response_json),
333+
:headers => {"content-type"=>"application/json; charset=UTF-8",
334+
"content-length"=> "74"})
335+
336+
response = Sift::Client.new(:api_key => api_key).get_user_score(user_score_response_json[:entity_id],
337+
:abuse_types => ["content_abuse",
338+
"payment_abuse"])
339+
expect(response.ok?).to eq(true)
340+
expect(response.api_status).to eq(0)
341+
expect(response.api_error_message).to eq("OK")
342+
343+
expect(response.body["entity_id"]).to eq("247019")
344+
expect(response.body["scores"]["payment_abuse"]["score"]).to eq(0.78)
345+
end
346+
347+
326348
it "Successfully executes client.rescore_user()" do
327349
api_key = "foobar"
328350
response_json = user_score_response_json
@@ -342,6 +364,28 @@ def fully_qualified_api_endpoint
342364
end
343365

344366

367+
it "Successfully executes client.rescore_user() with abuse types specified" do
368+
api_key = "foobar"
369+
response_json = user_score_response_json
370+
371+
stub_request(:post, "https://api.siftscience.com/v205/users/247019/score" +
372+
"?api_key=foobar&abuse_types=content_abuse,payment_abuse")
373+
.to_return(:status => 200, :body => MultiJson.dump(response_json),
374+
:headers => {"content-type"=>"application/json; charset=UTF-8",
375+
"content-length"=> "74"})
376+
377+
response = Sift::Client.new(:api_key => api_key).rescore_user(user_score_response_json[:entity_id],
378+
:abuse_types => ["content_abuse",
379+
"payment_abuse"])
380+
expect(response.ok?).to eq(true)
381+
expect(response.api_status).to eq(0)
382+
expect(response.api_error_message).to eq("OK")
383+
384+
expect(response.body["entity_id"]).to eq("247019")
385+
expect(response.body["scores"]["payment_abuse"]["score"]).to eq(0.78)
386+
end
387+
388+
345389
it "Successfully make a sync score request" do
346390
api_key = "foobar"
347391
response_json = {

0 commit comments

Comments
 (0)