Sha256: 5815b3f8afd52a29a00addef8b4bf6b5beffad00aa0682573f5ad9ce24984c2d

Contents?: true

Size: 899 Bytes

Versions: 2

Compression:

Stored size: 899 Bytes

Contents

require 'test_helper'

module Plotline
  class FooSearchableContent < Entry
    content_attr :body, :text
    content_attr :url, :string
  end

  class EntryTest < ActiveSupport::TestCase
    test "searchable_attributes" do
      FooSearchableContent.searchable_attributes(:foo_attr, :bar_attr)
      assert_equal [:foo_attr, :bar_attr], FooSearchableContent.searchable_attributes
    end

    test "search_attributes" do
      FooSearchableContent.searchable_attributes(:title, :body)

      foo = FooSearchableContent.new(title: "Hello", body: "World")
      assert_equal({ title: "Hello", body: "World"}, foo.search_attributes)
    end

    test "update_search_index" do
      FooSearchableContent.searchable_attributes(:title, :body)

      assert_difference('Plotline::EntrySearchData.count', 2) do
        FooSearchableContent.create(title: "Hello", body: "World")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
plotline-0.1.1 test/models/plotline/concerns/searchable_test.rb
plotline-0.1.0 test/models/plotline/concerns/searchable_test.rb