gecko-ruby 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +9 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +41 -0
- data/CONTRIBUTING.md +0 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +144 -0
- data/Rakefile +19 -0
- data/gecko-ruby.gemspec +34 -0
- data/generate.thor +81 -0
- data/lib/gecko-ruby.rb +1 -0
- data/lib/gecko.rb +31 -0
- data/lib/gecko/client.rb +132 -0
- data/lib/gecko/helpers/association_helper.rb +69 -0
- data/lib/gecko/helpers/inspection_helper.rb +51 -0
- data/lib/gecko/helpers/record_helper.rb +29 -0
- data/lib/gecko/helpers/serialization_helper.rb +61 -0
- data/lib/gecko/helpers/validation_helper.rb +91 -0
- data/lib/gecko/record/account.rb +66 -0
- data/lib/gecko/record/address.rb +33 -0
- data/lib/gecko/record/base.rb +66 -0
- data/lib/gecko/record/base_adapter.rb +365 -0
- data/lib/gecko/record/company.rb +41 -0
- data/lib/gecko/record/contact.rb +25 -0
- data/lib/gecko/record/currency.rb +23 -0
- data/lib/gecko/record/exceptions.rb +15 -0
- data/lib/gecko/record/fulfillment.rb +42 -0
- data/lib/gecko/record/fulfillment_line_item.rb +26 -0
- data/lib/gecko/record/image.rb +38 -0
- data/lib/gecko/record/invoice.rb +29 -0
- data/lib/gecko/record/invoice_line_item.rb +18 -0
- data/lib/gecko/record/location.rb +23 -0
- data/lib/gecko/record/order.rb +50 -0
- data/lib/gecko/record/order_line_item.rb +35 -0
- data/lib/gecko/record/product.rb +27 -0
- data/lib/gecko/record/purchase_order.rb +43 -0
- data/lib/gecko/record/purchase_order_line_item.rb +29 -0
- data/lib/gecko/record/tax_type.rb +21 -0
- data/lib/gecko/record/user.rb +44 -0
- data/lib/gecko/record/variant.rb +96 -0
- data/lib/gecko/version.rb +3 -0
- data/test/client_test.rb +29 -0
- data/test/fixtures/vcr_cassettes/accounts.yml +57 -0
- data/test/fixtures/vcr_cassettes/accounts_current.yml +57 -0
- data/test/fixtures/vcr_cassettes/addresses.yml +68 -0
- data/test/fixtures/vcr_cassettes/addresses_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/companies.yml +62 -0
- data/test/fixtures/vcr_cassettes/companies_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/contacts.yml +60 -0
- data/test/fixtures/vcr_cassettes/contacts_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/currencies.yml +62 -0
- data/test/fixtures/vcr_cassettes/currencies_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/fulfillments.yml +59 -0
- data/test/fixtures/vcr_cassettes/fulfillments_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/images.yml +59 -0
- data/test/fixtures/vcr_cassettes/images_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/invoice_line_items.yml +63 -0
- data/test/fixtures/vcr_cassettes/invoice_line_items_count.yml +62 -0
- data/test/fixtures/vcr_cassettes/invoices.yml +63 -0
- data/test/fixtures/vcr_cassettes/invoices_count.yml +62 -0
- data/test/fixtures/vcr_cassettes/locations.yml +65 -0
- data/test/fixtures/vcr_cassettes/locations_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/order_line_items.yml +63 -0
- data/test/fixtures/vcr_cassettes/order_line_items_count.yml +62 -0
- data/test/fixtures/vcr_cassettes/orders.yml +62 -0
- data/test/fixtures/vcr_cassettes/orders_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/products.yml +79 -0
- data/test/fixtures/vcr_cassettes/products_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/products_new_invalid.yml +54 -0
- data/test/fixtures/vcr_cassettes/products_new_valid.yml +58 -0
- data/test/fixtures/vcr_cassettes/purchase_order_line_items.yml +64 -0
- data/test/fixtures/vcr_cassettes/purchase_order_line_items_count.yml +62 -0
- data/test/fixtures/vcr_cassettes/purchase_orders.yml +63 -0
- data/test/fixtures/vcr_cassettes/purchase_orders_count.yml +62 -0
- data/test/fixtures/vcr_cassettes/tax_types.yml +74 -0
- data/test/fixtures/vcr_cassettes/tax_types_count.yml +62 -0
- data/test/fixtures/vcr_cassettes/users.yml +60 -0
- data/test/fixtures/vcr_cassettes/users_count.yml +58 -0
- data/test/fixtures/vcr_cassettes/users_current.yml +54 -0
- data/test/fixtures/vcr_cassettes/variants.yml +60 -0
- data/test/fixtures/vcr_cassettes/variants_count.yml +58 -0
- data/test/gecko_test.rb +7 -0
- data/test/helpers/association_helper_test.rb +56 -0
- data/test/helpers/inspection_helper_test.rb +27 -0
- data/test/helpers/serialization_helper_test.rb +30 -0
- data/test/helpers/validation_helper_test.rb +24 -0
- data/test/record/account_adapter_test.rb +43 -0
- data/test/record/address_adapter_test.rb +14 -0
- data/test/record/address_test.rb +18 -0
- data/test/record/company_adapter_test.rb +14 -0
- data/test/record/company_test.rb +18 -0
- data/test/record/contact_adapter_test.rb +14 -0
- data/test/record/contact_test.rb +18 -0
- data/test/record/currency_adapter_test.rb +14 -0
- data/test/record/currency_test.rb +18 -0
- data/test/record/fulfillment_adapter_test.rb +24 -0
- data/test/record/fulfillment_line_item_adapter_test.rb +21 -0
- data/test/record/fulfillment_line_item_test.rb +18 -0
- data/test/record/fulfillment_test.rb +27 -0
- data/test/record/image_adapter_test.rb +14 -0
- data/test/record/image_test.rb +25 -0
- data/test/record/invoice_adapter_test.rb +14 -0
- data/test/record/invoice_line_item_adapter_test.rb +20 -0
- data/test/record/invoice_line_item_test.rb +18 -0
- data/test/record/invoice_test.rb +18 -0
- data/test/record/location_adapter_test.rb +14 -0
- data/test/record/location_test.rb +18 -0
- data/test/record/order_adapter_test.rb +14 -0
- data/test/record/order_line_item_adapter_test.rb +14 -0
- data/test/record/order_line_item_test.rb +18 -0
- data/test/record/order_test.rb +18 -0
- data/test/record/product_adapter_test.rb +32 -0
- data/test/record/product_test.rb +18 -0
- data/test/record/purchase_order_adapter_test.rb +14 -0
- data/test/record/purchase_order_line_item_adapter_test.rb +14 -0
- data/test/record/purchase_order_line_item_test.rb +18 -0
- data/test/record/purchase_order_test.rb +18 -0
- data/test/record/tax_type_adapter_test.rb +14 -0
- data/test/record/tax_type_test.rb +18 -0
- data/test/record/user_adapter_test.rb +27 -0
- data/test/record/user_test.rb +18 -0
- data/test/record/variant_adapter_test.rb +14 -0
- data/test/record/variant_test.rb +44 -0
- data/test/support/let.rb +10 -0
- data/test/support/shared_adapter_examples.rb +159 -0
- data/test/support/shared_record_examples.rb +21 -0
- data/test/support/testing_adapter.rb +11 -0
- data/test/support/vcr_support.rb +7 -0
- data/test/test_helper.rb +21 -0
- metadata +430 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.lvh.me:3000/variants?limit=0
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Gecko/0.0.2 OAuth2/0.9.3 Ruby/2.0.0
|
12
|
+
Authorization:
|
13
|
+
- Bearer ca89bd74c095b9d27b62c0e4dff6960123d6df6919d078e96b85081a132014ba
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- '*/*'
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Sat, 08 Mar 2014 04:18:47 GMT
|
25
|
+
Status:
|
26
|
+
- 200 OK
|
27
|
+
Connection:
|
28
|
+
- close
|
29
|
+
X-Frame-Options:
|
30
|
+
- SAMEORIGIN
|
31
|
+
X-Xss-Protection:
|
32
|
+
- 1; mode=block
|
33
|
+
X-Content-Type-Options:
|
34
|
+
- nosniff
|
35
|
+
X-Ua-Compatible:
|
36
|
+
- chrome=1
|
37
|
+
X-Pagination:
|
38
|
+
- '{"total_records":857,"total_pages":1,"first_page":true,"last_page":true,"out_of_bounds":false,"offset":0}'
|
39
|
+
Link:
|
40
|
+
- <http://api.lvh.me:3000/ajax/variants.json?limit=0&page=1>; rel="last"
|
41
|
+
Content-Type:
|
42
|
+
- application/json; charset=utf-8
|
43
|
+
Etag:
|
44
|
+
- '"79e77bf51df468ef5174fd75ebf26081"'
|
45
|
+
Cache-Control:
|
46
|
+
- max-age=0, private, must-revalidate
|
47
|
+
X-Request-Id:
|
48
|
+
- 0efd90d9-f263-49d1-a301-73c14048d379
|
49
|
+
X-Runtime:
|
50
|
+
- '0.192030'
|
51
|
+
Transfer-Encoding:
|
52
|
+
- chunked
|
53
|
+
body:
|
54
|
+
encoding: UTF-8
|
55
|
+
string: '{"variants":[],"meta":{"total":857}}'
|
56
|
+
http_version:
|
57
|
+
recorded_at: Sat, 08 Mar 2014 04:18:47 GMT
|
58
|
+
recorded_with: VCR 2.8.0
|
data/test/gecko_test.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'gecko'
|
2
|
+
|
3
|
+
class Gecko::Helpers::AssociationHelperTest < Minitest::Test
|
4
|
+
def setup
|
5
|
+
@klass = Class.new(Gecko::Record::Base) do
|
6
|
+
has_many :orders
|
7
|
+
belongs_to :order
|
8
|
+
belongs_to :small_order, class_name: "Order"
|
9
|
+
end
|
10
|
+
@client = Gecko::Client.new('ABC', 'DEF')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_adds_association_methods
|
14
|
+
record = @klass.new(@client, {})
|
15
|
+
assert(record.respond_to?(:orders))
|
16
|
+
assert(record.respond_to?(:order))
|
17
|
+
assert(record.respond_to?(:small_order))
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_adds_id_methods
|
21
|
+
record = @klass.new(@client, {})
|
22
|
+
assert(record.respond_to?(:order_ids))
|
23
|
+
assert(record.respond_to?(:order_id))
|
24
|
+
assert(record.respond_to?(:small_order_id))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_has_many
|
28
|
+
record = @klass.new(@client, {order_ids: [123]})
|
29
|
+
@client.Order.expects(:find_many).with([123])
|
30
|
+
record.orders
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_has_many_without_ids
|
34
|
+
record = @klass.new(@client, {order_ids: []})
|
35
|
+
@client.Order.expects(:find_many).never
|
36
|
+
assert_equal([], record.orders)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_belongs_to
|
40
|
+
record = @klass.new(@client, {order_id: 4})
|
41
|
+
@client.Order.expects(:find).with(4)
|
42
|
+
record.order
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_belongs_to_without_id
|
46
|
+
record = @klass.new(@client, {order_id: nil})
|
47
|
+
@client.Order.expects(:find).never
|
48
|
+
assert_nil record.order
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_belongs_to_with_class
|
52
|
+
record = @klass.new(@client, {small_order_id: 56})
|
53
|
+
@client.Order.expects(:find).with(56)
|
54
|
+
record.small_order
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'gecko'
|
2
|
+
|
3
|
+
class Gecko::Helpers::InspectionHelperTest < Minitest::Test
|
4
|
+
def setup
|
5
|
+
@klass = Class.new(Gecko::Record::Base) do
|
6
|
+
attribute :published_date, Date
|
7
|
+
attribute :published_datetime, DateTime
|
8
|
+
attribute :published_time, Time
|
9
|
+
end
|
10
|
+
@client = Gecko::Client.new('ABC', 'DEF')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_inspect_times
|
14
|
+
record = @klass.new(@client, {
|
15
|
+
published_date: Date.new(2014),
|
16
|
+
published_time: Time.new(2014),
|
17
|
+
published_datetime: DateTime.new(2014),
|
18
|
+
})
|
19
|
+
assert_equal("2014-01-01 00:00:00", get_timestamp(record.inspect, :published_time))
|
20
|
+
assert_equal("2014-01-01 00:00:00", get_timestamp(record.inspect, :published_datetime))
|
21
|
+
assert_equal("2014-01-01", get_timestamp(record.inspect, :published_date))
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_timestamp(inspect_string, attribute)
|
25
|
+
inspect_string.match(%r|#{attribute}: \"(?<timestamp>[\d:\s-]+)\"|)[:timestamp]
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'gecko'
|
2
|
+
|
3
|
+
class Gecko::Helpers::SerializationHelperTest < Minitest::Test
|
4
|
+
def setup
|
5
|
+
@klass = Class.new(Gecko::Record::Base) do
|
6
|
+
attribute :name, String
|
7
|
+
attribute :secret, String, readonly: true
|
8
|
+
|
9
|
+
def root
|
10
|
+
:widget
|
11
|
+
end
|
12
|
+
end
|
13
|
+
@client = Gecko::Client.new('ABC', 'DEF')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_serializable_hash
|
17
|
+
record = @klass.new(@client, name: "Gecko", secret: "Iguana")
|
18
|
+
assert_equal({name: "Gecko"}, record.serializable_hash)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_as_json
|
22
|
+
record = @klass.new(@client, name: "Gecko", secret: "Iguana")
|
23
|
+
assert_equal({widget: {name: "Gecko"}}, record.as_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_root_key
|
27
|
+
record = Gecko::Record::OrderLineItem.new(@client, @json)
|
28
|
+
assert_equal(:order_line_item, record.root)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'gecko'
|
2
|
+
|
3
|
+
class Gecko::Helpers::ValidationHelperTest < Minitest::Test
|
4
|
+
def setup
|
5
|
+
@klass = Class.new(Gecko::Record::Base) do
|
6
|
+
attribute :name, String
|
7
|
+
end
|
8
|
+
@client = Gecko::Client.new('ABC', 'DEF')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_initially_valid?
|
12
|
+
record = @klass.new(@client, name: "Gecko")
|
13
|
+
assert(record.valid?)
|
14
|
+
assert(record.errors.empty?)
|
15
|
+
assert(record.errors.messages.empty?)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_from_response
|
19
|
+
record = @klass.new(@client, name: "Gecko")
|
20
|
+
record.errors.from_response({name: ["is not shiny"]})
|
21
|
+
assert(!record.valid?)
|
22
|
+
assert_equal(record.errors[:name], ["is not shiny"])
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class Gecko::Record::AccountAdapterTest < Minitest::Test
|
3
|
+
include TestingAdapter
|
4
|
+
include SharedAdapterExamples
|
5
|
+
undef :test_adapter_count
|
6
|
+
|
7
|
+
# Can't build accounts via API
|
8
|
+
undef :test_build
|
9
|
+
undef :test_build_with_attributes
|
10
|
+
undef :test_saving_new_record
|
11
|
+
undef :test_saving_new_invalid_record
|
12
|
+
|
13
|
+
let(:adapter) { @client.Account }
|
14
|
+
let(:plural_name) { 'accounts' }
|
15
|
+
let(:record_class) { Gecko::Record::Account }
|
16
|
+
|
17
|
+
def test_initializes_adapter
|
18
|
+
assert_instance_of(Gecko::Record::AccountAdapter, @client.Account)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_current
|
22
|
+
VCR.use_cassette('accounts#current') do
|
23
|
+
assert_instance_of(Gecko::Record::Account, @client.Account.current)
|
24
|
+
assert(@client.Account.current, 'Account.current is identity mapped')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_adapter_all
|
29
|
+
VCR.use_cassette(plural_name) do
|
30
|
+
collection = adapter.where(limit: 5)
|
31
|
+
assert_instance_of(Array, collection)
|
32
|
+
assert_equal(1, collection.size)
|
33
|
+
assert_instance_of(record_class, collection[0])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_adapter_uses_identity_map
|
38
|
+
VCR.use_cassette(plural_name) do
|
39
|
+
collection = adapter.where(limit: 5)
|
40
|
+
assert_equal(collection.first, adapter.find(collection.first.id))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::Record::AddressAdapterTest < Minitest::Test
|
4
|
+
include TestingAdapter
|
5
|
+
include SharedAdapterExamples
|
6
|
+
|
7
|
+
let(:adapter) { @client.Address }
|
8
|
+
let(:plural_name) { 'addresses' }
|
9
|
+
let(:record_class) { Gecko::Record::Address }
|
10
|
+
|
11
|
+
def test_initializes_adapter
|
12
|
+
assert_instance_of(Gecko::Record::AddressAdapter, @client.Address)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::AddressTest < Minitest::Test
|
4
|
+
include VCRHelper
|
5
|
+
include SharedRecordExamples
|
6
|
+
|
7
|
+
let(:plural_name) { 'addresses' }
|
8
|
+
let(:record_class) { Gecko::Record::Address }
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@json = load_vcr_hash('addresses', 'addresses').first
|
12
|
+
@record = record_class.new(client, @json)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initializes_record
|
16
|
+
assert_instance_of(Gecko::Record::Address, @record)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::Record::CompanyAdapterTest < Minitest::Test
|
4
|
+
include TestingAdapter
|
5
|
+
include SharedAdapterExamples
|
6
|
+
|
7
|
+
let(:adapter) { @client.Company }
|
8
|
+
let(:plural_name) { 'companies' }
|
9
|
+
let(:record_class) { Gecko::Record::Company }
|
10
|
+
|
11
|
+
def test_initializes_adapter
|
12
|
+
assert_instance_of(Gecko::Record::CompanyAdapter, @client.Company)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::CompanyTest < Minitest::Test
|
4
|
+
include VCRHelper
|
5
|
+
include SharedRecordExamples
|
6
|
+
|
7
|
+
let(:plural_name) { 'companies' }
|
8
|
+
let(:record_class) { Gecko::Record::Company }
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@json = load_vcr_hash('companies', 'companies').first
|
12
|
+
@record = record_class.new(client, @json)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initializes_record
|
16
|
+
assert_instance_of(Gecko::Record::Company, @record)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::Record::ContactAdapterTest < Minitest::Test
|
4
|
+
include TestingAdapter
|
5
|
+
include SharedAdapterExamples
|
6
|
+
|
7
|
+
let(:adapter) { @client.Contact }
|
8
|
+
let(:plural_name) { "contacts" }
|
9
|
+
let(:record_class) { Gecko::Record::Contact }
|
10
|
+
|
11
|
+
def test_initializes_adapter
|
12
|
+
assert_instance_of(Gecko::Record::ContactAdapter, @client.Contact)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::ContactTest < Minitest::Test
|
4
|
+
include VCRHelper
|
5
|
+
include SharedRecordExamples
|
6
|
+
|
7
|
+
let(:plural_name) { "contacts" }
|
8
|
+
let(:record_class) { Gecko::Record::Contact }
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@json = load_vcr_hash("contacts", "contacts").first
|
12
|
+
@record = record_class.new(client, @json)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initializes_record
|
16
|
+
assert_instance_of(Gecko::Record::Contact, @record)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::Record::CurrencyAdapterTest < Minitest::Test
|
4
|
+
include TestingAdapter
|
5
|
+
include SharedAdapterExamples
|
6
|
+
|
7
|
+
let(:adapter) { @client.Currency }
|
8
|
+
let(:plural_name) { 'currencies' }
|
9
|
+
let(:record_class) { Gecko::Record::Currency }
|
10
|
+
|
11
|
+
def test_initializes_adapter
|
12
|
+
assert_instance_of(Gecko::Record::CurrencyAdapter, @client.Currency)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::CurrencyTest < Minitest::Test
|
4
|
+
include VCRHelper
|
5
|
+
include SharedRecordExamples
|
6
|
+
|
7
|
+
let(:plural_name) { 'currencies' }
|
8
|
+
let(:record_class) { Gecko::Record::Currency }
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@json = load_vcr_hash('currencies', 'currencies').first
|
12
|
+
@record = record_class.new(client, @json)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_initializes_record
|
16
|
+
assert_instance_of(Gecko::Record::Currency, @record)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::Record::FulfillmentAdapterTest < Minitest::Test
|
4
|
+
include TestingAdapter
|
5
|
+
include SharedAdapterExamples
|
6
|
+
|
7
|
+
let(:adapter) { @client.Fulfillment }
|
8
|
+
let(:plural_name) { 'fulfillments' }
|
9
|
+
let(:record_class) { Gecko::Record::Fulfillment }
|
10
|
+
|
11
|
+
def test_initializes_adapter
|
12
|
+
assert_instance_of(Gecko::Record::FulfillmentAdapter, @client.Fulfillment)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_identity_map_stores_sideloaded_line_items
|
16
|
+
VCR.use_cassette('fulfillments') do
|
17
|
+
collection = @client.Fulfillment.where(limit: 5)
|
18
|
+
fulfillment = collection.first
|
19
|
+
item = fulfillment.fulfillment_line_items.first
|
20
|
+
assert_instance_of(Gecko::Record::FulfillmentLineItem, item)
|
21
|
+
assert_equal(fulfillment, item.fulfillment)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Gecko::Record::FulfillmentLineItemAdapterTest < Minitest::Test
|
4
|
+
include TestingAdapter
|
5
|
+
|
6
|
+
let(:adapter) { @client.FulfillmentLineItem }
|
7
|
+
let(:plural_name) { 'fulfillment_line_items' }
|
8
|
+
let(:record_class) { Gecko::Record::FulfillmentLineItem }
|
9
|
+
|
10
|
+
def test_initializes_adapter
|
11
|
+
assert_instance_of(Gecko::Record::FulfillmentLineItemAdapter, @client.FulfillmentLineItem)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_adapter_uses_identity_map
|
15
|
+
VCR.use_cassette('fulfillments') do
|
16
|
+
@client.Fulfillment.where(limit: 5)
|
17
|
+
collection = adapter.all
|
18
|
+
assert_equal(collection.first, adapter.find(collection.first.id))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|