Skip to content

Commit 96c9296

Browse files
committed
Fix warning and spec failure related to company_descriptive_date
1 parent 75f6b38 commit 96c9296

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/ach/ach_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def parse_descriptive_date(date_string)
166166
Date.today.to_datetime + (same_day_hour + same_day_minute/60) / 24
167167
end
168168

169-
date_time || Data.parse(date_string)
169+
date_time || ACH::Data.parse(date_string)
170170
rescue
171171
date_string
172172
end
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
module ACH
22
module StringFormattingHelper
3-
# Passing in SD to the date signifies same-day to banks. This is used for the company_descriptive_date
3+
# Passing in SD to the date signifies same-day to banks. This is used for
4+
# the company_descriptive_date
45
def self.stringify_with_same_day(f)
56
return f.upcase if f.to_s.upcase.match(/^SD\d+$/)
67

7-
f.strftime('%y%m%d')
8-
rescue
9-
f
8+
if f.respond_to?(:strftime)
9+
f = f.strftime('%y%m%d')
10+
end
11+
12+
f[0..5].rjust(6)
1013
end
1114
end
1215
end

spec/ach/parse_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
it "should parse return/notification of change file" do
2323
fake_current_datetime = Date.new(2012, 10, 15)
24-
expected_datetime = DateTime.new(2012, 10, 15, 19, 32)
2524
allow(Date).to receive(:today).and_return(fake_current_datetime)
2625

2726
ach = ACH::ACHFile.new(@data)
@@ -42,7 +41,7 @@
4241
expect(bh.full_company_identification).to eq("1412345678")
4342
expect(bh.standard_entry_class_code).to eq('COR')
4443
expect(bh.company_entry_description).to eq("DESCRIPT")
45-
expect(bh.company_descriptive_date).to eq(expected_datetime)
44+
expect(bh.company_descriptive_date).to eq('SD1932')
4645
expect(bh.effective_entry_date).to eq(Date.parse('121015'))
4746
expect(bh.originating_dfi_identification).to eq("99222222")
4847

0 commit comments

Comments
 (0)