require 'test_helper' class MetaTagTest < ActionView::TestCase include Metamagic::ViewHelper test "meta tags" do meta keywords: %w{one two three}, description: "My description" assert_equal %{\n}, metamagic end test "shortcut helpers" do keywords %w{one two three} description "My description" assert_equal %{\n}, metamagic end test "nil meta value" do title "Test Title" description nil assert_equal %{Test Title}, metamagic end test "array as meta value" do keywords %w{one two three} assert_equal %{}, metamagic end test "empty array as meta value" do title "Test Title" keywords [] assert_equal %{Test Title}, metamagic end test "nil in array as meta value" do title "Test Title" keywords ["one", nil, "two"] assert_equal %{Test Title\n}, metamagic end test "nil only array as meta value" do title "Test Title" keywords [nil] assert_equal %{Test Title}, metamagic end test "keywords template" do keywords %w{added keywords} assert_equal %{}, metamagic(keywords: [:keywords, "default", "from", "layout"]) end test "keywords template with no keywords" do assert_equal %{}, metamagic(keywords: [:keywords, "default", "from", "layout"]) end test "unique values using templates" do keywords %w{added keywords} assert_equal %{}, metamagic(keywords: [:keywords, "added", "default", "keywords", "from", "layout"]) end test "html safe keywords" do keywords ["one", "two → test".html_safe, "three"] assert_equal %{}, metamagic end test "html unsafe keywords" do keywords ["one", "two → test", "three"] assert_equal %{}, metamagic end end