Skip to content

Commit

Permalink
Merge pull request xero-gateway#70 from armstrjare/update_dev_env
Browse files Browse the repository at this point in the history
Update development environment
  • Loading branch information
nikz committed Feb 24, 2015
2 parents 17dd896 + 8dac0fa commit 7e33f35
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 23 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Expand Up @@ -6,7 +6,9 @@ gem 'activesupport'

group :test do
gem 'i18n' # For fixing undocumented active_support dependency
gem 'minitest'
gem 'test-unit'
gem 'mocha'
gem 'shoulda'
gem 'libxml-ruby', '~> 2.2.2'
gem 'libxml-ruby'
end
38 changes: 29 additions & 9 deletions Gemfile.lock
@@ -1,15 +1,33 @@
GEM
remote: http://rubygems.org/
specs:
activesupport (3.0.0)
builder (2.1.2)
i18n (0.6.0)
libxml-ruby (2.2.2)
metaclass (0.0.1)
mocha (0.14.0)
activesupport (4.2.0)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
builder (3.2.2)
i18n (0.7.0)
json (1.8.2)
libxml-ruby (2.8.0)
metaclass (0.0.4)
minitest (5.5.1)
mocha (1.1.0)
metaclass (~> 0.0.1)
oauth (0.4.3)
shoulda (2.11.3)
oauth (0.4.7)
power_assert (0.2.2)
shoulda (3.5.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (>= 1.4.1, < 3.0)
shoulda-context (1.2.1)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
test-unit (3.0.9)
power_assert
thread_safe (0.3.4)
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby
Expand All @@ -18,7 +36,9 @@ DEPENDENCIES
activesupport
builder (>= 2.1.2)
i18n
libxml-ruby (~> 2.2.2)
libxml-ruby
minitest
mocha
oauth (>= 0.3.6)
shoulda
test-unit
4 changes: 4 additions & 0 deletions lib/xero_gateway/dates.rb
Expand Up @@ -20,6 +20,10 @@ def parse_date(time)
def parse_date_time(time)
Time.local(time[0..3].to_i, time[5..6].to_i, time[8..9].to_i, time[11..12].to_i, time[14..15].to_i, time[17..18].to_i)
end

def parse_date_time_utc(time)
Time.utc(time[0..3].to_i, time[5..6].to_i, time[8..9].to_i, time[11..12].to_i, time[14..15].to_i, time[17..18].to_i)
end
end
end
end
6 changes: 3 additions & 3 deletions lib/xero_gateway/line_item_calculations.rb
Expand Up @@ -20,7 +20,7 @@ def sub_total=(value)

# Calculate the sub_total as the SUM(line_item.line_amount).
def sub_total
@sub_total || line_items.inject(BigDecimal.new('0')) { | sum, line_item | sum + BigDecimal.new(line_item.line_amount.to_s) }
!line_items_downloaded? && @sub_total || line_items.inject(BigDecimal.new('0')) { | sum, line_item | sum + BigDecimal.new(line_item.line_amount.to_s) }
end

# Deprecated (but API for setter remains).
Expand All @@ -32,7 +32,7 @@ def total_tax=(value)

# Calculate the total_tax as the SUM(line_item.tax_amount).
def total_tax
@total_tax || line_items.inject(BigDecimal.new('0')) { | sum, line_item | sum + BigDecimal.new(line_item.tax_amount.to_s) }
!line_items_downloaded? && @total_tax || line_items.inject(BigDecimal.new('0')) { | sum, line_item | sum + BigDecimal.new(line_item.tax_amount.to_s) }
end

# Deprecated (but API for setter remains).
Expand All @@ -44,7 +44,7 @@ def total=(value)

# Calculate the toal as sub_total + total_tax.
def total
@total || (sub_total + total_tax)
!line_items_downloaded? && @total || (sub_total + total_tax)
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/xero_gateway/report.rb
Expand Up @@ -29,7 +29,7 @@ def self.from_xml(report_element)
report.report_titles << title
end
when 'ReportDate' then report.report_date = Date.parse(element.text)
when 'UpdatedDateUTC' then report.updated_at = parse_date_time(element.text)
when 'UpdatedDateUTC' then report.updated_at = parse_date_time_utc(element.text)
when 'Rows'
report.column_names ||= find_body_column_names(element)
each_row_content(element) do |content_hash|
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
@@ -1,4 +1,4 @@
require "rubygems"
require 'bundler/setup'

require 'test/unit'
require 'mocha/setup'
Expand Down
2 changes: 1 addition & 1 deletion test/unit/contact_test.rb
Expand Up @@ -58,7 +58,7 @@ def test_add_address_helper

# Test Contact#add_phone helper creates a valid XeroGateway::Phone object with the passed in values
# and appends it to the Contact#phones attribute.
def test_add_address_helper
def test_add_address_helper2
contact = create_test_contact
assert_equal(1, contact.phones.size)

Expand Down
4 changes: 2 additions & 2 deletions test/unit/credit_note_test.rb
Expand Up @@ -40,7 +40,7 @@ def test_credit_note_sub_total_calculation
end

# Tests the total_tax calculation and that setting it manually doesn't modify the data.
def test_credit_note_sub_total_calculation
def test_credit_note_sub_total_calculation2
credit_note = create_test_credit_note
line_item = credit_note.line_items.first

Expand All @@ -61,7 +61,7 @@ def test_credit_note_sub_total_calculation
end

# Tests the total calculation and that setting it manually doesn't modify the data.
def test_credit_note_sub_total_calculation
def test_credit_note_sub_total_calculation3
credit_note = create_test_credit_note
line_item = credit_note.line_items.first

Expand Down
8 changes: 4 additions & 4 deletions test/unit/invoice_test.rb
Expand Up @@ -41,7 +41,7 @@ class InvoiceTest < Test::Unit::TestCase

# Tests the sub_total calculation and that setting it manually doesn't modify the data.
def test_invoice_sub_total_calculation
invoice = create_test_invoice
invoice = create_test_invoice(:line_items_downloaded => true)
line_item = invoice.line_items.first

# Make sure that everything adds up to begin with.
Expand All @@ -61,8 +61,8 @@ def test_invoice_sub_total_calculation
end

# Tests the total_tax calculation and that setting it manually doesn't modify the data.
def test_invoice_sub_total_calculation
invoice = create_test_invoice
def test_invoice_sub_total_calculation2
invoice = create_test_invoice(:line_items_downloaded => true)
line_item = invoice.line_items.first

# Make sure that everything adds up to begin with.
Expand All @@ -82,7 +82,7 @@ def test_invoice_sub_total_calculation
end

# Tests the total calculation and that setting it manually doesn't modify the data.
def test_invoice_sub_total_calculation
def test_invoice_sub_total_calculation3
invoice = create_test_invoice(:line_items_downloaded => true)
assert invoice.line_items_downloaded?
line_item = invoice.line_items.first
Expand Down
2 changes: 1 addition & 1 deletion test/unit/report_test.rb
Expand Up @@ -36,7 +36,7 @@ class ReportTest < Test::Unit::TestCase
expected_titles = ["Bank Statement", "Business Bank Account", "Demo Company (NZ)", "From 1 May 2014 to 27 May 2014"]
assert_equal expected_titles, @report.report_titles
assert_equal "BankStatement", @report.report_type
assert_equal Time.parse("2014-05-26 22:36:07 +1200"), @report.updated_at
assert_equal Time.parse("2014-05-26 22:36:07 +0000").to_i, @report.updated_at.to_i
expected_names = { :column_1=>"Date", :column_2=>"Description", :column_3=>"Reference", :column_4=>"Reconciled", :column_5=>"Source", :column_6=>"Amount", :column_7=>"Balance" }
assert_equal expected_names, @report.column_names

Expand Down

0 comments on commit 7e33f35

Please sign in to comment.