Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby revrec refactor #884

Draft
wants to merge 2 commits into
base: v2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/recurly/business_entity.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Recurly
class BusinessEntity < Resource
belongs_to :site
belongs_to :default_revenue_gl_account, class_name: 'GeneralLedgerAccount'
belongs_to :default_liability_gl_account, class_name: 'GeneralLedgerAccount'

has_many :invoices
has_many :accounts
Expand Down
2 changes: 0 additions & 2 deletions lib/recurly/plan.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_relative './rev_rec'

module Recurly
# Recurly Documentation: https://dev.recurly.com/docs/list-plans
class Plan < Resource
Expand Down
1 change: 1 addition & 0 deletions lib/recurly/resource.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'date'
require 'erb'
require_relative './rev_rec'

module Recurly
# The base class for all Recurly resources (e.g. {Account}, {Subscription},
Expand Down
2 changes: 1 addition & 1 deletion lib/recurly/shipping_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ShippingMethod < Resource
tax_code
created_at
updated_at
)
) + RevRec::PRODUCT_ATTRIBUTES
alias to_param code
end
end
3 changes: 3 additions & 0 deletions spec/fixtures/shipping_methods/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Content-Type: application/xml; charset=utf-8
<code>fedex_ground</code>
<name>FedEx Ground</name>
<accounting_code></accounting_code>
<liability_gl_account_id>twywqfr48v9l</liability_gl_account_id>
<revenue_gl_account_id>thproqnpcuwp</revenue_gl_account_id>
<performance_obligation_id>4</performance_obligation_id>
<tax_code></tax_code>
<created_at type="datetime">2019-05-07T16:36:22Z</created_at>
<updated_at type="datetime">2019-05-07T16:36:22Z</updated_at>
Expand Down
4 changes: 2 additions & 2 deletions spec/recurly/business_entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
subscriber_location_countries: ['US', 'AU'],
default_vat_number: '12345',
default_registration_number: '12345',
default_revenue_gl_account: revenue_gla,
default_liability_gl_account: liablity_gla,
default_revenue_gl_account_id: revenue_gla.id,
default_liability_gl_account_id: liablity_gla.id,
created_at: '2023-05-23T19:02:40Z',
updated_at: '2023-06-23T19:02:40Z'
)
Expand Down
13 changes: 11 additions & 2 deletions spec/recurly/shipping_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@

describe ShippingMethod do
describe ".find" do
it "must return a shipping method when available" do
before do
stub_api_request(
:get, 'shipping_methods/fedex_ground', 'shipping_methods/show-200'
)
)
end
it "must return a shipping method when available" do
shipping_method = ShippingMethod.find 'fedex_ground'
shipping_method.must_be_instance_of ShippingMethod
end

it "returns RevRec values" do
shipping_method = ShippingMethod.find 'fedex_ground'
shipping_method.performance_obligation_id.must_equal('4')
shipping_method.revenue_gl_account_id.must_equal('thproqnpcuwp')
shipping_method.liability_gl_account_id.must_equal('twywqfr48v9l')
end
end
end
Loading