Project

General

Profile

« Previous | Next » 

Revision 07ad7166

Added by Lucas Tolchinsky over 14 years ago

  • ID 07ad7166f57160b3f5fdcddbbaafac6c7727ab02

corrected tests in hosts_controller and report_observer

View differences:

test/unit/report_observer_test.rb
class ReportObserverTest < ActiveSupport::TestCase
def setup
# Email recepient
SETTINGS[:administrator] = "ltolchinsky@vurbiatechnologies.com"
SETTINGS[:administrator] = "admin@example.com"
# Host and Report creation
h = Host.create :name => "myfullhost", :mac => "aabbecddeeff", :ip => "123.05.02.03",
......
@report = Report.new :host => h, :log => p, :reported_at => Date.today
end
test "if report has an error a mail to admin should be sent" do
test "when notification fails, if report has an error a mail to admin should be sent" do
SETTINGS[:failed_report_email_notification] = true
assert_difference 'ActionMailer::Base.deliveries.size' do
@report.status = 16781381 # Error status.
@report.save!
end
end
test "when notification doesn't fails, if report has an error, no mail should be sent" do
SETTINGS[:failed_report_email_notification] = false
assert_no_difference 'ActionMailer::Base.deliveries.size' do
@report.status = 16781381 # Error status.
@report.save!
end
end
test "if report has no error, no mail should be sent" do
assert_no_difference 'ActionMailer::Base.deliveries.size' do
@report.status = 79

Also available in: Unified diff