require "test_helper"

class FeaturedLinkTest < ActiveSupport::TestCase
  test "should not be valid without a url" do
    link = build(:featured_link, url: nil)
    refute link.valid?
  end

  test "should not be valid without a title" do
    link = build(:featured_link, title: nil)
    refute link.valid?
  end

  test "should not be valid with a url that doesn't start with http" do
    link = build(:featured_link, url: "not a link")
    refute link.valid?
  end

  test "should be valid with a url that starts with http" do
    link = build(:featured_link, url: "http://my.example.com/path")
    refute link.valid?
  end
end

require "test_helper"

class FeaturedLinkTest < ActiveSupport::TestCase
  test "should not be valid without a url" do
    link = build(:featured_link, title: 'a title', url: nil)
    refute link.valid?
  end

  test "should not be valid without a title" do
    link = build(:featured_link, title: nil, url: 'http://my.example.com/path')
    refute link.valid?
  end

  test "should not be valid with a url that doesn't start with http" do
    link = build(:featured_link, title: 'a title', url: "not a link")
    refute link.valid?
  end

  test "should be valid with a url that starts with http" do
    link = build(:featured_link, title: 'a title', url: "http://my.example.com/path")
    assert link.valid?
  end
end

Add positive test for FeaturedLink
Add positive test for FeaturedLink

Also update the negative tests so the models would otherwise be valid if
it wasn't for the attribute we are testing.
