cirandas.net

ref: master

plugins/pg_search/test/functional/search_controller_test.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require_relative '../../../../test/test_helper'

class SearchControllerTest < ActionController::TestCase

  def setup
    @environment = Environment.default
    @environment.enable_plugin(PgSearchPlugin)
  end

  attr_accessor :environment

  should 'list all communities' do
    c1 = fast_create(Community, :name => 'Testing community 1')
    c2 = fast_create(Community, :name => 'Testing community 3')
    c3 = fast_create(Community, :name => 'Testing community 3')

    get :communities
    assert_equivalent [c1, c2, c3], assigns(:searches)[:communities][:results]
  end

  should 'list communities of a specific template' do
    t1 = fast_create(Community, :is_template => true)
    t2 = fast_create(Community, :is_template => true)
    c1 = fast_create(Community, :template_id => t1.id, :name => 'Testing community 1')
    c2 = fast_create(Community, :template_id => t2.id, :name => 'Testing community 2')
    c3 = fast_create(Community, :template_id => t1.id, :name => 'Testing community 3')
    c4 = fast_create(Community, :name => 'Testing community 3')

    get :communities, :template_id => t1.id
    assert_equivalent [c1, c3], assigns(:searches)[:communities][:results]
  end
end