spec/netsuite/utilities_spec.rb in netsuite-0.8.4 vs spec/netsuite/utilities_spec.rb in netsuite-0.8.5
- old
+ new
@@ -1,46 +1,51 @@
require 'spec_helper'
describe NetSuite::Utilities do
describe 'time utilities' do
it '#normalize_time_to_netsuite_date' do
- stamp = DateTime.parse('Wed, 27 Jul 2016 00:00:00 -0000')
- formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(stamp.to_time.to_i)
- expect(formatted_date).to eq('2016-07-27T00:00:00-07:00')
+ ['Etc/UTC', 'America/Los_Angeles', 'America/Denver'].each do |zone|
+ ENV['TZ'] = zone
+ puts "In zone: #{zone}"
- no_dst_stamp = DateTime.parse('Sun, November 6 2017 00:00:00 -0000')
- formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(no_dst_stamp.to_time.to_i)
- expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
+ stamp = DateTime.parse('Wed, 27 Jul 2016 00:00:00 -0000')
+ formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(stamp.to_time.to_i)
+ expect(formatted_date).to eq('2016-07-27T00:00:00-07:00')
- no_dst_stamp_with_time = DateTime.parse('Sun, November 6 2017 12:11:10 -0000')
- formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(no_dst_stamp_with_time.to_time.to_i)
- expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
+ no_dst_stamp = DateTime.parse('Sun, November 6 2017 00:00:00 -0000')
+ formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(no_dst_stamp.to_time.to_i)
+ expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
+
+ no_dst_stamp_with_time = DateTime.parse('Sun, November 6 2017 12:11:10 -0000')
+ formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(no_dst_stamp_with_time.to_time.to_i)
+ expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
+ end
end
end
it "#netsuite_data_center_urls" do
domains = NetSuite::Utilities.netsuite_data_center_urls('TSTDRV1576318')
- expect(domains[:webservices_domain]).to eq('https://webservices.netsuite.com')
- expect(domains[:system_domain]).to eq('https://system.netsuite.com')
+ expect(domains[:webservices_domain]).to eq('https://tstdrv1576318.suitetalk.api.netsuite.com')
+ expect(domains[:system_domain]).to eq('https://tstdrv1576318.app.netsuite.com')
# ensure domains returned don't change when sandbox is enabled
NetSuite.configure do
reset!
sandbox true
end
domains = NetSuite::Utilities.netsuite_data_center_urls('TSTDRV1576318')
- expect(domains[:webservices_domain]).to eq('https://webservices.netsuite.com')
- expect(domains[:system_domain]).to eq('https://system.netsuite.com')
+ expect(domains[:webservices_domain]).to eq('https://tstdrv1576318.suitetalk.api.netsuite.com')
+ expect(domains[:system_domain]).to eq('https://tstdrv1576318.app.netsuite.com')
NetSuite.configure do
reset!
api_version '2015_1'
end
domains = NetSuite::Utilities.netsuite_data_center_urls('TSTDRV1576318')
- expect(domains[:webservices_domain]).to eq('https://webservices.netsuite.com')
- expect(domains[:system_domain]).to eq('https://system.netsuite.com')
+ expect(domains[:webservices_domain]).to eq('https://tstdrv1576318.suitetalk.api.netsuite.com')
+ expect(domains[:system_domain]).to eq('https://tstdrv1576318.app.netsuite.com')
domains = NetSuite::Utilities.netsuite_data_center_urls('4810331')
expect(domains[:webservices_domain]).to eq('https://4810331.suitetalk.api.netsuite.com')
expect(domains[:system_domain]).to eq('https://4810331.app.netsuite.com')
end