* This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ namespace Test\Memcache; /** * @group Memcache * @group APCu */ class APCuTest extends Cache { protected function setUp(): void { parent::setUp(); if (!\OC\Memcache\APCu::isAvailable()) { $this->markTestSkipped('The APCu extension is not available.'); return; } $this->instance = new \OC\Memcache\APCu($this->getUniqueID()); } public function testCasIntChanged() { $this->instance->set('foo', 1); $this->assertTrue($this->instance->cas('foo', 1, 2)); $this->assertEquals(2, $this->instance->get('foo')); } public function testCasIntNotChanged() { $this->instance->set('foo', 1); $this->assertFalse($this->instance->cas('foo', 2, 3)); $this->assertEquals(1, $this->instance->get('foo')); } } 1-stable Mirror of redmine code source: https://github.com/redmine/redminewww-data
summaryrefslogtreecommitdiffstats
path: root/test/functional/search_controller_test.rb
blob: 49004c7e677fe6f3a6e18717f397b56b70e51991 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require File.dirname(__FILE__) + '/../test_helper'
require 'search_controller'

# Re-raise errors caught by the controller.
class SearchController; def rescue_action(e) raise e end; end

class SearchControllerTest < Test::Unit::TestCase
  fixtures :projects, :enabled_modules, :issues, :custom_fields, :custom_values
  
  def setup
    @controller = SearchController.new
    @request    = ActionController::TestRequest.new
    @response   = ActionController::TestResponse.new
    User.current = nil
  end
  
  def test_search_for_projects
    get :index
    assert_response :success
    assert_template 'index'

    get :index, :q => "cook"
    assert_response :success
    assert_template 'index'
    assert assigns(:results).include?(Project.find(1))
  end
  
  def test_search_without_searchable_custom_fields
    CustomField.update_all "searchable = #{ActiveRecord::Base.connection.quoted_false}"
    
    get :index, :id => 1
    assert_response :success
    assert_template 'index'
    assert_not_nil assigns(:project)
    
    get :index, :id => 1, :q => "can"
    assert_response :success
    assert_template 'index'
  end
  
  def test_search_with_searchable_custom_fields
    get :index, :id => 1, :q => "stringforcustomfield"
    assert_response :success
    results = assigns(:results)
    assert_not_nil results
    assert_equal 1, results.size
    assert results.include?(Issue.find(3))
  end
  
  def test_search_all_words
    # 'all words' is on by default
    get :index, :id => 1, :q => 'recipe updating saving'
    results = assigns(:results)
    assert_not_nil results
    assert_equal 1, results.size
    assert results.include?(Issue.find(3))
  end
  
  def test_search_one_of_the_words
    get :index, :id => 1, :q => 'recipe updating saving', :submit => 'Search'
    results = assigns(:results)
    assert_not_nil results
    assert_equal 3, results.size
    assert results.include?(Issue.find(3))
  end

  def test_search_titles_only_without_result
    get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1', :titles_only => '1', :submit => 'Search'
    results = assigns(:results)
    assert_not_nil results
    assert_equal 0, results.size
  end

  def test_search_titles_only
    get :index, :id => 1, :q => 'recipe', :titles_only => '1', :submit => 'Search'
    results = assigns(:results)
    assert_not_nil results
    assert_equal 2, results.size
  end
  
  def test_search_with_invalid_project_id
    get :index, :id => 195, :q => 'recipe'
    assert_response 404
    assert_nil assigns(:results)
  end

  def test_quick_jump_to_issue
    # issue of a public project
    get :index, :q => "3"
    assert_redirected_to 'issues/show/3'
    
    # issue of a private project
    get :index, :q => "4"
    assert_response :success
    assert_template 'index'
  end
  
  def test_tokens_with_quotes
    get :index, :id => 1, :q => '"good bye" hello "bye bye"'
    assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens)
  end
end