Skip to content

Commit

Permalink
completed adding my test suite from LH_23 branch to my master branch,…
Browse files Browse the repository at this point in the history
… all my tests pass. These are mostly unit tests.
  • Loading branch information
Jonathan Hoyt authored and Jonathan Hoyt committed Mar 24, 2009
1 parent 0880041 commit d095f42
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/models/ticket.rb
Expand Up @@ -7,6 +7,7 @@ class Ticket < ActiveRecord::Base
has_many :things, :as => :attached, :dependent => :destroy

validates_presence_of :client_id
validates_presence_of :creator_id
validates_presence_of :user_id
validates_presence_of :description

Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Expand Up @@ -4,7 +4,7 @@
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
config.cache_classes = false

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
Expand Down
2 changes: 1 addition & 1 deletion test/factories/schedules.rb
@@ -1,7 +1,7 @@
Factory.define :schedule do |f|
f.name "24x7"
f.active true
f.user_id 1
f.association :user
f.start_time "7am"
f.end_time "10pm"
end
5 changes: 5 additions & 0 deletions test/factories/users.rb
Expand Up @@ -8,3 +8,8 @@
f.remember_token "77de68daecd823babbb58edb1c8e14d7106e83bb"
f.association :client
end

Factory.define :george, :parent => :user do |f|
f.email "george@example.com"
f.name "George Jones"
end
23 changes: 9 additions & 14 deletions test/unit/ticket_test.rb
Expand Up @@ -53,7 +53,8 @@ class TicketTest < ActiveSupport::TestCase

context "ticket#technician" do
should "return the ticket user" do
ticket = Factory.create(:ticket)
user = Factory.create(:user)
ticket = Factory.create(:ticket, :user_id => user.id)
assert_equal ticket.technician.name, ticket.user.name
end
end
Expand All @@ -65,25 +66,22 @@ class TicketTest < ActiveSupport::TestCase
end
end

context "Ticket#limit" do

end

context "Ticket#totals" do
setup do
@user = Factory.create(:user)
(1..2).each do
Factory.create(:ticket)
Factory.create(:ticket, :user_id => @user.id)
end
(1..3).each do
Factory.create(:ticket, :active_on => Date.tomorrow)
Factory.create(:ticket, :user_id => @user.id, :active_on => Date.tomorrow)
end
(1..4).each do
Factory.create(:ticket, :completed_on => 2.days.ago)
Factory.create(:ticket, :user_id => @user.id, :completed_on => 2.days.ago)
end
(1..5).each do
Factory.create(:ticket, :archived_on => 5.days.ago)
Factory.create(:ticket, :user_id => @user.id, :archived_on => 5.days.ago)
end
@totals = Ticket.totals(User.find(1))
@totals = Ticket.totals(@user)
end
should "return proper number of open tickets" do
assert_equal @totals[:open].to_i, 2
Expand All @@ -98,8 +96,5 @@ class TicketTest < ActiveSupport::TestCase
assert_equal @totals[:all].to_i, 9
end
end

context "ticket#checklists" do
end


end

0 comments on commit d095f42

Please sign in to comment.