require 'spec_helper'

describe IpBlacklist do

  describe "#banned" do
    it "returns false if no ban" do
      IpBlacklist.banned('1.1.1.1').should eq false
    end

    it "returns true if banned" do
      FactoryGirl.create(:ip_blacklist, remote_ip: "1.1.1.1")
      IpBlacklist.banned('1.1.1.1').should eq true
    end

    it "returns false if whitelisted" do
      FactoryGirl.create(:ip_whitelist, remote_ip: "1.1.1.1")
      IpBlacklist.banned('1.1.1.1').should eq false
    end


    it "returns false if whitelisted and blacklisted too" do
      FactoryGirl.create(:ip_blacklist, remote_ip: "1.1.1.1")
      FactoryGirl.create(:ip_whitelist, remote_ip: "1.1.1.1")
      IpBlacklist.banned('1.1.1.1').should eq false
    end
  end
end