From 7d55c99ffa4ec390fb356a469c9055be8f91e3d0 Mon Sep 17 00:00:00 2001 From: Edoardo Serra Date: Wed, 15 May 2024 15:53:47 -0400 Subject: [PATCH 1/2] add .complete to report instance --- lib/checkr/report.rb | 1 + test/checkr/report_test.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/checkr/report.rb b/lib/checkr/report.rb index b81d0fb..4d39226 100644 --- a/lib/checkr/report.rb +++ b/lib/checkr/report.rb @@ -65,6 +65,7 @@ class Report < APIResource api_class_method :create, :post api_instance_method :save, :post, default_params: :changed_attributes + api_instance_method :complete, :post, ':path/complete' def self.path '/v1/reports' diff --git a/test/checkr/report_test.rb b/test/checkr/report_test.rb index e70b5fa..fc7ac4f 100644 --- a/test/checkr/report_test.rb +++ b/test/checkr/report_test.rb @@ -20,6 +20,13 @@ class ReportTest < Test::Unit::TestCase assert(report.is_a?(Report)) assert_equal(test_report[:id], report.id) end + + should 'be completeable' do + id = "report_id" + @mock.expects(:get).once.with("#{@report_url}/#{id}", anything, anything).returns(test_response(test_report)) + report = Report.retrieve(id) + assert(report.is_a?(Report)) + end end context 'Report instance' do @@ -42,6 +49,15 @@ class ReportTest < Test::Unit::TestCase report.save assert_equal(test_report[:package], report.package) end + + should 'be completeable' do + report = Report.new(test_report) + + @mock.expects(:post).once.with("#{@report_url}/#{test_report[:id]}/complete", anything, anything).returns(test_response(test_report)) + + report.complete + assert_equal(test_report[:status], "complete") + end end From 4947d98185a3c85acdf344a1df6d6fafa87568b9 Mon Sep 17 00:00:00 2001 From: Edoardo Serra Date: Wed, 15 May 2024 15:54:55 -0400 Subject: [PATCH 2/2] cleanup --- test/checkr/report_test.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/test/checkr/report_test.rb b/test/checkr/report_test.rb index fc7ac4f..03d83fe 100644 --- a/test/checkr/report_test.rb +++ b/test/checkr/report_test.rb @@ -20,13 +20,6 @@ class ReportTest < Test::Unit::TestCase assert(report.is_a?(Report)) assert_equal(test_report[:id], report.id) end - - should 'be completeable' do - id = "report_id" - @mock.expects(:get).once.with("#{@report_url}/#{id}", anything, anything).returns(test_response(test_report)) - report = Report.retrieve(id) - assert(report.is_a?(Report)) - end end context 'Report instance' do @@ -51,10 +44,8 @@ class ReportTest < Test::Unit::TestCase end should 'be completeable' do - report = Report.new(test_report) - @mock.expects(:post).once.with("#{@report_url}/#{test_report[:id]}/complete", anything, anything).returns(test_response(test_report)) - + report = Report.new(test_report) report.complete assert_equal(test_report[:status], "complete") end