Permalink
Browse files

Adding tests for script tag and checkouts

  • Loading branch information...
1 parent 5f881dd commit 7c088048a6a060eefad7273591b57afc896aed3a @benjlcox benjlcox committed Mar 10, 2014
Showing with 238 additions and 0 deletions.
  1. +9 −0 test/checkouts_test.rb
  2. +186 −0 test/fixtures/checkouts.json
  3. +10 −0 test/fixtures/script_tag.json
  4. +18 −0 test/fixtures/script_tags.json
  5. +15 −0 test/script_tag_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class CheckoutsTest < Test::Unit::TestCase
+ test "get all should get all orders" do
+ fake 'checkouts', :method => :get, :status => 200, :body => load_fixture('checkouts')
+ checkout = ShopifyAPI::Checkout.all
+ assert_equal 450789469, checkout.first.id
+ end
+end
@@ -0,0 +1,186 @@
+{
+ "checkouts": [
+ {
+ "buyer_accepts_marketing": false,
+ "cart_token": "68778783ad298f1c80c3bafcddeea02f",
+ "closed_at": null,
+ "completed_at": null,
+ "created_at": "2012-10-12T07:05:27-04:00",
+ "currency": "USD",
+ "email": "bob.norman@hostmail.com",
+ "gateway": null,
+ "id": 450789469,
+ "landing_site": null,
+ "note": null,
+ "referring_site": null,
+ "shipping_lines": [
+ {
+ "title": "Free Shipping",
+ "price": "0.00",
+ "code": "Free Shipping",
+ "source": "shopify"
+ }
+ ],
+ "source": null,
+ "source_identifier": null,
+ "source_name": "web",
+ "source_url": null,
+ "subtotal_price": "398.00",
+ "taxes_included": false,
+ "token": "2a1ace52255252df566af0faaedfbfa7",
+ "total_discounts": "0.00",
+ "total_line_items_price": "398.00",
+ "total_price": "409.94",
+ "total_tax": "11.94",
+ "total_weight": 400,
+ "updated_at": "2012-10-12T07:05:27-04:00",
+ "line_items": [
+ {
+ "applied_discounts": [
+
+ ],
+ "compare_at_price": null,
+ "fulfillment_service": "manual",
+ "gift_card": false,
+ "grams": 200,
+ "id": 49148385,
+ "line_price": "199.00",
+ "price": "199.00",
+ "product_id": 632910392,
+ "properties": null,
+ "quantity": 1,
+ "requires_shipping": true,
+ "sku": "IPOD2008RED",
+ "tax_lines": [
+
+ ],
+ "taxable": true,
+ "title": "IPod Nano - 8GB",
+ "variant_id": 49148385,
+ "variant_title": "Red",
+ "vendor": "Apple"
+ },
+ {
+ "applied_discounts": [
+
+ ],
+ "compare_at_price": null,
+ "fulfillment_service": "manual",
+ "gift_card": false,
+ "grams": 200,
+ "id": 808950810,
+ "line_price": "199.00",
+ "price": "199.00",
+ "product_id": 632910392,
+ "properties": null,
+ "quantity": 1,
+ "requires_shipping": true,
+ "sku": "IPOD2008PINK",
+ "tax_lines": [
+
+ ],
+ "taxable": true,
+ "title": "IPod Nano - 8GB",
+ "variant_id": 808950810,
+ "variant_title": "Pink",
+ "vendor": "Apple"
+ }
+ ],
+ "name": "#450789469",
+ "note_attributes": [
+ {
+ "name": "custom engraving",
+ "value": "Happy Birthday"
+ },
+ {
+ "name": "colour",
+ "value": "green"
+ }
+ ],
+ "discount_codes": [
+ {
+ "code": "TENOFF",
+ "amount": "10.00"
+ }
+ ],
+ "abandoned_checkout_url": "https://checkout.local/orders/690933842/2a1ace52255252df566af0faaedfbfa7?recovered=1",
+ "tax_lines": [
+ {
+ "price": "11.94",
+ "rate": 0.06,
+ "title": "State Tax"
+ }
+ ],
+ "billing_address": {
+ "address1": "Chestnut Street 92",
+ "address2": "",
+ "city": "Louisville",
+ "company": null,
+ "country": "United States",
+ "first_name": "Bob",
+ "last_name": "Norman",
+ "latitude": "45.41634",
+ "longitude": "-75.6868",
+ "phone": "555-625-1199",
+ "province": "Kentucky",
+ "zip": "40202",
+ "name": "Bob Norman",
+ "country_code": "US",
+ "province_code": "KY"
+ },
+ "shipping_address": {
+ "address1": "Chestnut Street 92",
+ "address2": "",
+ "city": "Louisville",
+ "company": null,
+ "country": "United States",
+ "first_name": "Bob",
+ "last_name": "Norman",
+ "latitude": "45.41634",
+ "longitude": "-75.6868",
+ "phone": "555-625-1199",
+ "province": "Kentucky",
+ "zip": "40202",
+ "name": "Bob Norman",
+ "country_code": "US",
+ "province_code": "KY"
+ },
+ "customer": {
+ "accepts_marketing": false,
+ "created_at": "2014-03-07T16:12:37-05:00",
+ "email": "bob.norman@hostmail.com",
+ "first_name": "Bob",
+ "id": 207119551,
+ "last_name": "Norman",
+ "last_order_id": null,
+ "multipass_identifier": null,
+ "note": null,
+ "orders_count": 0,
+ "state": "disabled",
+ "total_spent": "0.00",
+ "updated_at": "2014-03-07T16:12:37-05:00",
+ "verified_email": true,
+ "tags": "",
+ "last_order_name": null,
+ "default_address": {
+ "address1": "Chestnut Street 92",
+ "address2": "",
+ "city": "Louisville",
+ "company": null,
+ "country": "United States",
+ "first_name": null,
+ "id": 207119551,
+ "last_name": null,
+ "phone": "555-625-1199",
+ "province": "Kentucky",
+ "zip": "40202",
+ "name": null,
+ "province_code": "KY",
+ "country_code": "US",
+ "country_name": "United States",
+ "default": true
+ }
+ }
+ }
+ ]
+}
@@ -0,0 +1,10 @@
+{
+ "script_tags":
+ {
+ "created_at": "2014-03-07T16:14:54-05:00",
+ "event": "onload",
+ "id": 421379493,
+ "src": "http://js-aplenty.com/bar.js",
+ "updated_at": "2014-03-07T16:14:54-05:00"
+ }
+}
@@ -0,0 +1,18 @@
+{
+ "script_tags": [
+ {
+ "created_at": "2014-03-07T16:14:54-05:00",
+ "event": "onload",
+ "id": 421379493,
+ "src": "http://js-aplenty.com/bar.js",
+ "updated_at": "2014-03-07T16:14:54-05:00"
+ },
+ {
+ "created_at": "2014-03-07T16:14:54-05:00",
+ "event": "onload",
+ "id": 596726825,
+ "src": "http://js-aplenty.com/foo.js",
+ "updated_at": "2014-03-07T16:14:54-05:00"
+ }
+ ]
+}
@@ -0,0 +1,15 @@
+require 'test_helper'
+
+class ScriptTagTest < Test::Unit::TestCase
+ test "get all should get all script tags" do
+ fake 'script_tags', :method => :get, :status => 200, :body => load_fixture('script_tags')
+ script_tags = ShopifyAPI::ScriptTag.all
+ assert_equal "http://js-aplenty.com/bar.js", script_tags.first.src
+ end
+
+ test "get should get a script tag" do
+ fake 'script_tags/421379493', :method => :get, :status => 200, :body => load_fixture('script_tag')
+ script_tag = ShopifyAPI::ScriptTag.find(421379493)
+ assert_equal "http://js-aplenty.com/bar.js", script_tag.src
+ end
+end

0 comments on commit 7c08804

Please sign in to comment.