|
10 | 10 | working_quote_params[:line_items].last[:price] = '100.0'
|
11 | 11 | end
|
12 | 12 |
|
13 |
| - # it 'initializes @body with payload.body' do |
14 |
| - # assert_equal payload.body, response.instance_variable_get(:@body) |
15 |
| - # end |
| 13 | + it 'initializes @body with payload.body' do |
| 14 | + assert_equal payload.body, response.instance_variable_get(:@body) |
| 15 | + end |
16 | 16 |
|
17 |
| - # describe 'subtotal' do |
18 |
| - # it 'is the sum of price from line_items' do |
19 |
| - # assert_equal 135.5, response.subtotal.to_f |
20 |
| - # end |
| 17 | + describe 'subtotal' do |
| 18 | + it 'is the sum of price from line_items' do |
| 19 | + assert_equal 135.5, response.subtotal.to_f |
| 20 | + end |
21 | 21 |
|
22 |
| - # it 'handles empty quotes' do |
23 |
| - # working_quote_params[:line_items] = [] |
24 |
| - # assert_equal 0.0, response.subtotal.to_f |
25 |
| - # end |
26 |
| - # end |
| 22 | + it 'handles empty quotes' do |
| 23 | + working_quote_params[:line_items] = [] |
| 24 | + assert_equal 0.0, response.subtotal.to_f |
| 25 | + end |
| 26 | + end |
27 | 27 |
|
28 | 28 | describe 'total_tax' do
|
29 | 29 | describe 'for country-less customer' do
|
|
40 | 40 | end
|
41 | 41 | end
|
42 | 42 |
|
43 |
| - # describe 'for US customer' do |
44 |
| - # it 'is the sum of total_tax from line_items' do |
45 |
| - # assert_equal 8.66, response.total_tax.to_f |
46 |
| - # end |
47 |
| - |
48 |
| - # it 'handles empty quotes' do |
49 |
| - # working_quote_params[:line_items] = [] |
50 |
| - # assert_equal 0.0, response.total_tax.to_f |
51 |
| - # end |
52 |
| - |
53 |
| - # it 'handle unrecognized states' do |
54 |
| - # working_quote_params[:customer][:state] = 'XY' |
55 |
| - # working_quote_params[:line_items][1][:customer][:state] = 'XY' |
56 |
| - # assert_equal 0.0, response.total_tax.to_f |
57 |
| - # end |
58 |
| - # end |
59 |
| - |
60 |
| - # describe 'for EU customer' do |
61 |
| - # let(:payload) { VertexClient::Payload::QuotationFallback.new(working_eu_quote_params) } |
62 |
| - |
63 |
| - # it 'is the sum of total_tax from line_items' do |
64 |
| - # assert_equal 0.0, response.total_tax.to_f |
65 |
| - # end |
66 |
| - # end |
67 |
| - |
68 |
| - # describe 'for other countries' do |
69 |
| - # let(:intl_params) do |
70 |
| - # working_quote_params.tap do |wqp| |
71 |
| - # wqp[:customer][:country] = 'TZ' |
72 |
| - # wqp[:customer].delete(:state) |
73 |
| - # wqp[:line_items][1][:customer][:country] = 'TZ' |
74 |
| - # wqp[:line_items][1][:customer].delete(:state) |
75 |
| - # end |
76 |
| - # end |
77 |
| - # let(:payload) { VertexClient::Payload::QuotationFallback.new(intl_params) } |
78 |
| - |
79 |
| - # it 'is the sum of total_tax from line_items' do |
80 |
| - # assert_equal 0.0, response.total_tax.to_f |
81 |
| - # end |
82 |
| - # end |
| 43 | + describe 'for US customer' do |
| 44 | + it 'is the sum of total_tax from line_items' do |
| 45 | + assert_equal 8.66, response.total_tax.to_f |
| 46 | + end |
| 47 | + |
| 48 | + it 'handles empty quotes' do |
| 49 | + working_quote_params[:line_items] = [] |
| 50 | + assert_equal 0.0, response.total_tax.to_f |
| 51 | + end |
| 52 | + |
| 53 | + it 'handle unrecognized states' do |
| 54 | + working_quote_params[:customer][:state] = 'XY' |
| 55 | + working_quote_params[:line_items][1][:customer][:state] = 'XY' |
| 56 | + assert_equal 0.0, response.total_tax.to_f |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + describe 'for EU customer' do |
| 61 | + let(:payload) { VertexClient::Payload::QuotationFallback.new(working_eu_quote_params) } |
| 62 | + |
| 63 | + it 'is the sum of total_tax from line_items' do |
| 64 | + assert_equal 0.0, response.total_tax.to_f |
| 65 | + end |
| 66 | + end |
| 67 | + |
| 68 | + describe 'for other countries' do |
| 69 | + let(:intl_params) do |
| 70 | + working_quote_params.tap do |wqp| |
| 71 | + wqp[:customer][:country] = 'TZ' |
| 72 | + wqp[:customer].delete(:state) |
| 73 | + wqp[:line_items][1][:customer][:country] = 'TZ' |
| 74 | + wqp[:line_items][1][:customer].delete(:state) |
| 75 | + end |
| 76 | + end |
| 77 | + let(:payload) { VertexClient::Payload::QuotationFallback.new(intl_params) } |
| 78 | + |
| 79 | + it 'is the sum of total_tax from line_items' do |
| 80 | + assert_equal 0.0, response.total_tax.to_f |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | + describe 'for a country with a state code that collides with a US state code' do |
| 85 | + let(:params) do |
| 86 | + working_quote_params.tap do |wqp| |
| 87 | + wqp[:customer][:address_1] = 'Miguel Angel Blanco 2 4C' |
| 88 | + wqp[:customer][:city] = 'Valladolid' |
| 89 | + wqp[:customer][:state] = 'VA' |
| 90 | + wqp[:customer][:postal_code] = '47014' |
| 91 | + wqp[:customer][:country] = 'ES' |
| 92 | + wqp[:line_items][1][:customer][:address_1] = 'Miguel Angel Blanco 2 4C' |
| 93 | + wqp[:line_items][1][:customer][:city] = 'Valladolid' |
| 94 | + wqp[:line_items][1][:customer][:state] = 'VA' |
| 95 | + wqp[:line_items][1][:customer][:postal_code] = '47014' |
| 96 | + wqp[:line_items][1][:customer][:country] = 'ES' |
| 97 | + end |
| 98 | + end |
| 99 | + let(:payload) { VertexClient::Payload::QuotationFallback.new(params) } |
| 100 | + |
| 101 | + it 'does not use the US rates' do |
| 102 | + assert_equal 0.0, response.total_tax.to_f |
| 103 | + end |
| 104 | + end |
| 105 | + end |
| 106 | + |
| 107 | + describe 'total' do |
| 108 | + it 'is the sum of subtotal and total_tax' do |
| 109 | + assert_equal 144.16, response.total.to_f |
| 110 | + end |
83 | 111 | end
|
84 | 112 |
|
85 |
| - # describe 'total' do |
86 |
| - # it 'is the sum of subtotal and total_tax' do |
87 |
| - # assert_equal 144.16, response.total.to_f |
88 |
| - # end |
89 |
| - # end |
90 |
| - |
91 |
| - # describe 'line_items' do |
92 |
| - # it 'is a collection of Response::LineItem' do |
93 |
| - # assert_equal 2, response.line_items.size |
94 |
| - # assert_equal '4600', response.line_items.first.product.product_code |
95 |
| - # assert_equal '53103000', response.line_items.first.product.product_class |
96 |
| - # assert_equal 7, response.line_items.first.quantity |
97 |
| - # assert_equal 35.5, response.line_items.first.price.to_f |
98 |
| - # end |
99 |
| - # end |
| 113 | + describe 'line_items' do |
| 114 | + it 'is a collection of Response::LineItem' do |
| 115 | + assert_equal 2, response.line_items.size |
| 116 | + assert_equal '4600', response.line_items.first.product.product_code |
| 117 | + assert_equal '53103000', response.line_items.first.product.product_class |
| 118 | + assert_equal 7, response.line_items.first.quantity |
| 119 | + assert_equal 35.5, response.line_items.first.price.to_f |
| 120 | + end |
| 121 | + end |
100 | 122 | end
|
0 commit comments