fossil 0.4.26 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,27 @@
1
- module Sequel
2
- module Metaprogramming
3
- # Defines an class method within a class
4
- def inst_def name, &blk
5
- instance_eval { define_method name, &blk }
6
- end
1
+ # why the lucky stiff's helper for making metaclasses
2
+ # easily available and usable
3
+ class Object
4
+ # The hidden singleton lurks behind everyone
5
+ def metaclass; class << self; self; end; end
6
+ def meta_eval &blk; metaclass.class_eval &blk; end
7
+
8
+ # Adds methods to a metaclass
9
+ def meta_def name, &blk
10
+ meta_eval { define_method name, &blk }
11
+ end
12
+
13
+ def inst_def name, &blk
14
+ define_method name, &blk
15
+ end
16
+
17
+ # Defines an instance method within a class
18
+ def class_def name, &blk
19
+ class_eval { define_method name, &blk }
20
+ end
21
+
22
+ # Defines an class method within a class
23
+ def inst_def name, &blk
24
+ instance_eval { define_method name, &blk }
7
25
  end
8
26
  end
27
+
@@ -135,7 +135,7 @@ class Sequel::Model
135
135
  inst_def datetime_column_name do
136
136
  days = send(:[], date_column) || 0 # nil defaults to 0 days
137
137
  minutes = send(:[], time_column) || 0 # nil defaults to 0 minutes
138
- DateTime.from_fos_date_time(days, minutes) # returns utc time
138
+ DateTime.from_fos_date_time(days, minutes) # returns utc datetime
139
139
  end
140
140
  end
141
141
 
@@ -250,14 +250,14 @@ class Sequel::Model
250
250
  inst_def method_view_name do
251
251
  column_value = send(column_name)
252
252
  return nil unless column_value
253
- Date.from_fos_days(column_value).to_s(:mdy)
253
+ Date.from_fos_days(column_value).strftime('%m/%d/%Y')
254
254
  end
255
255
  method_view_name = method_name.to_s + "_view_mdy_ipc"
256
256
  # method that returns the column value as a Date in mdy format
257
257
  inst_def method_view_name do
258
258
  column_value = send(column_name)
259
259
  return nil unless column_value
260
- date_str = Date.from_fos_days(column_value).to_s(:mdy)
260
+ date_str = Date.from_fos_days(column_value).strftime('%m/%d/%Y')
261
261
  date_str.slice!(3) if date_str[3] == 48 # if the fourth char is 0 ( ascii value 48 ) remove it
262
262
  date_str.slice!(0) if date_str[0] == 48 # if the first char is 0 ( ascii value 48 ) remove it
263
263
  date_str
@@ -96,7 +96,7 @@ module Sequel
96
96
  when :date then
97
97
  Date.from_fos_days(v.to_i)
98
98
  when :time then
99
- Date.from_fos_days(0).to_time.utc + v.to_i.minutes
99
+ DateTime.from_fos_date_time(0,v.to_i)
100
100
  else
101
101
  v = v.unpack('A*')[0] if v.is_a? String
102
102
  super(v)
@@ -1,7 +1,7 @@
1
1
  module Sequel
2
2
  module Serialization
3
3
  def self.included(base)
4
- base.cattr_accessor :include_root_in_json, :instance_writer => false
4
+ # base.cattr_accessor :include_root_in_json, :instance_writer => false
5
5
  base.extend ClassMethods
6
6
  end
7
7
 
@@ -72,11 +72,12 @@ module Sequel
72
72
  # {"comments": [{"body": "Don't think too hard"}],
73
73
  # "title": "So I was thinking"}]}
74
74
  def to_json(options = {})
75
- if include_root_in_json
76
- "{#{self.class.json_class_name}: #{JsonSerializer.new(self, options).to_s}}"
77
- else
78
- JsonSerializer.new(self, options).to_s
79
- end
75
+
76
+ # if include_root_in_json
77
+ # "{#{self.class.json_class_name}: #{JsonSerializer.new(self, options).to_s}}"
78
+ # else
79
+ JsonSerializer.new(self, options).to_s
80
+ # end
80
81
  end
81
82
 
82
83
  # special to_fos_json .. adds the only=> [] option by default, because we are using
@@ -88,10 +89,10 @@ module Sequel
88
89
  to_json(options)
89
90
  end
90
91
 
91
- def from_json(json)
92
- self.attributes = ActiveSupport::JSON.decode(json)
93
- self
94
- end
92
+ # def from_json(json)
93
+ # self.attributes = ActiveSupport::JSON.decode(json)
94
+ # self
95
+ # end
95
96
 
96
97
  class JsonSerializer < Sequel::Serialization::Serializer #:nodoc:
97
98
  def serialize
@@ -107,26 +108,18 @@ module Sequel
107
108
  end
108
109
  end
109
110
 
110
- module ActiveSupport #:nodoc:
111
- module CoreExtensions #:nodoc:
112
- module Array #:nodoc:
113
- module Conversions
114
- def to_fos_json(options = {})
115
- to_json({:only=>[]}.merge(options))
116
- end
117
- end
111
+ class Array #:nodoc:
112
+ def to_fos_json(options = {})
113
+ if first.is_a? Sequel::Model
114
+ collect{ |model| model.fill_hash(options[:methods]) }.to_json
115
+ else
116
+ to_json
118
117
  end
119
118
  end
120
119
  end
121
120
 
122
- module ActiveSupport #:nodoc:
123
- module CoreExtensions #:nodoc:
124
- module Hash #:nodoc:
125
- module Conversions
126
- def to_fos_json(options = {})
127
- to_json({:only=>[]}.merge(options))
128
- end
129
- end
130
- end
121
+ class Hash #:nodoc:
122
+ def to_fos_json(options = {})
123
+ to_json({:only=>[]}.merge(options))
131
124
  end
132
125
  end
@@ -1,4 +1,4 @@
1
- #require 'active_support/json'
1
+ require 'builder'
2
2
 
3
3
  module Sequel
4
4
  module Serialization
@@ -67,16 +67,16 @@ module Sequel
67
67
  end
68
68
 
69
69
  def serializable_record
70
- returning(serializable_record = {}) do
71
- serializable_names.each { |name| serializable_record[name] = @record.send(name) }
72
- add_includes do |association, records, opts|
73
- if records.is_a?(Enumerable)
74
- serializable_record[association] = records.collect { |r| self.class.new(r, opts).serializable_record }
75
- else
76
- serializable_record[association] = self.class.new(records, opts).serializable_record
77
- end
70
+ serializable_record = {}
71
+ serializable_names.each { |name| serializable_record[name] = @record.send(name) }
72
+ add_includes do |association, records, opts|
73
+ if records.is_a?(Enumerable)
74
+ serializable_record[association] = records.collect { |r| self.class.new(r, opts).serializable_record }
75
+ else
76
+ serializable_record[association] = self.class.new(records, opts).serializable_record
78
77
  end
79
78
  end
79
+ serializable_record
80
80
  end
81
81
 
82
82
  def serialize
@@ -229,7 +229,6 @@ module Sequel #:nodoc:
229
229
  end
230
230
 
231
231
  def add_tag(attribute)
232
- # p "add_tag #{attribute} attribute.name=#{attribute.name} options=#{options} options[:skip_types]=#{options[:skip_types]}"
233
232
  builder.tag!(
234
233
  reformat_name(attribute.name),
235
234
  attribute.value.to_s,
@@ -285,14 +284,9 @@ module Sequel #:nodoc:
285
284
  options[:procs] = procs
286
285
  add_procs
287
286
  yield builder if block_given?
288
- # strip_associations if options[:flatten]
289
287
  end
290
288
  end
291
289
 
292
- # def strip_associations
293
- # p @tag_names
294
- # end
295
-
296
290
  class Attribute #:nodoc:
297
291
  attr_reader :name, :value, :type
298
292
 
@@ -369,26 +363,121 @@ module Sequel #:nodoc:
369
363
  end
370
364
  end
371
365
 
372
- module ActiveSupport #:nodoc:
373
- module CoreExtensions #:nodoc:
374
- module Array #:nodoc:
375
- module Conversions
376
- def to_fos_xml(options = {})
377
- to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]}.merge(options))
378
- end
379
- end
366
+ class Array
367
+ # Returns a string that represents this array in XML by sending +to_xml+
368
+ # to each element. Active Record collections delegate their representation
369
+ # in XML to this method.
370
+ #
371
+ # All elements are expected to respond to +to_xml+, if any of them does
372
+ # not an exception is raised.
373
+ #
374
+ # The root node reflects the class name of the first element in plural
375
+ # if all elements belong to the same type and that's not Hash:
376
+ #
377
+ # customer.projects.to_xml
378
+ #
379
+ # <?xml version="1.0" encoding="UTF-8"?>
380
+ # <projects type="array">
381
+ # <project>
382
+ # <amount type="decimal">20000.0</amount>
383
+ # <customer-id type="integer">1567</customer-id>
384
+ # <deal-date type="date">2008-04-09</deal-date>
385
+ # ...
386
+ # </project>
387
+ # <project>
388
+ # <amount type="decimal">57230.0</amount>
389
+ # <customer-id type="integer">1567</customer-id>
390
+ # <deal-date type="date">2008-04-15</deal-date>
391
+ # ...
392
+ # </project>
393
+ # </projects>
394
+ #
395
+ # Otherwise the root element is "records":
396
+ #
397
+ # [{:foo => 1, :bar => 2}, {:baz => 3}].to_xml
398
+ #
399
+ # <?xml version="1.0" encoding="UTF-8"?>
400
+ # <records type="array">
401
+ # <record>
402
+ # <bar type="integer">2</bar>
403
+ # <foo type="integer">1</foo>
404
+ # </record>
405
+ # <record>
406
+ # <baz type="integer">3</baz>
407
+ # </record>
408
+ # </records>
409
+ #
410
+ # If the collection is empty the root element is "nil-classes" by default:
411
+ #
412
+ # [].to_xml
413
+ #
414
+ # <?xml version="1.0" encoding="UTF-8"?>
415
+ # <nil-classes type="array"/>
416
+ #
417
+ # To ensure a meaningful root element use the <tt>:root</tt> option:
418
+ #
419
+ # customer_with_no_projects.projects.to_xml(:root => "projects")
420
+ #
421
+ # <?xml version="1.0" encoding="UTF-8"?>
422
+ # <projects type="array"/>
423
+ #
424
+ # By default root children have as node name the one of the root
425
+ # singularized. You can change it with the <tt>:children</tt> option.
426
+ #
427
+ # The +options+ hash is passed downwards:
428
+ #
429
+ # Message.all.to_xml(:skip_types => true)
430
+ #
431
+ # <?xml version="1.0" encoding="UTF-8"?>
432
+ # <messages>
433
+ # <message>
434
+ # <created-at>2008-03-07T09:58:18+01:00</created-at>
435
+ # <id>1</id>
436
+ # <name>1</name>
437
+ # <updated-at>2008-03-07T09:58:18+01:00</updated-at>
438
+ # <user-id>1</user-id>
439
+ # </message>
440
+ # </messages>
441
+ #
442
+ def to_xml(options = {})
443
+ raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml }
444
+ require 'builder' unless defined?(Builder)
445
+
446
+ options = options.dup
447
+ options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.name.underscore.pluralize.tr('/', '_') : "records"
448
+ options[:children] ||= options[:root].singularize
449
+ options[:indent] ||= 2
450
+ options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
451
+
452
+ root = options.delete(:root).to_s
453
+ children = options.delete(:children)
454
+
455
+ if !options.has_key?(:dasherize) || options[:dasherize]
456
+ root = root.dasherize
457
+ end
458
+
459
+ options[:builder].instruct! unless options.delete(:skip_instruct)
460
+
461
+ opts = options.merge({ :root => children })
462
+
463
+ xml = options[:builder]
464
+ if empty?
465
+ xml.tag!(root, options[:skip_types] ? {} : {:type => "array"})
466
+ else
467
+ xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) {
468
+ yield xml if block_given?
469
+ each { |e| e.to_xml(opts.merge({ :skip_instruct => true })) }
470
+ }
380
471
  end
381
472
  end
473
+
474
+ def to_fos_xml(options = {})
475
+ to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]}.merge(options))
476
+ end
382
477
  end
383
478
 
384
- module ActiveSupport #:nodoc:
385
- module CoreExtensions #:nodoc:
386
- module Hash #:nodoc:
387
- module Conversions
388
- def to_fos_xml(options = {})
389
- to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]}.merge(options))
390
- end
391
- end
392
- end
479
+ class Hash
480
+ def to_fos_xml(options = {})
481
+ to_xml({:skip_instruct=>true, :skip_types=>true, :dasherize=>false, :only=>[]}.merge(options))
393
482
  end
394
483
  end
@@ -40,12 +40,12 @@ module HelperMethods
40
40
  response.body.should == "xml"
41
41
  end
42
42
 
43
- def equal_xml(other)
44
- simple_matcher("xml #{other} not equal") do |actual|
45
- actual.gsub(/\s/,'').should == other.gsub(/\s/,'')
46
- end
47
- end
48
-
43
+ # def equal_xml(other)
44
+ # simple_matcher("xml #{other} not equal") do |actual|
45
+ # actual.gsub(/\s/,'').should == other.gsub(/\s/,'')
46
+ # end
47
+ # end
48
+ #
49
49
  def stub_save_for_model(model)
50
50
  stub.instance_of(model)._refresh(anything) {}
51
51
  stub.instance_of(model)._update(anything) {}
@@ -2,85 +2,85 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe TripLeg do
4
4
 
5
- describe "arrival_airport assoc works" do
6
- before :all do
7
- set_fos_db([Airport])
8
- end
9
-
10
- it "when there is an arrival_icao" do
11
- trip_leg = TripLeg.new(:arrival_icao=>'KSFO')
12
- trip_leg.arrival_airport.should_not == nil
13
- end
14
-
15
- it "when there is no arrival_icao but there is arrival_ap_prefix and arrival_airport_id" do
16
- trip_leg = TripLeg.new(:arrival_icao=>'', :arrival_ap_prefix=>'K', :arrival_airport_id=>'SFO')
17
- trip_leg.arrival_airport.should_not == nil
18
- end
19
-
20
- it "when there is no arrival_ap_prefix or arrival_airport_id" do
21
- trip_leg = TripLeg.new(:arrival_icao=>'', :arrival_ap_prefix=>'', :arrival_airport_id=>'')
22
- trip_leg.arrival_airport.should == nil
23
- end
24
- end
25
-
26
- describe "departure_airport assoc works" do
27
- before :all do
28
- set_fos_db([Airport])
29
- end
30
-
31
- it "when there is an departure_icao" do
32
- trip_leg = TripLeg.new(:departure_icao=>'KSFO')
33
- trip_leg.departure_airport.should_not == nil
34
- end
35
-
36
- it "when there is no departure_icao but there is depart_ap_prefix and depart_airport_id" do
37
- trip_leg = TripLeg.new(:departure_icao=>'', :depart_ap_prefix=>'K', :depart_airport_id=>'SFO')
38
- trip_leg.departure_airport.should_not == nil
39
- end
40
-
41
- it "when there is no departure_icao or arrival_ap_prefix or arrival_airport_id" do
42
- trip_leg = TripLeg.new(:departure_icao=>'', :depart_ap_prefix=>'', :depart_airport_id=>'')
43
- trip_leg.departure_airport.should == nil
44
- end
45
- end
46
-
47
- it "ebt_time method produces correct Time with minutes" do
48
- dept_date_act_gmt = Date.new(2000, 1, 1)
49
- tl = TripLeg.new(:arrival_date_gmt=>dept_date_act_gmt.to_fos_days, :eta_gmt=>40,
50
- :dept_date_gmt=>dept_date_act_gmt.to_fos_days, :etd_gmt=>20)
51
- tl.ebt_time.should == Time.from_minutes(20)
52
- end
53
-
54
- it "ebt_time method produces correct Time with minutes" do
55
- dept_date_act_gmt = Date.new(2000, 1, 1)
56
- tl = TripLeg.new(:arrival_date_gmt=>dept_date_act_gmt.to_fos_days, :eta_gmt=>40,
57
- :dept_date_gmt=>dept_date_act_gmt.to_fos_days, :etd_gmt=>20)
58
- tl.ebt_time.should == Time.from_minutes(20)
59
- end
60
-
61
- it "actual take off date_time dates are after dept_date_act_gmt if take off time is less than depart time" do
62
- dept_date_act_gmt = Date.new(1900, 1, 1)
63
- tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days, :t_o_time_act_gmt=>20, :dept_time_act_gmt=>1420)
64
- tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900, 1, 2, 0, 20, 0)
65
- end
66
-
67
- it "actual take off date_time dates are the same as dept_date_act_gmt if take off time is not less than depart time" do
68
- dept_date_act_gmt = Date.new(1900, 1, 1)
69
- tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days, :t_o_time_act_gmt=>40, :dept_time_act_gmt=>20)
70
- tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900, 1, 1, 0, 40, 0)
71
- end
72
-
73
- it "actual landing date_time dates are before arr_date_act_gmt if on time time is greater than landing time" do
74
- arr_date_act_gmt = Date.new(1900, 1, 2)
75
- tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days, :land_time_act_gmt=>1420, :arriv_time_act_gmt=>20)
76
- tl.actual_land_date_time_gmt.should == DateTime.new(1900, 1, 1, 23, 40, 0)
77
- end
78
-
79
- it "actual landing date_time dates are the same as arr_date_act_gmt if on time time is not greater than landing time" do
80
- arr_date_act_gmt = Date.new(1900, 1, 2)
81
- tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days, :land_time_act_gmt=>20, :arriv_time_act_gmt=>40)
82
- tl.actual_land_date_time_gmt.should == DateTime.new(1900, 1, 2, 0, 20, 0)
83
- end
5
+ # describe "arrival_airport assoc works" do
6
+ # before :all do
7
+ # set_fos_db([Airport])
8
+ # end
9
+ #
10
+ # it "when there is an arrival_icao" do
11
+ # trip_leg = TripLeg.new(:arrival_icao=>'KSFO')
12
+ # trip_leg.arrival_airport.should_not == nil
13
+ # end
14
+ #
15
+ # it "when there is no arrival_icao but there is arrival_ap_prefix and arrival_airport_id" do
16
+ # trip_leg = TripLeg.new(:arrival_icao=>'', :arrival_ap_prefix=>'K', :arrival_airport_id=>'SFO')
17
+ # trip_leg.arrival_airport.should_not == nil
18
+ # end
19
+ #
20
+ # it "when there is no arrival_ap_prefix or arrival_airport_id" do
21
+ # trip_leg = TripLeg.new(:arrival_icao=>'', :arrival_ap_prefix=>'', :arrival_airport_id=>'')
22
+ # trip_leg.arrival_airport.should == nil
23
+ # end
24
+ # end
25
+ #
26
+ # describe "departure_airport assoc works" do
27
+ # before :all do
28
+ # set_fos_db([Airport])
29
+ # end
30
+ #
31
+ # it "when there is an departure_icao" do
32
+ # trip_leg = TripLeg.new(:departure_icao=>'KSFO')
33
+ # trip_leg.departure_airport.should_not == nil
34
+ # end
35
+ #
36
+ # it "when there is no departure_icao but there is depart_ap_prefix and depart_airport_id" do
37
+ # trip_leg = TripLeg.new(:departure_icao=>'', :depart_ap_prefix=>'K', :depart_airport_id=>'SFO')
38
+ # trip_leg.departure_airport.should_not == nil
39
+ # end
40
+ #
41
+ # it "when there is no departure_icao or arrival_ap_prefix or arrival_airport_id" do
42
+ # trip_leg = TripLeg.new(:departure_icao=>'', :depart_ap_prefix=>'', :depart_airport_id=>'')
43
+ # trip_leg.departure_airport.should == nil
44
+ # end
45
+ # end
46
+ #
47
+ # it "ebt_time method produces correct Time with minutes" do
48
+ # dept_date_act_gmt = Date.new(2000, 1, 1)
49
+ # tl = TripLeg.new(:arrival_date_gmt=>dept_date_act_gmt.to_fos_days, :eta_gmt=>40,
50
+ # :dept_date_gmt=>dept_date_act_gmt.to_fos_days, :etd_gmt=>20)
51
+ # tl.ebt_time.should == Time.from_minutes(20)
52
+ # end
53
+ #
54
+ # it "ebt_time method produces correct Time with minutes" do
55
+ # dept_date_act_gmt = Date.new(2000, 1, 1)
56
+ # tl = TripLeg.new(:arrival_date_gmt=>dept_date_act_gmt.to_fos_days, :eta_gmt=>40,
57
+ # :dept_date_gmt=>dept_date_act_gmt.to_fos_days, :etd_gmt=>20)
58
+ # tl.ebt_time.should == Time.from_minutes(20)
59
+ # end
60
+ #
61
+ # it "actual take off date_time dates are after dept_date_act_gmt if take off time is less than depart time" do
62
+ # dept_date_act_gmt = Date.new(1900, 1, 1)
63
+ # tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days, :t_o_time_act_gmt=>20, :dept_time_act_gmt=>1420)
64
+ # tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900, 1, 2, 0, 20, 0)
65
+ # end
66
+ #
67
+ # it "actual take off date_time dates are the same as dept_date_act_gmt if take off time is not less than depart time" do
68
+ # dept_date_act_gmt = Date.new(1900, 1, 1)
69
+ # tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days, :t_o_time_act_gmt=>40, :dept_time_act_gmt=>20)
70
+ # tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900, 1, 1, 0, 40, 0)
71
+ # end
72
+ #
73
+ # it "actual landing date_time dates are before arr_date_act_gmt if on time time is greater than landing time" do
74
+ # arr_date_act_gmt = Date.new(1900, 1, 2)
75
+ # tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days, :land_time_act_gmt=>1420, :arriv_time_act_gmt=>20)
76
+ # tl.actual_land_date_time_gmt.should == DateTime.new(1900, 1, 1, 23, 40, 0)
77
+ # end
78
+ #
79
+ # it "actual landing date_time dates are the same as arr_date_act_gmt if on time time is not greater than landing time" do
80
+ # arr_date_act_gmt = Date.new(1900, 1, 2)
81
+ # tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days, :land_time_act_gmt=>20, :arriv_time_act_gmt=>40)
82
+ # tl.actual_land_date_time_gmt.should == DateTime.new(1900, 1, 2, 0, 20, 0)
83
+ # end
84
84
 
85
85
  it "actual arrival date_time base are correctly calculating the tz offset" do
86
86
  arr_date_act_gmt = Date.new(1900, 1, 2)
@@ -91,102 +91,102 @@ describe TripLeg do
91
91
  tl.actual_arrival_date_time_base.should == DateTime.new(1900, 1, 2, 16, 40, 0)
92
92
  end
93
93
 
94
- it "actual departure date_time base are correctly calculating the tz offset" do
95
- dept_date_act_gmt = Date.new(1900, 1, 2)
96
- dept_time_act_gmt = 1420
97
- home_tz_gmt_offset = -70
98
- tl = TripLeg.new(:dept_date_act_gmt => dept_date_act_gmt.to_fos_days, :dept_time_act_gmt => dept_time_act_gmt,
99
- :home_tz_gmt_offset=>home_tz_gmt_offset)
100
- tl.actual_departure_date_time_base.should == DateTime.new(1900, 1, 2, 16, 40, 0)
101
- end
102
-
103
- it "should properly convert nautical miles to statute miles with 1 significant digit" do
104
- tl = TripLeg.new(:nautical_miles => 285)
105
- tl.custom_statute_miles.should == 327.9
106
- end
107
-
108
- it "should properly handle nautical miles to statute miles when nautical_miles is nil" do
109
- tl = TripLeg.new(:nautical_miles => nil)
110
- tl.custom_statute_miles.should == 0
111
- end
112
-
113
- describe "should find correct passenger list" do
114
- before :each do
115
- @p1 = TripPassenger.new(:name=>"dan", :departure_leg_number=>0, :arrival_leg_number=>0, :lead_pax=>0)
116
- @p2 = TripPassenger.new(:name=>"rob", :departure_leg_number=>1, :arrival_leg_number=>1, :lead_pax=>0)
117
- @p3 = TripPassenger.new(:name=>"eric", :departure_leg_number=>1, :arrival_leg_number=>2, :lead_pax=>1)
118
- @t = Trip.new(:trip_number=>100)
119
- end
120
-
121
- it "when leg has no passengers" do
122
- mock(@t).passengers { [] }
123
- tl = TripLeg.new(:trip_number=>100, :leg_number=>1, :trip=>@t)
124
- tl.passenger_list.should == ''
125
- end
126
-
127
- ## it "when leg has no pax/deadhead" do
128
- ## tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t, :status=>1,:deadhead=>1)
129
- ## tl.passenger_list.should == ''
130
- ## end
131
-
132
- it "when leg has some in range ( and put lead pax name first )" do
133
- stub(@t).passengers { [@p1, @p2, @p3] }
134
- tl = TripLeg.new(:trip_number=>100, :leg_number=>1, :verify_date=>0, :trip=>@t)
135
- tl.passenger_list.should == "eric (lead pax) : rob"
136
- end
137
-
138
- it "when leg has 1 in range" do
139
- stub(@t).passengers { [@p1, @p2, @p3] }
140
- tl = TripLeg.new(:trip_number=>100, :leg_number=>2, :verify_date=>0, :trip=>@t)
141
- tl.passenger_list.should == "eric (lead pax)"
142
- end
143
-
144
- it "when leg has none in range" do
145
- stub(@t).passengers { [@p1, @p2, @p3] }
146
- tl = TripLeg.new(:trip_number=>100, :leg_number=>3, :verify_date=>0, :trip=>@t)
147
- tl.passenger_list.should == ""
148
- end
149
-
150
- end
151
-
152
- it "method total_trip_statute_miles returns a value" do
153
- @t = Trip.new(:total_statute_miles=>100)
154
- tl = TripLeg.new(:trip_number=>100, :leg_number=>3, :trip=>@t)
155
- tl.total_trip_statute_miles.should == 10.0
156
- end
157
-
158
- describe 'crew brief fields' do
159
- before :all do
160
- set_fos_db([TripLeg, Comment])
161
- @trip_leg = TripLeg.first(:trip_number=>50885, :leg_number=>1)
162
- # @trip_leg = TripLeg.first(:trip_number=>76478,:leg_number=>1)
163
- # @trip_leg = TripLeg.first(~:fueler_comment=>0,~:catering_comment=>0,~:limo_comment=>0)
164
- end
165
-
166
- it "catering departure value" do
167
- @trip_leg.catering_departure.should == 1
168
- end
169
-
170
- it "departure fbo comment value" do
171
- @trip_leg.departure_fbo_comment_value.comment.should == "3028 Peacekeeper Way\r\nSacramento, CA 95652"
172
- end
173
-
174
- it "arrival fbo comment value" do
175
- @trip_leg.arrival_fbo_comment_value.comment.should == "Auto-selected FBO not preferred"
176
- end
177
-
178
- it "catering comment value" do
179
- @trip_leg.departure_catering_comment__comment.should == "Catering: Standard drinks and snacks for all live legs"
180
- end
181
-
182
- it "limo comment value" do
183
- @trip_leg.arrival_transport_comment__comment.should == "Transportation: Passenger arranged for all live legs"
184
- end
185
-
186
- it "crew fbo comment value" do
187
- @trip_leg.crew_fbo_comment_value.should == nil
188
- end
189
- end
94
+ # it "actual departure date_time base are correctly calculating the tz offset" do
95
+ # dept_date_act_gmt = Date.new(1900, 1, 2)
96
+ # dept_time_act_gmt = 1420
97
+ # home_tz_gmt_offset = -70
98
+ # tl = TripLeg.new(:dept_date_act_gmt => dept_date_act_gmt.to_fos_days, :dept_time_act_gmt => dept_time_act_gmt,
99
+ # :home_tz_gmt_offset=>home_tz_gmt_offset)
100
+ # tl.actual_departure_date_time_base.should == DateTime.new(1900, 1, 2, 16, 40, 0)
101
+ # end
102
+ #
103
+ # it "should properly convert nautical miles to statute miles with 1 significant digit" do
104
+ # tl = TripLeg.new(:nautical_miles => 285)
105
+ # tl.custom_statute_miles.should == 327.9
106
+ # end
107
+ #
108
+ # it "should properly handle nautical miles to statute miles when nautical_miles is nil" do
109
+ # tl = TripLeg.new(:nautical_miles => nil)
110
+ # tl.custom_statute_miles.should == 0
111
+ # end
112
+ #
113
+ # describe "should find correct passenger list" do
114
+ # before :each do
115
+ # @p1 = TripPassenger.new(:name=>"dan", :departure_leg_number=>0, :arrival_leg_number=>0, :lead_pax=>0)
116
+ # @p2 = TripPassenger.new(:name=>"rob", :departure_leg_number=>1, :arrival_leg_number=>1, :lead_pax=>0)
117
+ # @p3 = TripPassenger.new(:name=>"eric", :departure_leg_number=>1, :arrival_leg_number=>2, :lead_pax=>1)
118
+ # @t = Trip.new(:trip_number=>100)
119
+ # end
120
+ #
121
+ # it "when leg has no passengers" do
122
+ # mock(@t).passengers { [] }
123
+ # tl = TripLeg.new(:trip_number=>100, :leg_number=>1, :trip=>@t)
124
+ # tl.passenger_list.should == ''
125
+ # end
126
+ #
127
+ ### it "when leg has no pax/deadhead" do
128
+ ### tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t, :status=>1,:deadhead=>1)
129
+ ### tl.passenger_list.should == ''
130
+ ### end
131
+ #
132
+ # it "when leg has some in range ( and put lead pax name first )" do
133
+ # stub(@t).passengers { [@p1, @p2, @p3] }
134
+ # tl = TripLeg.new(:trip_number=>100, :leg_number=>1, :verify_date=>0, :trip=>@t)
135
+ # tl.passenger_list.should == "eric (lead pax) : rob"
136
+ # end
137
+ #
138
+ # it "when leg has 1 in range" do
139
+ # stub(@t).passengers { [@p1, @p2, @p3] }
140
+ # tl = TripLeg.new(:trip_number=>100, :leg_number=>2, :verify_date=>0, :trip=>@t)
141
+ # tl.passenger_list.should == "eric (lead pax)"
142
+ # end
143
+ #
144
+ # it "when leg has none in range" do
145
+ # stub(@t).passengers { [@p1, @p2, @p3] }
146
+ # tl = TripLeg.new(:trip_number=>100, :leg_number=>3, :verify_date=>0, :trip=>@t)
147
+ # tl.passenger_list.should == ""
148
+ # end
149
+ #
150
+ # end
151
+ #
152
+ # it "method total_trip_statute_miles returns a value" do
153
+ # @t = Trip.new(:total_statute_miles=>100)
154
+ # tl = TripLeg.new(:trip_number=>100, :leg_number=>3, :trip=>@t)
155
+ # tl.total_trip_statute_miles.should == 10.0
156
+ # end
157
+ #
158
+ # describe 'crew brief fields' do
159
+ # before :all do
160
+ # set_fos_db([TripLeg, Comment])
161
+ # @trip_leg = TripLeg.first(:trip_number=>50885, :leg_number=>1)
162
+ ## @trip_leg = TripLeg.first(:trip_number=>76478,:leg_number=>1)
163
+ ## @trip_leg = TripLeg.first(~:fueler_comment=>0,~:catering_comment=>0,~:limo_comment=>0)
164
+ # end
165
+ #
166
+ # it "catering departure value" do
167
+ # @trip_leg.catering_departure.should == 1
168
+ # end
169
+ #
170
+ # it "departure fbo comment value" do
171
+ # @trip_leg.departure_fbo_comment_value.comment.should == "3028 Peacekeeper Way\r\nSacramento, CA 95652"
172
+ # end
173
+ #
174
+ # it "arrival fbo comment value" do
175
+ # @trip_leg.arrival_fbo_comment_value.comment.should == "Auto-selected FBO not preferred"
176
+ # end
177
+ #
178
+ # it "catering comment value" do
179
+ # @trip_leg.departure_catering_comment__comment.should == "Catering: Standard drinks and snacks for all live legs"
180
+ # end
181
+ #
182
+ # it "limo comment value" do
183
+ # @trip_leg.arrival_transport_comment__comment.should == "Transportation: Passenger arranged for all live legs"
184
+ # end
185
+ #
186
+ # it "crew fbo comment value" do
187
+ # @trip_leg.crew_fbo_comment_value.should == nil
188
+ # end
189
+ # end
190
190
 
191
191
  ## NEED TO REMOVE, TESTS SHOULD BE IN FlightLogExpense spec
192
192
  # describe "fuel passdown data columns" do