Sha256: df0093e4f8679c0d1efaef0b0bbd0efdde8ccb0744c37d0d796c1d7b4deb6b49

Contents?: true

Size: 1.74 KB

Versions: 19

Compression:

Stored size: 1.74 KB

Contents

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

describe "OpenallTimeApplet" do
  it "should be able to start" do
    begin
      $tmp_path = "/tmp/openall_spec.sqlite3"
      File.unlink($tmp_path) if File.exists?($tmp_path)
      Openall_time_applet::CONFIG[:db_path] = $tmp_path
      $oata = Openall_time_applet.new
      
      Knj::Opts.set("openall_host", "192.168.56.54")
      Knj::Opts.set("openall_port", 80)
      Knj::Opts.set("openall_username", "kaspernj")
      Knj::Opts.set("openall_password", Base64.strict_encode64("123"))
      Knj::Opts.set("openall_ssl", 0)
    rescue Exception => e
      STDOUT.print Knj::Errors.error_str(e)
    end
  end
  
  it "should only return a specific amount of timelogs for tray-icon" do
    $oata.sync_static
    sleep 1
    raise "A new message box was shown: '#{Knj::Gtk2::Msgbox.cur_label}'." if Knj::Gtk2::Msgbox.shown?
    
    task = $oata.ob.get_by(:Task, "openall_uid_not" => ["", 0])
    raise "No task could be found?" if !task
    
    idstr = Digest::MD5.hexdigest(Time.now.to_f.to_s)
    titlestr = "Tlog test #{idstr}"
    
    tlog = $oata.ob.add(:Timelog,
      :descr => titlestr,
      :sync_need => 1,
      :task_id => task.id,
      :time => Knj::Strings.human_time_str_to_secs("01:30:15"),
      :time_sync => Knj::Strings.human_time_str_to_secs("01:30:30")
    )
    
    $oata.sync_real
    $oata.sync_static
    sleep 1
    
    worktime = $oata.ob.get_by(:Worktime, "comment" => titlestr)
    raise "Could not find synced worktime." if !worktime
    raise "Expected synced worktime to be '5430' but it was '#{worktime[:worktime]}'." if worktime[:worktime].to_i != 5430
  end
  
  it "should remove the temp db" do
    File.unlink($tmp_path) if File.exists?($tmp_path)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
openall_time_applet-0.0.45 spec/sync_spec.rb
openall_time_applet-0.0.44 spec/sync_spec.rb
openall_time_applet-0.0.43 spec/sync_spec.rb
openall_time_applet-0.0.42 spec/sync_spec.rb
openall_time_applet-0.0.41 spec/sync_spec.rb
openall_time_applet-0.0.40 spec/sync_spec.rb
openall_time_applet-0.0.38 spec/sync_spec.rb
openall_time_applet-0.0.37 spec/sync_spec.rb
openall_time_applet-0.0.36 spec/sync_spec.rb
openall_time_applet-0.0.35 spec/sync_spec.rb
openall_time_applet-0.0.34 spec/sync_spec.rb
openall_time_applet-0.0.33 spec/sync_spec.rb
openall_time_applet-0.0.32 spec/sync_spec.rb
openall_time_applet-0.0.31 spec/sync_spec.rb
openall_time_applet-0.0.30 spec/sync_spec.rb
openall_time_applet-0.0.29 spec/sync_spec.rb
openall_time_applet-0.0.28 spec/sync_spec.rb
openall_time_applet-0.0.27 spec/sync_spec.rb
openall_time_applet-0.0.26 spec/sync_spec.rb