fossil 0.4.13 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.13
1
+ 0.4.14
data/fossil.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fossil}
8
- s.version = "0.4.13"
8
+ s.version = "0.4.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Patrick Lardin, Daniel Sudol"]
12
- s.date = %q{2010-07-20}
12
+ s.date = %q{2010-08-02}
13
13
  s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
14
14
  s.email = %q{plardin@xojet.com}
15
15
  s.files = [
@@ -132,6 +132,7 @@ Gem::Specification.new do |s|
132
132
  "spec/hash_extentions_spec.rb",
133
133
  "spec/helper_classes.rb",
134
134
  "spec/helper_methods.rb",
135
+ "spec/models/airport_fbo_spec.rb",
135
136
  "spec/models/code_spec.rb",
136
137
  "spec/models/quote_spec.rb",
137
138
  "spec/models/trip_leg_spec.rb",
@@ -168,6 +169,7 @@ Gem::Specification.new do |s|
168
169
  "spec/models/quote_spec.rb",
169
170
  "spec/models/vendor_document_spec.rb",
170
171
  "spec/models/trip_spec.rb",
172
+ "spec/models/airport_fbo_spec.rb",
171
173
  "spec/be_model_with_values_matcher.rb"
172
174
  ]
173
175
 
@@ -5,16 +5,19 @@ class Airport < Sequel::Model(:'airport')
5
5
  # Associations
6
6
  #~ one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival-icao/iata/id'=>3, :'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}")))}
7
7
  one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>self.primary_key, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}"), :'arrival-icao/iata/id'=>3))}
8
- # one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}"), :'arrival-icao/iata/id'=>3))}
9
- #~ one_to_many :trip_leg_departures, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'depart-icao/iata/id'=>1, :'departure icao'=>self[:'icao']).union(TripLeg.filter(:'depart-icao/iata/id'=>2, :'departure iata'=>self[:'iata'])).union(TripLeg.filter(:'depart-icao/iata/id'=>3, :'depart a/p prefix'.like("%#{self[:'airport id prefix']}"), :'depart airport id'.like("%#{self[:'airport id']}")))}
8
+ # one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}"), :'arrival-icao/iata/id'=>3))}
9
+ # one_to_many :trip_leg_departures, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'depart-icao/iata/id'=>1, :'departure icao'=>self[:'icao']).union(TripLeg.filter(:'depart-icao/iata/id'=>2, :'departure iata'=>self[:'iata'])).union(TripLeg.filter(:'depart-icao/iata/id'=>3, :'depart a/p prefix'.like("%#{self[:'airport id prefix']}"), :'depart airport id'.like("%#{self[:'airport id']}")))}
10
10
 
11
- one_to_many :airport_fbos, :class=>:AirportFbo, :key=>self.primary_key, :dataset=>proc{
12
- map = Airport.filter(:iata=>iata).graph( AirportFbo, {:'airport kid - date'=>:kid_date, :'airport kid - time'=>:kid_time,:'airport kid - user'=>:kid_user,:'airport kid - mult'=>:kid_mult,:'airport kid - comm'=>:kid_comm}, :table_alias=>:fbo);
13
- result = map.inject([]){|array, hash| array<<hash[:fbo];array};
14
- def result.all; self; end;
15
- result;
16
- }
11
+ ###### this method works sometimes but only when there is an iata. and there are 17K airports with no iata
12
+ # so its better not to use fossil for this relationship.
13
+ # one_to_many :airport_fbos, :class=>:AirportFbo, :key=>self.primary_key, :dataset=>proc{
14
+ # map = Airport.filter(:iata=>iata).graph( AirportFbo, {:'airport kid - date'=>:kid_date, :'airport kid - time'=>:kid_time,:'airport kid - user'=>:kid_user,:'airport kid - mult'=>:kid_mult,:'airport kid - comm'=>:kid_comm}, :table_alias=>:fbo);
15
+ # result = map.inject([]){|array, hash| array<<hash[:fbo];array};
16
+ # def result.all; self; end;
17
+ # result;
18
+ # }
17
19
 
20
+ o_to_n :airport_fbos, :class=>:AirportFbo, :prefix=>'airport'
18
21
  #### BEGIN GENERATED SECTION ####
19
22
 
20
23
  column_alias :acn_pcn, :'acn pcn'
@@ -5,6 +5,7 @@ class AirportFbo < Sequel::Model(:"airport fbos")
5
5
  o_to_n :trip_legs, :class=>:TripLeg, :prefix=>'fbo'
6
6
  o_to_n :fueled_trip_legs, :class=>:TripLeg, :prefix=>'fueler'
7
7
  o_to_n :airport_fuels, :class=>:AirportFuel, :prefix=>'fbo'
8
+ n_to_o :airport, :class=>:Airport, :prefix=>'airport'
8
9
 
9
10
  #### BEGIN GENERATED SECTION ####
10
11
 
@@ -42,10 +42,15 @@ class TripLeg < Sequel::Model(:'trip legs')
42
42
  many_to_one :departure_airport, :class=>:Airport, :key=>:departure_icao, :primary_key=>:icao #:key=>nil, :dataset=>proc{ ref_method = self[:'depart-icao/iata/id']; case ref_method; when 1 then Airport.filter(:'icao'=>self[:'departure icao']); when 2 then Airport.filter(:'iata'=>self[:'departure iata']); else Airport.filter(:'airport id prefix'.like("%#{self[:'depart a/p prefix']}"), :'airport id'.like("%#{self[:'depart airport id']}")); end }
43
43
  many_to_one :alternate_arrival_airport, :class=>:Airport, :key=>nil, :dataset=>proc{ Airport.filter(:'airport id prefix'.like("%#{self[:'arr alt prefix']}"), :'airport id'.like( "%#{self[:'arr alt id']}"))}
44
44
  many_to_one :alternate_departure_airport, :class=>:Airport, :key=>nil, :dataset=>proc{ Airport.filter(:'airport id prefix'.like("%#{self[:'dep alt prefix']}"), :'airport id'.like( "%#{self[:'dep alt id']}"))}
45
- many_to_one :comment_value, :class=>:Comment, :key=>primary_key#, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>self[:"kid - comm"]) }
46
- many_to_one :departure_fbo_comment_value, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>43) } # must hardcode kid comms for comments
47
- many_to_one :arrival_fbo_comment_value, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>34) } # must hardcode kid comms for comments
48
- many_to_one :catering_comment_value, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>37) }
45
+ many_to_one :departure_fbo_comment_value, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>43) }
46
+ many_to_one :arrival_fbo_comment_value, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>34) }
47
+ many_to_one :departure_catering_comment, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>37) }
48
+ many_to_one :departure_transport_comment, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>41) }
49
+ many_to_one :departure_general_comment, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>183) }
50
+ many_to_one :arrival_catering_comment, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>1) }
51
+ many_to_one :arrival_transport_comment, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>36) }
52
+ many_to_one :arrival_general_comment, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>185) }
53
+
49
54
  many_to_one :limo_comment_value, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>self[:"limo comment"]) }
50
55
  many_to_one :crew_fbo_comment_value, :class=>:Comment, :key=>nil, :dataset=>proc { Comment.filter( :"kid - date"=>self[:"kid - date"], :"kid - time"=>self[:"kid - time"], :"kid - user"=>self[:"kid - user"], :"kid - mult"=>self[:"kid - mult"], :"kid - comm"=>self[:"mics serv 2 comment"]) }
51
56
 
@@ -757,7 +762,7 @@ class TripLeg < Sequel::Model(:'trip legs')
757
762
  def passenger_list
758
763
  return '' if trip__passengers.blank? or is_deadhead?
759
764
  trip__passengers.sort_by{|tp| -tp.lead_pax}.collect do |tp|
760
- if (leg_number >= tp.departure_leg_number and leg_number <= tp.arrival_leg_number)
765
+ if (leg_number >= tp.departure_leg_number and leg_number <= tp.arrival_leg_number) or tp.all_legs == 1
761
766
  tp.name + (tp.lead_pax==1 ? " (lead pax)" : '' )
762
767
  end
763
768
  end.compact.uniq.join(' : ')
@@ -808,4 +813,71 @@ class TripLeg < Sequel::Model(:'trip legs')
808
813
  return 0 unless nautical_miles
809
814
  ((nautical_miles*1.150777*10).to_i)/10.0
810
815
  end
816
+
817
+ # FUEL PASSDOWN STUFF
818
+ def method_missing(method, *args, &block)
819
+ if method.to_s =~ /^(dept_fuel|arr_fuel)/ then # looking for something like dept_fuel_quantity, dept_fuel_rate or arr_fuel_quantity, etc...
820
+ arr = method.to_s.split('_')
821
+ send(:get_fuel_value, arr[0], arr[2])
822
+ else
823
+ super(method, *args, &block)
824
+ end
825
+ end
826
+
827
+ def get_fuel_value type, item
828
+ set_fuel_values type unless instance_variable_get "@#{type}_fuel"
829
+ pow = instance_variable_get "@#{type}_fuel"
830
+ pow[item.to_sym]
831
+ end
832
+
833
+ private
834
+ def set_fuel_values type
835
+ my_type = (type == "arr" ? "ARRIVAL" : "DEPART")
836
+ pow = instance_variable_set "@#{type}_fuel", {}
837
+ pow[:quantity], pow[:rate] = airport_fuel_quantity_and_rate(my_type)
838
+ pow[:cost] = pow[:rate] * pow[:quantity]
839
+ end
840
+
841
+ def airport_fuel_quantity_and_rate type #ARRIVAL or DEPART
842
+ airport_fuel = airport_fuel_lookup type
843
+ (airport_fuel ? [airport_fuel[:quantity], fuel_cost_by_quantity(airport_fuel[:quantity], airport_fuel)]: [0,0])
844
+ end
845
+
846
+ def airport_fuel_lookup type #ARRIVAL or DEPART
847
+ str = (type == "DEPART" ? "DEPT" : type)
848
+ sql = <<-SQL
849
+ SELECT TOP 1 TL."TRIP NUMBER",TL."LEG NUMBER", TL."#{str} DATE GMT", TL."#{type} AIRPORT ID",
850
+ FLE."VENDOR ID", FLE."QUANTITY",
851
+ AF."COST 1", AF."QTY 1", AF."COST 2", AF."QTY 2", AF."COST 3", AF."QTY 3", AF."COST 4", AF."QTY 4",
852
+ AF."COST 5", AF."QTY 5", AF."COST 6", AF."QTY 6", AF."COST 7", AF."QTY 7", AF."COST 8", AF."QTY 8",
853
+ AF."COST 9", AF."QTY 9", AF."COST 10", AF."QTY 10", AF."EFFECTIVE DATE"
854
+ FROM "TRIP LEGS" AS TL inner join "FLIGHT LOG EXPENSES" AS FLE
855
+ ON
856
+ (FLE."TRIP LEG KID - DATE" = TL."KID - DATE" AND FLE."TRIP LEG KID - TIME" = TL."KID - TIME"
857
+ AND FLE."TRIP LEG KID - USER" = TL."KID - USER" AND FLE."TRIP LEG KID - MULT"=TL."KID - MULT"
858
+ AND FLE."TRIP LEG KID - COMM" = TL."KID - COMM" AND FLE."TYPE" = 1)
859
+ LEFT OUTER JOIN "AIRPORT FUEL" AS AF
860
+ ON (AF."VENDOR ID" = FLE."VENDOR ID" AND AF."AIRPORT ID" = TL."DEPART AIRPORT ID" AND AF."EFFECTIVE DATE" <= TL."#{str} DATE GMT")
861
+ AND (TL."TRIP NUMBER" = ? AND TL."LEG NUMBER" = ?)
862
+ ORDER BY AF."EFFECTIVE DATE" DESC
863
+ SQL
864
+ return DB.fetch(sql, trip_number, leg_number).first
865
+ end
866
+
867
+ def build_fuel_tier_hash airport_fuel # creates a hash table of the qty and fuel prices for each tier
868
+ h = Hash.new
869
+ (1..10).each do |n|
870
+ h[airport_fuel[:"qty #{n}"]] = airport_fuel[:"cost #{n}"]
871
+ end
872
+ h
873
+ end
874
+
875
+ def fuel_cost_by_quantity qty, airport_fuel # gives the cost associated with the qty of fuel purchased
876
+ return 0 if qty == nil or qty == 0 or airport_fuel == nil
877
+ h = build_fuel_tier_hash airport_fuel
878
+ h.keys.sort.reverse.each do |key|
879
+ return (h[key] / 100.0) if (qty and key) and qty >= key
880
+ end
881
+ 0
882
+ end
811
883
  end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "airport_fbo associations" do
4
+ it "finds airport" do
5
+ set_fos_db([Airport, AirportFbo])
6
+
7
+ # fbo = AirportFbo["CTAI", 183, 3, 38174, 38] #ODYSSEY AVIATION
8
+ # fbo.name.should == 'ODYSSEY AVIATION'
9
+ # p fbo.values.select{|k,v| k.match(/airport/) }
10
+ # p fbo.airport
11
+
12
+ a = Airport.filter(:icao=>'AGGA').eager_graph(:airport_fbos).limit(1).all.first
13
+ a.airport_fbos.first.name.should == "SOLOMON AIRLINES"
14
+ # a.airport_fbos.first.values
15
+
16
+ end
17
+ end
@@ -114,10 +114,6 @@ describe TripLeg do
114
114
  # @trip_leg = TripLeg.first(~:fueler_comment=>0,~:catering_comment=>0,~:limo_comment=>0)
115
115
  end
116
116
 
117
- it "comment field" do
118
- @trip_leg.comment_value.comment.should =="Contact: Chris Kelley 415-927-2123"
119
- end
120
-
121
117
  it "catering departure value" do
122
118
  @trip_leg.catering_departure.should == 1
123
119
  end
@@ -131,11 +127,11 @@ describe TripLeg do
131
127
  end
132
128
 
133
129
  it "catering comment value" do
134
- @trip_leg.catering_comment_value.comment.should == "Catering: Standard drinks and snacks for all live legs"
130
+ @trip_leg.departure_catering_comment__comment.should == "Catering: Standard drinks and snacks for all live legs"
135
131
  end
136
132
 
137
133
  it "limo comment value" do
138
- @trip_leg.limo_comment_value.comment.should == "Transportation: Passenger arranged for all live legs"
134
+ @trip_leg.arrival_transport_comment__comment.should == "Transportation: Passenger arranged for all live legs"
139
135
  end
140
136
 
141
137
  it "crew fbo comment value" do
@@ -143,5 +139,145 @@ describe TripLeg do
143
139
  end
144
140
  end
145
141
 
142
+ describe "fuel passdown data columns" do
143
+ describe "with airport fuel data" do
144
+ before :each do
145
+ #expect the method airport_fuel_lookup to be called and return a prepopulated hash
146
+ hash_with_airport_fuel = {:"qty 1"=>1, :"cost 1"=>393,
147
+ :"qty 2"=>1000, :"cost 2"=>373,
148
+ :"qty 3"=>2000, :"cost 3"=>362,
149
+ :"qty 4"=>0, :"cost 4"=>0,
150
+ :"qty 5"=>0, :"cost 5"=>0,
151
+ :"qty 6"=>0, :"cost 6"=>0,
152
+ :"qty 7"=>0, :"cost 7"=>0,
153
+ :"qty 8"=>0, :"cost 8"=>0,
154
+ :"qty 9"=>0, :"cost 9"=>0,
155
+ :"qty 10"=>0, :"cost 10"=>0,
156
+ :quantity=>970}
157
+ @tl = TripLeg.new
158
+ mock(@tl).airport_fuel_lookup(is_a(String)).times(2) {hash_with_airport_fuel}
159
+ end
160
+
161
+ it "fuel quantity for leg with airport fuel" do
162
+ @tl.dept_fuel_quantity.should == 970
163
+ @tl.arr_fuel_quantity.should == 970
164
+ end
165
+
166
+ it "fuel rate for leg with airport fuel" do
167
+ @tl.dept_fuel_rate.should == 3.93
168
+ @tl.arr_fuel_rate.should == 3.93
169
+ end
170
+
171
+ it "fuel cost for leg with airport fuel" do
172
+ @tl.dept_fuel_cost.to_s.should == "3812.1"
173
+ @tl.arr_fuel_cost.to_s.should == "3812.1"
174
+ end
175
+ end
176
+
177
+ describe "without airport fuel data" do
178
+ before :each do
179
+ #expect the method airport_fuel_lookup to be called and return a prepopulated hash
180
+ hash_without_airport_fuel = {:quantity=>970}
181
+ @tl = TripLeg.new
182
+ mock(@tl).airport_fuel_lookup(is_a(String)).times(2) {hash_without_airport_fuel}
183
+ end
184
+
185
+ it "fuel quantity for leg without airport fuel" do
186
+ @tl.dept_fuel_quantity.should == 970
187
+ @tl.arr_fuel_quantity.should == 970
188
+ end
189
+
190
+ it "fuel rate for leg without airport fuel" do
191
+ @tl.dept_fuel_rate.should == 0
192
+ @tl.arr_fuel_rate.should == 0
193
+ end
194
+
195
+ it "fuel cost for leg without airport fuel" do
196
+ @tl.dept_fuel_cost.should == 0
197
+ @tl.arr_fuel_cost.should == 0
198
+ end
199
+ end
200
+ end
201
+
202
+ describe "without any data at all" do
203
+ before :each do
204
+ hash_without_any_data = nil
205
+ @tl = TripLeg.new
206
+ mock(@tl).airport_fuel_lookup(is_a(String)).times(2) {hash_without_any_data}
207
+ end
208
+
209
+ it "fuel quantity for leg without any data" do
210
+ @tl.dept_fuel_quantity.should == 0
211
+ @tl.arr_fuel_quantity.should == 0
212
+ end
213
+
214
+ it "fuel rate for leg without any data" do
215
+ @tl.dept_fuel_rate.should == 0
216
+ @tl.arr_fuel_rate.should == 0
217
+ end
218
+
219
+ it "fuel cost for leg without any data" do
220
+ @tl.dept_fuel_cost.should == 0
221
+ @tl.arr_fuel_cost.should == 0
222
+ end
223
+ end
224
+
225
+ # FUEL PASSDOWN SPECS
226
+ describe "different tier pricing selection" do
227
+ it "has fuel qty <= second lowest tier" do
228
+ fuel_data_hash = { :"qty 1"=>1, :"cost 1"=>393,
229
+ :"qty 2"=>1000, :"cost 2"=>373,
230
+ :"qty 3"=>2000, :"cost 3"=>362,
231
+ :"qty 4"=>0, :"cost 4"=>0,
232
+ :"qty 5"=>0, :"cost 5"=>0,
233
+ :"qty 6"=>0, :"cost 6"=>0,
234
+ :"qty 7"=>0, :"cost 7"=>0,
235
+ :"qty 8"=>0, :"cost 8"=>0,
236
+ :"qty 9"=>0, :"cost 9"=>0,
237
+ :"qty 10"=>0, :"cost 10"=>0,
238
+ :quantity=>970}
239
+ tl = TripLeg.new
240
+ mock(tl).airport_fuel_lookup(is_a(String)).times(2) {fuel_data_hash}
241
+ tl.dept_fuel_cost.to_s.should == "3812.1"
242
+ tl.arr_fuel_cost.to_s.should == "3812.1"
243
+ end
244
+
245
+ it "has fuel qty >= highest tier" do
246
+ fuel_data_hash = { :"qty 1"=>1, :"cost 1"=>393,
247
+ :"qty 2"=>1000, :"cost 2"=>373,
248
+ :"qty 3"=>2000, :"cost 3"=>362,
249
+ :"qty 4"=>3000, :"cost 4"=>352,
250
+ :"qty 5"=>4000, :"cost 5"=>342,
251
+ :"qty 6"=>5000, :"cost 6"=>332,
252
+ :"qty 7"=>6000, :"cost 7"=>322,
253
+ :"qty 8"=>7000, :"cost 8"=>312,
254
+ :"qty 9"=>8000, :"cost 9"=>302,
255
+ :"qty 10"=>9000, :"cost 10"=>292,
256
+ :quantity=>10000}
257
+ tl = TripLeg.new
258
+ mock(tl).airport_fuel_lookup(is_a(String)).times(2) {fuel_data_hash}
259
+ tl.dept_fuel_cost.should == 29200
260
+ tl.arr_fuel_cost.should == 29200
261
+ end
262
+
263
+ it "has fuel qty in the middle of fuel tiers" do
264
+ fuel_data_hash = { :"qty 1"=>1, :"cost 1"=>393,
265
+ :"qty 2"=>1000, :"cost 2"=>373,
266
+ :"qty 3"=>2000, :"cost 3"=>362,
267
+ :"qty 4"=>0, :"cost 4"=>0,
268
+ :"qty 5"=>0, :"cost 5"=>0,
269
+ :"qty 6"=>0, :"cost 6"=>0,
270
+ :"qty 7"=>0, :"cost 7"=>0,
271
+ :"qty 8"=>0, :"cost 8"=>0,
272
+ :"qty 9"=>0, :"cost 9"=>0,
273
+ :"qty 10"=>0, :"cost 10"=>0,
274
+ :quantity=>1100}
275
+ tl = TripLeg.new
276
+ mock(tl).airport_fuel_lookup(is_a(String)).times(2) {fuel_data_hash}
277
+ tl.dept_fuel_cost.should == 4103
278
+ tl.arr_fuel_cost.should == 4103
279
+ end
280
+ end
281
+
146
282
  end
147
283
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'lib/fossil'
2
+ gem "rspec", '1.3.0'
2
3
  require 'spec'
3
4
  require 'rr'
4
5
  require 'pp'
@@ -9,7 +10,7 @@ unless defined?(DB_DEMO)
9
10
  DB_DEMO = Sequel.odbc('demodata')#, :loggers=>[Logger.new($stdout)])
10
11
  DB_DEMO.extend(Sequel::Pervasive::DatabaseMethods)
11
12
 
12
- DB_FOS = Sequel.odbc('fos')#, :loggers=>[Logger.new($stdout)])
13
+ DB_FOS = Sequel.odbc('fos', :loggers=>[Logger.new($stdout)])
13
14
  DB_FOS.extend(Sequel::Pervasive::DatabaseMethods)
14
15
  end
15
16
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 13
9
- version: 0.4.13
8
+ - 14
9
+ version: 0.4.14
10
10
  platform: ruby
11
11
  authors:
12
12
  - Patrick Lardin, Daniel Sudol
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-20 00:00:00 -07:00
17
+ date: 2010-08-02 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -185,6 +185,7 @@ files:
185
185
  - spec/hash_extentions_spec.rb
186
186
  - spec/helper_classes.rb
187
187
  - spec/helper_methods.rb
188
+ - spec/models/airport_fbo_spec.rb
188
189
  - spec/models/code_spec.rb
189
190
  - spec/models/quote_spec.rb
190
191
  - spec/models/trip_leg_spec.rb
@@ -245,4 +246,5 @@ test_files:
245
246
  - spec/models/quote_spec.rb
246
247
  - spec/models/vendor_document_spec.rb
247
248
  - spec/models/trip_spec.rb
249
+ - spec/models/airport_fbo_spec.rb
248
250
  - spec/be_model_with_values_matcher.rb