From 56158e07d0404a22123726c49b83781cdbfb1da2 Mon Sep 17 00:00:00 2001 From: Alex Paino Date: Thu, 2 Aug 2018 10:20:48 -0700 Subject: [PATCH] Added tests with abuse types specified --- spec/unit/client_spec.rb | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index af97a69..531dc52 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -323,6 +323,28 @@ def fully_qualified_api_endpoint end + it "Successfully executes client.get_user_score() with abuse types specified" do + api_key = "foobar" + response_json = user_score_response_json + + stub_request(:get, "https://api.siftscience.com/v205/users/247019/score" + + "?api_key=foobar&abuse_types=content_abuse,payment_abuse") + .to_return(:status => 200, :body => MultiJson.dump(response_json), + :headers => {"content-type"=>"application/json; charset=UTF-8", + "content-length"=> "74"}) + + response = Sift::Client.new(:api_key => api_key).get_user_score(user_score_response_json[:entity_id], + :abuse_types => ["content_abuse", + "payment_abuse"]) + expect(response.ok?).to eq(true) + expect(response.api_status).to eq(0) + expect(response.api_error_message).to eq("OK") + + expect(response.body["entity_id"]).to eq("247019") + expect(response.body["scores"]["payment_abuse"]["score"]).to eq(0.78) + end + + it "Successfully executes client.rescore_user()" do api_key = "foobar" response_json = user_score_response_json @@ -342,6 +364,28 @@ def fully_qualified_api_endpoint end + it "Successfully executes client.rescore_user() with abuse types specified" do + api_key = "foobar" + response_json = user_score_response_json + + stub_request(:post, "https://api.siftscience.com/v205/users/247019/score" + + "?api_key=foobar&abuse_types=content_abuse,payment_abuse") + .to_return(:status => 200, :body => MultiJson.dump(response_json), + :headers => {"content-type"=>"application/json; charset=UTF-8", + "content-length"=> "74"}) + + response = Sift::Client.new(:api_key => api_key).rescore_user(user_score_response_json[:entity_id], + :abuse_types => ["content_abuse", + "payment_abuse"]) + expect(response.ok?).to eq(true) + expect(response.api_status).to eq(0) + expect(response.api_error_message).to eq("OK") + + expect(response.body["entity_id"]).to eq("247019") + expect(response.body["scores"]["payment_abuse"]["score"]).to eq(0.78) + end + + it "Successfully make a sync score request" do api_key = "foobar" response_json = {