aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl_bogus.c
blob: a07ea7529c42ecf8844ffc287996029a411d16d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  /********************************************************************\
  * BitlBee -- An IRC to other IM-networks gateway                     *
  *                                                                    *
  * Copyright 2002-2004 Wilmer van der Gaast and others                *
  \********************************************************************/

/* SSL module - dummy version                                           */

/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License with
  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  Suite 330, Boston, MA  02111-1307  USA
*/

#include "ssl_client.h"

int ssl_errno;

void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data )
{
	return( NULL );
}

int ssl_read( void *conn, char *buf, int len )
{
	return( -1 );
}

int ssl_write( void *conn, const char *buf, int len )
{
	return( -1 );
}

void ssl_disconnect( void *conn_ )
{
}

int ssl_getfd( void *conn )
{
	return( -1 );
}

void *ssl_starttls( int fd, ssl_input_function func, gpointer data ) 
{
	return NULL;
}

b_input_condition ssl_getdirection( void *conn )
{
	return GAIM_INPUT_READ;
}

int ssl_pending( void *conn )
{
	return 0;
}
' href='#n81'>81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
# == Schema Information
#
# Table name: holidays
#
#  id          :integer          not null, primary key
#  day         :date
#  description :text
#

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Holiday do

    describe :new do

        it 'should require a day' do
            holiday = Holiday.new
            holiday.valid?.should be_false
            holiday.errors[:day].should == "can't be blank"
        end
    end

    describe " when calculating due date" do

        def due_date(ymd)
            return Holiday.due_date_from_working_days(Date.strptime(ymd), 20).strftime("%F")
        end

        context "in working days" do
            it "handles no holidays" do
            due_date('2008-10-01').should == '2008-10-29'
            end

            it "handles non leap years" do
            due_date('2007-02-01').should == '2007-03-01'
            end

            it "handles leap years" do
            due_date('2008-02-01').should == '2008-02-29'
            end

            it "handles Thursday start" do
            due_date('2009-03-12').should == '2009-04-14'
            end

            it "handles Friday start" do
            due_date('2009-03-13').should == '2009-04-15'
            end

            # Delivery at the weekend ends up the same due day as if it had arrived on
            # the Friday before. This is because the next working day (Monday) counts
            # as day 1.
            # See http://www.whatdotheyknow.com/help/officers#days
            it "handles Saturday start" do
            due_date('2009-03-14').should == '2009-04-15'
            end
            it "handles Sunday start" do
            due_date('2009-03-15').should == '2009-04-15'
            end

            it "handles Monday start" do
            due_date('2009-03-16').should == '2009-04-16'
            end

            it "handles Time objects" do
            Holiday.due_date_from_working_days(Time.utc(2009, 03, 16, 12, 0, 0), 20).strftime('%F').should == '2009-04-16'
            end
        end

        context "in calendar days" do
            it "handles no holidays" do
                Holiday.due_date_from_calendar_days(Date.new(2008, 10, 1), 20).should == Date.new(2008, 10, 21)
            end

            it "handles the due date falling on a Friday" do
                Holiday.due_date_from_calendar_days(Date.new(2008, 10, 4), 20).should == Date.new(2008, 10, 24)
            end

            # If the due date would fall on a Saturday it should in fact fall on the next day that isn't a weekend
            # or a holiday
            it "handles the due date falling on a Saturday" do
                Holiday.due_date_from_calendar_days(Date.new(2008, 10, 5), 20).should == Date.new(2008, 10, 27)
            end

            it "handles the due date falling on a Sunday" do
                Holiday.due_date_from_calendar_days(Date.new(2008, 10, 6), 20).should == Date.new(2008, 10, 27)
            end

            it "handles the due date falling on a Monday" do
                Holiday.due_date_from_calendar_days(Date.new(2008, 10, 7), 20).should == Date.new(2008, 10, 27)
            end

            it "handles the due date falling on a day before a Holiday" do
                Holiday.due_date_from_calendar_days(Date.new(2008, 12, 4), 20).should == Date.new(2008, 12, 24)
            end

            it "handles the due date falling on a Holiday" do
                Holiday.due_date_from_calendar_days(Date.new(2008, 12, 5), 20).should == Date.new(2008, 12, 29)
            end

            it "handles Time objects" do
                Holiday.due_date_from_calendar_days(Time.utc(2009, 03, 17, 12, 0, 0), 20).should == Date.new(2009, 4, 6)
            end
        end
    end
end