Skip to content

Commit

Permalink
Merge pull request #38 from checkr/fix-package-return-packages
Browse files Browse the repository at this point in the history
Fix packages
  • Loading branch information
capripot authored Jan 22, 2018
2 parents a7779b9 + e251a21 commit 4ea45a0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.3.0 (2018-01-19)
## 1.3.1 (2018-01-19)

Features:

Expand Down
2 changes: 1 addition & 1 deletion lib/checkr/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Package < APIResource
attribute :price
attribute :screenings

api_class_method :all, :get, :constructor => APIList.constructor(:Geo)
api_class_method :all, :get, :constructor => APIList.constructor(:Package)
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
api_class_method :create, :post

Expand Down
1 change: 0 additions & 1 deletion lib/checkr/program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Program < APIResource

api_class_method :all, :get, :constructor => APIList.constructor(:Program)
api_class_method :retrieve, :get, ":path/:id", :arguments => [:id]
api_class_method :create, :post

def self.path
"/v1/programs"
Expand Down
2 changes: 1 addition & 1 deletion lib/checkr/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Checkr
VERSION = '1.3.0'.freeze
VERSION = '1.3.1'.freeze
end
8 changes: 8 additions & 0 deletions test/checkr/package_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ class PackageTest < Test::Unit::TestCase
end
end

context '#all' do
should 'return instances of Package' do
@mock.expects(:get).once.with(@package_url, anything, anything)
.returns(test_response(test_package_list))
assert_equal(Package.all.first.class, Package)
end
end

should 'be registered' do
assert(APIClass.subclasses.include?(Package))
assert_equal(Package, APIClass.subclass_fetch('package'))
Expand Down
16 changes: 8 additions & 8 deletions test/checkr/program_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ class ProgramTest < Test::Unit::TestCase
program = Program.retrieve(id)
assert(program.is_a?(Program))
end

should 'be createable' do
@mock.expects(:post).once.with(@program_url, anything, test_program)
.returns(test_response(test_program))
program = Program.create(test_program)
assert(program.is_a?(Program))
assert_equal(program.id, test_program[:id])
end
end

context 'Program instance' do
Expand Down Expand Up @@ -80,6 +72,14 @@ class ProgramTest < Test::Unit::TestCase
end
end

context '#all' do
should 'return instances of Program' do
@mock.expects(:get).once.with(@program_url, anything, anything)
.returns(test_response(test_program_list))
assert_equal(Program.all.first.class, Program)
end
end

should 'be registered' do
assert(APIClass.subclasses.include?(Program))
assert_equal(Program, APIClass.subclass_fetch('program'))
Expand Down
14 changes: 14 additions & 0 deletions test/test_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ def test_package
:subtype=>"7years"}]}
end

def test_package_list
{
:object => 'list',
:data => [test_package, test_package, test_package],
}
end

def test_program
{:id=>"e44aa283528e6fde7d542194",
:object=>"program",
Expand All @@ -150,6 +157,13 @@ def test_program
:package_ids=>["a57a0cd15965a585ff7d5d35"]}
end

def test_program_list
{
:object => 'list',
:data => [test_program, test_program, test_program],
}
end

def test_ssn_trace
{:id=>"539fd88c101897f7cd000001",
:object=>"ssn_trace",
Expand Down

0 comments on commit 4ea45a0

Please sign in to comment.