Sha256: d00b6adc29c7237e568149b903db7fb4e921caf53de13183869192fa0c3424b4
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
require 'test_plugin_helper' class NewHostNotificationTest < ActiveSupport::TestCase include FactImporterIsolation allow_transactions_for_any_importer alias_method :blueprint, :discovered_notification_blueprint setup do assert blueprint end test 'new discovered host should generate a notification' do set_default_settings assert_difference('blueprint.notifications.count') do discover_host_from_facts(parse_json_fixture('/../facts.json')['facts']) end end test 'multiple discovered hosts should generate only one notification' do host1 = FactoryBot.create :discovered_host ForemanDiscovery::UINotifications::NewHost.deliver!(host1) expired_at = blueprint.notifications.first.expired_at Time.any_instance.stubs(:utc).returns(expired_at + 1.hour) host2 = FactoryBot.create :discovered_host ForemanDiscovery::UINotifications::NewHost.deliver!(host2) assert_equal 1, blueprint.notifications.count assert_not_equal expired_at, blueprint.notifications.first.expired_at end def parse_json_fixture(relative_path) return JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + relative_path))) end end
Version data entries
4 entries across 4 versions & 1 rubygems