/
searcher_spec.rb
51 lines (43 loc) · 1.33 KB
/
searcher_spec.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'spec_helper'
describe Searcher do
let(:search_results) { subject }
let(:first_result) { subject.first }
context "habtm label search" do
context "one word value" do
subject { Ticket.search("tag:bug") }
it "finds a ticket" do
expect(first_result.description).to eq("Hello world! You are awesome.")
end
end
context "multiple word value" do
subject { Ticket.search(%q{tag:"visual regression"}) }
it "finds a ticket" do
expect(first_result.description).to eq("Hello world! You are awesome.")
end
end
end
context "belongs_to label search" do
subject { Ticket.search("state:Open") }
it "finds a ticket" do
expect(first_result.description).to eq("Hello world! You are awesome.")
end
end
context "combined search" do
subject { Ticket.search("tag:bug state:Open") }
it "finds a ticket" do
expect(first_result.description).to eq("Hello world! You are awesome.")
end
end
context "no tickets with tag feature" do
subject { Ticket.search("tag:feature state:Open") }
it "finds a ticket" do
expect(first_result).to be_nil
end
end
context "undefined label search" do
subject { Ticket.search("undefined:true") }
it "returns all the records" do
expect(search_results).to eq(Ticket.all)
end
end
end