-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from checkr/g/verifications
Add Verification
- Loading branch information
Showing
9 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
## v1.5.0 (2018-02-2) | ||
|
||
Features: | ||
|
||
- Add Verification | ||
|
||
## v1.4.0 (2018-01-24) | ||
|
||
Features: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Checkr | ||
class Verification < APIResource | ||
|
||
attribute :verification_type | ||
attribute :verification_url | ||
attribute :completed_at | ||
|
||
api_class_method :all, :get, "/v1/reports/:report_id/verifications", :constructor => :VerificationList | ||
|
||
APIClass.register_subclass(self, "verification") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Checkr | ||
class VerificationList < APIList | ||
|
||
attribute :next_href | ||
attribute :previous_href | ||
attribute :count | ||
attr_accessor :parent | ||
|
||
api_instance_method :all, :get | ||
|
||
def self.construct(json, parent=nil) | ||
lambda = constructor(:Verification) | ||
instance = lambda.call(json) | ||
instance.parent = parent if parent | ||
instance.clear_changed_attributes | ||
instance | ||
end | ||
|
||
def path | ||
parent.path + "/verifications" | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Checkr | ||
VERSION = '1.4.0'.freeze | ||
VERSION = '1.5.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require File.expand_path('../../test_helper', __FILE__) | ||
|
||
module Checkr | ||
class VerificationListTest < Test::Unit::TestCase | ||
setup do | ||
@report = Report.construct(test_report) | ||
@verification_url = "#{Checkr.api_base}#{@report.path}/verifications" | ||
end | ||
|
||
context 'VerificationList class' do | ||
should 'be listable' do | ||
@mock.expects(:get).once.with(@verification_url, anything, anything).returns(test_response(test_verification_list)) | ||
|
||
verifications = @report.verifications.all | ||
|
||
assert(verifications.is_a?(VerificationList)) | ||
verifications.each do |document| | ||
assert(document.is_a?(Verification)) | ||
end | ||
assert(verifications.length > 0) | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require File.expand_path('../../test_helper', __FILE__) | ||
|
||
module Checkr | ||
class VerificationTest < Test::Unit::TestCase | ||
setup do | ||
@report = Report.construct(test_report) | ||
@verification_url = "#{Checkr.api_base}#{@report.path}/verifications" | ||
end | ||
|
||
context 'Constructed Verification instance' do | ||
setup do | ||
@verification = Verification.construct(test_verification) | ||
end | ||
|
||
should 'have the id attribute' do | ||
assert_equal(test_verification[:id], @verification.id) | ||
end | ||
|
||
should 'have the object attribute' do | ||
assert_equal(test_verification[:object], @verification.object) | ||
end | ||
|
||
should 'have the uri attribute' do | ||
assert_equal(test_verification[:uri], @verification.uri) | ||
end | ||
|
||
should 'have the created_at attribute' do | ||
assert_equal(test_verification[:created_at], @verification.created_at) | ||
end | ||
|
||
should 'have the completed_at attribute' do | ||
assert_equal(test_verification[:completed_at], @verification.completed_at) | ||
end | ||
|
||
should 'have the verification_type attribute' do | ||
assert_equal(test_verification[:verification_type], @verification.verification_type) | ||
end | ||
|
||
should 'have the verification_url attribute' do | ||
assert_equal(test_verification[:verification_url], @verification.verification_url) | ||
end | ||
end | ||
|
||
context '#all' do | ||
should 'return instances of Verification' do | ||
@mock.expects(:get).once.with(@verification_url, anything, anything) | ||
.returns(test_response(test_verification_list)) | ||
assert_equal(@report.verifications.all.first.class, Verification) | ||
end | ||
end | ||
|
||
should 'be registered' do | ||
assert(APIClass.subclasses.include?(Verification)) | ||
assert_equal(Verification, APIClass.subclass_fetch('verification')) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters