# frozen_string_literal: true # == Schema Information # # Table name: subnet_bans # # id :integer not null, primary key # enabled :boolean default(TRUE), not null # note :string # reason :string not null # specification :inet # valid_until :datetime not null # created_at :datetime not null # updated_at :datetime not null # banning_user_id :integer not null # generated_ban_id :string not null # # Indexes # # index_subnet_bans_on_banning_user_id (banning_user_id) # index_subnet_bans_on_created_at (created_at) # # Foreign Keys # # fk_rails_... (banning_user_id => users.id) ON DELETE => restrict ON UPDATE => cascade # require 'test_helper' class SubnetBanTest < ActiveSupport::TestCase setup do @ban = build(:subnet_ban) end test 'should be valid' do assert @ban.valid? end test '.banned? should return the active ban when banned' do @ban.save assert_equal @ban, SubnetBan.banned?(@ban.specification) end test '.banned? should return false when not banned' do assert_not SubnetBan.banned?(@ban.specification) # did not save @ban = create(:expired_subnet_ban) assert_not SubnetBan.banned?(@ban.specification) end end