def test_send
msg 'Testing send'
from = 'admin'
recipient = 'valcker'
ajaxIM = AjaxIM.new(@db, from, recipient, '')
responce = ajaxIM.send(Hash.new)
assert_match('not_online', responce, 'User must be offline')
@db.query("INSERT INTO {ajaxim_status} SET status=100, uid=1, last_ping=#{Time.now.to_i.to_s}, last_status=0")
from = 'valcker'
recipient = 'admin'
ajaxIM = AjaxIM.new(@db, from, recipient, '')
responce = ajaxIM.send(Hash.new)
assert(responce.nil?, 'Responce should be nil for empty messages')
ajaxIM = AjaxIM.new(@db, from, recipient, 'a'*1501)
responce = ajaxIM.send(Hash.new)
assert_match('too_long', responce, 'Responce should be too_long for messages > 1500')
ajaxIM = AjaxIM.new(@db, from, recipient, 'Hello world')
responce = ajaxIM.send(Hash.new)
assert_match('sent', responce, 'All params are OK, responce should be "sent"')
params = {
'font' => 'tahoma',
'font_size' => 20,
'font_color' => 'black',
'font_bold' => false,
'font_italic' => false,
'font_underline' => true
}
ajaxIM = AjaxIM.new(@db, from, recipient, 'Hi there')
responce = ajaxIM.send(params)
puts responce
res = @db.query('SELECT * FROM {ajaxim_messages} ORDER BY id DESC').fetch_hash
puts res['message']
end