Sha256: 64e49f27113eefd3c75a2c3eb4b0bd0f4db1067ff81d8ca08adf83834ab6615e

Contents?: true

Size: 1.45 KB

Versions: 23

Compression:

Stored size: 1.45 KB

Contents

require File.expand_path('../test_helper', __FILE__)

class TestOrganization < Minitest::Test
  FIXTURE = API_FIXTURES.fetch("organization")
  FIXTURE_FOR_LIST = API_FIXTURES.fetch("organizations")

  def test_retrieve()
    stub_request(:get, /organizations/).
      to_return(status: 200, body: FIXTURE.to_json)

    organization = MyJohnDeere::Organization.retrieve(default_access_token, FIXTURE[:id])

    assert_equal "1234", organization.id
    assert_equal "Smith Farms", organization.name
    assert_equal "customer", organization.type
    assert_equal true, organization.member
    assert_equal FIXTURE["links"].length, organization.links.length
    assert organization.access_token
  end

  def test_list()
    stub_request(:get, /organizations;start=0;count=1/).
      to_return(status: 200, body: FIXTURE_FOR_LIST.to_json)

    organizations = MyJohnDeere::Organization.list(default_access_token, count: 1)

    assert_equal 1, organizations.data.length
    assert_equal MyJohnDeere::Organization, organizations.data[0].class
    assert_equal 2, organizations.links.length
  end

  def test_fields()
    organization = MyJohnDeere::Organization.new(FIXTURE, default_access_token)

    stub_request(:get, /organizations\/#{organization.id}\/fields/).
      to_return(status: 200, body: API_FIXTURES["fields"].to_json)
    fields = organization.fields

    assert_equal MyJohnDeere::ListObject, fields.class
    assert_equal MyJohnDeere::Field, fields.data[0].class
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
myjohndeere-0.1.11 test/test_organization.rb
myjohndeere-0.1.10 test/test_organization.rb
myjohndeere-0.1.9 test/test_organization.rb
myjohndeere-0.1.8 test/test_organization.rb
myjohndeere-0.1.7 test/test_organization.rb
myjohndeere-0.1.6 test/test_organization.rb
myjohndeere-0.1.5 test/test_organization.rb
myjohndeere-0.1.4 test/test_organization.rb
myjohndeere-0.1.3 test/test_organization.rb
myjohndeere-0.1.2 test/test_organization.rb
myjohndeere-0.1.1 test/test_organization.rb
myjohndeere-0.1.0 test/test_organization.rb
myjohndeere-0.0.11 test/test_organization.rb
myjohndeere-0.0.10 test/test_organization.rb
myjohndeere-0.0.9 test/test_organization.rb
myjohndeere-0.0.8 test/test_organization.rb
myjohndeere-0.0.7 test/test_organization.rb
myjohndeere-0.0.6 test/test_organization.rb
myjohndeere-0.0.5 test/test_organization.rb
myjohndeere-0.0.4 test/test_organization.rb