spec/integrations/check_spec.rb in onfido-0.14.0 vs spec/integrations/check_spec.rb in onfido-0.15.0
- old
+ new
@@ -28,9 +28,53 @@
response = check.find(applicant_id, check_id, expand: "reports")
expect(response['reports'].first).to be_a(Hash)
end
end
+ describe '#find_by_url' do
+ let(:check_id) { '8546921-123123-123123' }
+
+ context 'partial url' do
+ let(:url) { "applicants/#{applicant_id}/checks/#{check_id}" }
+
+ it 'returns an existing check for the applicant with the partial url' do
+ response = check.find_by_url(url)
+ expect(response['id']).to eq(check_id)
+ end
+
+ it "returns unexpanded reports" do
+ response = check.find_by_url(url)
+ expect(response['reports'].first).to be_a(String)
+ end
+
+ it 'allows you to expand the reports' do
+ response = check.find_by_url(url, expand: "reports")
+ expect(response['reports'].first).to be_a(Hash)
+ end
+ end
+
+ context 'full url' do
+ let(:url) do
+ "https://api.onfido.com/v2/applicants/#{applicant_id}/checks/#{check_id}"
+ end
+
+ it 'returns an existing check for the applicant with the partial url' do
+ response = check.find_by_url(url)
+ expect(response['id']).to eq(check_id)
+ end
+
+ it "returns unexpanded reports" do
+ response = check.find_by_url(url)
+ expect(response['reports'].first).to be_a(String)
+ end
+
+ it 'allows you to expand the reports' do
+ response = check.find_by_url(url, expand: "reports")
+ expect(response['reports'].first).to be_a(Hash)
+ end
+ end
+ end
+
describe '#all' do
let(:check_id) { '8546921-123123-123123' }
context 'with the default page and per page params' do
it 'returns all existing checks for the applicant' do