From e349ab8e48b9c0a3b93bd55a5589ff83765ac68b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 7 Nov 2012 15:50:52 +0100 Subject: [PATCH] Improved some unit tests. --- test/unit/history_test.rb | 53 +++++++++++++++++++++------------------ test/unit/user_test.rb | 7 ++++++ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/test/unit/history_test.rb b/test/unit/history_test.rb index e6ebacb3d..93c7202ed 100644 --- a/test/unit/history_test.rb +++ b/test/unit/history_test.rb @@ -15,9 +15,11 @@ class HistoryTest < ActiveSupport::TestCase :title => 'Unit Test 1 (äöüß)!', :ticket_state_id => Ticket::State.where( :name => 'new' ).first.id, :ticket_priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id, - :created_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id + :updated_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, + :created_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, }, :article => { + :updated_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, :created_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, :ticket_article_type_id => Ticket::Article::Type.where(:name => 'phone' ).first.id, :ticket_article_sender_id => Ticket::Article::Sender.where(:name => 'Customer' ).first.id, @@ -39,20 +41,20 @@ class HistoryTest < ActiveSupport::TestCase :history_type => 'created', }, { - :history_object => 'Ticket', - :history_type => 'updated', + :history_object => 'Ticket', + :history_type => 'updated', :history_attribute => 'title', - :value_from => 'Unit Test 1 (äöüß)!', - :value_to => 'Unit Test 1 (äöüß) - update!', + :value_from => 'Unit Test 1 (äöüß)!', + :value_to => 'Unit Test 1 (äöüß) - update!', }, { - :history_object => 'Ticket', - :history_type => 'updated', + :history_object => 'Ticket', + :history_type => 'updated', :history_attribute => 'ticket_state', - :value_from => 'new', - :value_to => 'open', - :id_from => Ticket::State.where( :name => 'new' ).first.id, - :id_to => Ticket::State.where( :name => 'open' ).first.id, + :value_from => 'new', + :value_to => 'open', + :id_from => Ticket::State.where( :name => 'new' ).first.id, + :id_to => Ticket::State.where( :name => 'open' ).first.id, }, { :history_object => 'Ticket::Article', @@ -60,7 +62,7 @@ class HistoryTest < ActiveSupport::TestCase }, ] }, - + # test 2 { :ticket_create => { @@ -71,10 +73,12 @@ class HistoryTest < ActiveSupport::TestCase :title => 'Unit Test 2 (äöüß)!', :ticket_state_id => Ticket::State.where( :name => 'new' ).first.id, :ticket_priority_id => Ticket::Priority.where( :name => '2 normal' ).first.id, - :created_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id + :updated_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, + :created_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, }, :article => { :created_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, + :updated_by_id => User.where( :login => 'nicole.braun@zammad.org' ).first.id, :ticket_article_type_id => Ticket::Article::Type.where(:name => 'phone' ).first.id, :ticket_article_sender_id => Ticket::Article::Sender.where(:name => 'Customer' ).first.id, :from => 'Unit Test ', @@ -92,23 +96,23 @@ class HistoryTest < ActiveSupport::TestCase :history_check => [ { :history_object => 'Ticket', - :history_type => 'created', + :history_type => 'created', }, { - :history_object => 'Ticket', - :history_type => 'updated', + :history_object => 'Ticket', + :history_type => 'updated', :history_attribute => 'title', - :value_from => 'Unit Test 2 (äöüß)!', - :value_to => 'Unit Test 2 (äöüß) - update!', + :value_from => 'Unit Test 2 (äöüß)!', + :value_to => 'Unit Test 2 (äöüß) - update!', }, { - :history_object => 'Ticket', - :history_type => 'updated', + :history_object => 'Ticket', + :history_type => 'updated', :history_attribute => 'owner', - :value_from => '-', - :value_to => 'Nicole Braun', - :id_from => User.where( :login => '-' ).first.id, - :id_to => User.where( :login => 'nicole.braun@zammad.org' ).first.id, + :value_from => '-', + :value_to => 'Nicole Braun', + :id_from => User.where( :login => '-' ).first.id, + :id_to => User.where( :login => 'nicole.braun@zammad.org' ).first.id, }, { :history_object => 'Ticket::Article', @@ -128,7 +132,6 @@ class HistoryTest < ActiveSupport::TestCase ticket = Ticket.create( test[:ticket_create][:ticket]) test[:ticket_create][:article][:ticket_id] = ticket.id article = Ticket::Article.create( test[:ticket_create][:article] ) - assert_equal( ticket.class.to_s, 'Ticket' ) assert_equal( article.class.to_s, 'Ticket::Article' ) diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 1b8b32d40..ce9491e65 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -10,6 +10,7 @@ class UserTest < ActiveSupport::TestCase :lastname => 'Lastname', :email => 'some@example.com', :login => 'some@example.com', + :updated_by_id => 1, :created_by_id => 1, }, :create_verify => { @@ -25,6 +26,7 @@ class UserTest < ActiveSupport::TestCase :lastname => '', :email => 'some@example.com', :login => 'some@example.com', + :updated_by_id => 1, :created_by_id => 1, }, :create_verify => { @@ -40,6 +42,7 @@ class UserTest < ActiveSupport::TestCase :lastname => nil, :email => 'some@example.com', :login => 'some@example.com', + :updated_by_id => 1, :created_by_id => 1, }, :create_verify => { @@ -55,6 +58,7 @@ class UserTest < ActiveSupport::TestCase :lastname => '', :email => 'some@example.com', :login => 'some@example.com', + :updated_by_id => 1, :created_by_id => 1, }, :create_verify => { @@ -70,6 +74,7 @@ class UserTest < ActiveSupport::TestCase :lastname => '', :email => 'firstname.lastname@example.com', :login => 'login', + :updated_by_id => 1, :created_by_id => 1, }, :create_verify => { @@ -85,6 +90,7 @@ class UserTest < ActiveSupport::TestCase :lastname => '', :email => 'FIRSTNAME.lastname@example.com', :login => 'login', + :updated_by_id => 1, :created_by_id => 1, }, :create_verify => { @@ -100,6 +106,7 @@ class UserTest < ActiveSupport::TestCase :lastname => nil, :email => 'FIRSTNAME.lastname@example.com', :login => 'login', + :updated_by_id => 1, :created_by_id => 1, }, :create_verify => {