Added unit tests.

This commit is contained in:
Martin Edenhofer 2014-08-23 15:42:25 +02:00
parent dbcc5414cf
commit 2401d860cd

View file

@ -0,0 +1,59 @@
# encoding: utf-8
require 'test_helper'
class RecentViewTest < ActiveSupport::TestCase
test 'simple tests' do
ticket1 = Ticket.create(
:title => 'RecentViewTest 1 some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:state => Ticket::State.lookup( :name => 'new' ),
:priority => Ticket::Priority.lookup( :name => '2 normal' ),
:updated_by_id => 1,
:created_by_id => 1,
)
assert( ticket1, "ticket created" )
ticket2 = Ticket.create(
:title => 'RecentViewTest 2 some title äöüß',
:group => Group.lookup( :name => 'Users'),
:customer_id => 2,
:state => Ticket::State.lookup( :name => 'new' ),
:priority => Ticket::Priority.lookup( :name => '2 normal' ),
:updated_by_id => 1,
:created_by_id => 1,
)
assert( ticket2, "ticket created" )
user1 = User.find(2)
#RecentView.user_log_destroy(user1)
RecentView.log( ticket1, user1 )
sleep 1
RecentView.log( ticket2, user1 )
sleep 1
RecentView.log( ticket1, user1 )
sleep 1
RecentView.log( ticket1, user1 )
list = RecentView.list( user1 )
assert( list[0]['o_id'], ticket1.id )
assert( list[0]['recent_view_object'], 'Ticket' )
assert( list[1]['o_id'], ticket1.id )
assert( list[1]['recent_view_object'], 'Ticket' )
assert( list[2]['o_id'], ticket2.id )
assert( list[2]['recent_view_object'], 'Ticket' )
assert( list[3]['o_id'], ticket1.id )
assert( list[3]['recent_view_object'], 'Ticket' )
ticket1.destroy
ticket2.destroy
#list = RecentView.list( user1 )
#assert( !list[0], 'check if recent view list is empty' )
end
end