#require_relative '../spec_dbr/spec_helper' require 'spec_helper' describe "FOS Licensing" do before :all do set_fos_db([CityPair]) # set_dbr_db([TripLeg, FlightLogExpense, Aircraft, Vendor, AirportFbo]) # db = Sequel.fos_dbr(:username => 'datamart', :password => 'datap@ss', :adapter => 'mysql', :host => 'hrkdm', :database => 'dbr') # db.loggers=[Logger.new($stdout)] # [TripLeg, FlightLogExpense, Aircraft, Vendor, AirportFbo, AirportFuel].each { |m| m.db = db } end it "exports the fos city pairs table" do File.open("city_pairs.csv", "w") do |f| csv = "" attributes = CityPair.first.keys csv << attributes.to_flat_file_row( :delimeter => ',', :enclosed_by => '"') + "\n" CityPair.find_all.each do |cp| csv << attributes.inject("") {|str, attr| str << "\"#{cp.send(attr)}\"," }.chop + "\n" end f.print(csv) end end #it "pass a block to include?" do #fbos = ["ATLANTIC AVIATION SERVIC", "SIGNATURE FLIGHT SUPPORT", "LANDMARK AVIATION"] #search = "LANDMARK AVIATION EAST" #result = nil #fbos.each do |fbo| #result = fbo and break if search.match(/^#{fbo}.*/) #end #p result #end # it "puts the lotion on the skin" do # legs = TripLeg.fuel_passdown_data(Date.parse('2011-02-06'), Date.parse('2011-02-06'), ["SIGNATURE FLIGHT SUPPORT"]) # p "BLAH BLAH BLAH" # pp legs # l = TripLeg.filter(:'trip number' => 68562, :'leg number' => 1).eager_graph(:flight_log_expenses => :vendor).all.first # p "BLAH BLAH BLAH BLAH" # p l.fuel_expenses.first.vendor # p FlightLogExpense.where(:trip_leg_id => "SEMJ-3-17-39922-1258", :type => 1) # tl = TripLeg.filter(:trip_number=>68562, :leg_number =>1).first # tl = TripLeg.filter(:trip_number => 68562, :leg_number => 1).eager_graph(:fuel_expenses).select_fields(:self => [:trip_number, :leg_number], :fuel_expenses => [:type]).all # tl = TripLeg.filter(:trip_number => 68562, :leg_number => 1).eager_graph(:aircraft).select_fields(:self => [:trip_number, :leg_number], :aircraft => [:tail_number]).all # end # it "gets the user licensing information" do # print UserInformation.select(:users_initials, :mobile_access).sql # end # # it "gets the aircraft licensing information" do # print Aircraft.select(:tail_number, :mobile_access).sql # end end