diff options
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/date_quarter_spec.rb | 31 | ||||
-rw-r--r-- | spec/lib/mail_handler/mail_handler_spec.rb | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/date_quarter_spec.rb b/spec/lib/date_quarter_spec.rb new file mode 100644 index 000000000..5af6fa334 --- /dev/null +++ b/spec/lib/date_quarter_spec.rb @@ -0,0 +1,31 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe DateQuarter do + include DateQuarter + + describe :quarters_between do + + it 'returns all the quarters in a year' do + # This is a bit of a convoluted spec, since we have to convert each + # Time in to an Integer to make a reasonable comparison + # See http://makandracards.com/makandra/1057-why-two-ruby-time-objects-are-not-equal-although-they-appear-to-be + with_env_tz 'UTC' do + start = Time.parse('2014-01-01') + finish = Time.parse('2014-12-31') + + expected = [['Wed Jan 01 00:00:00 +0000 2014', 'Mon Mar 31 23:59:59 +0000 2014'], + ['Tue Apr 01 00:00:00 +0000 2014', 'Mon Jun 30 23:59:59 +0000 2014'], + ['Tue Jul 01 00:00:00 +0000 2014', 'Tue Sep 30 23:59:59 +0000 2014'], + ['Wed Oct 01 00:00:00 +0000 2014', 'Wed Dec 31 23:59:59 +0000 2014']]. + map { |pair| [Time.parse(pair[0]).to_i, Time.parse(pair[1]).to_i] } + + quarters_between(start, finish).each_with_index do |pair, i| + pair.map!(&:to_i) + pair.should == expected[i] + end + end + end + + end + +end diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb index 49a65dade..ffc40ced9 100644 --- a/spec/lib/mail_handler/mail_handler_spec.rb +++ b/spec/lib/mail_handler/mail_handler_spec.rb @@ -22,6 +22,11 @@ describe 'when creating a mail object from raw data' do mail.multipart?.should == true end + it "should not fail on invalid byte sequence in content-disposition header", :focus => true do + part = Mail::Part.new("Content-Disposition: inline; filename=a\xB8z\r\n\r\nThis is the body text.") + lambda { part.inline? }.should_not raise_error + end + it 'should parse multiple to addresses with unqoted display names' do mail = get_fixture_mail('multiple-unquoted-display-names.email') mail.to.should == ["request-66666-caa77777@whatdotheyknow.com", "foi@example.com"] |