Sha256: cf7645ca424f3ff01e2408d914e8c515945d0ee3bbf5bc0b476961a00f72e951

Contents?: true

Size: 1.86 KB

Versions: 5

Compression:

Stored size: 1.86 KB

Contents

# -*- encoding : utf-8 -*-

describe Card::Set::Type::SearchType do
  it "wraps search items with correct view class" do
    Card.create :type=>'Search', :name=>'Asearch', :content=>%{{"type":"User"}}
    c=render_content("{{Asearch|core;item:name}}")
    expect(c).to match('search-result-item item-name')
    expect(render_content("{{Asearch|core}}"          ).scan('search-result-item item-closed').size).to eq(14)
    expect(render_content("{{Asearch|core;item:open}}").scan('search-result-item item-open'  ).size).to eq(14)
    expect(render_content("{{Asearch|core|titled}}"   ).scan('search-result-item item-titled').size).to eq(14)
  end

  it "handles returning 'count'" do
    expect(render_card(:core, :type=>'Search', :content=>%{{ "type":"User", "return":"count"}})).to eq('14')
  end

  it "passes item args correctly" do
    Card.create!(
      :name=>'Pointer2Searches',
      :type_id=>Card::PointerID,
      :content=>"[[Layout+*type+by name]]\n[[PlainText+*type+by name]]"
    )
    r = render_content "{{Pointer2Searches|core|closed|hide:menu}}"
    expect(r.scan('"view":"link"').size).to eq(0)
    expect(r.scan('item-closed').size).to eq(2) #there are two of each
  end

  it 'handles type update from pointer' do
    pointer_card = Card.create!(
        :name=>"PointerToSearches",
        :type_id=>Card::PointerID,
    )

    pointer_card.update_attributes! :type_id=>Card::SearchTypeID,:content=>%{{"type":"User"}}
    expect(pointer_card.content).to eq(%{{"type":"User"}})
  end

  context 'references' do
    before do
      Card.create :type=>'Search', :name=>'search with references', :content=>'{"name":"Y"}'
    end
    subject do
      Card['search with references']
    end

    it 'updates query if referee changed' do
      Card['Y'].update_attributes! :name=>'YYY', :update_referencers => true
      expect(subject.content).to eq '{"name":"YYY"}'
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-1.16.6 mod/05_standard/spec/set/type/search_type_spec.rb
card-1.16.5 mod/05_standard/spec/set/type/search_type_spec.rb
card-1.16.4 mod/05_standard/spec/set/type/search_type_spec.rb
card-1.16.3 mod/05_standard/spec/set/type/search_type_spec.rb
card-1.16.2 mod/05_standard/spec/set/type/search_type_spec.rb