Skip to content

Commit fda3d0a

Browse files
authored
Merge pull request #1263 from jdelStrother/fixing-tests
Fixing CI tests
2 parents 5caa63f + 01d141b commit fda3d0a

10 files changed

+75
-76
lines changed

.github/workflows/ci.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ on: [push, pull_request]
44

55
jobs:
66
sphinx:
7-
runs-on: ${{ matrix.os }}
7+
runs-on: ubuntu-22.04
88

99
strategy:
1010
fail-fast: false
1111
matrix:
12-
os: [ 'ubuntu-18.04' ]
1312
ruby: [ '2.7', '3.0', '3.1', '3.2' ]
1413
rails: [ '5_0', '5_1', '5_2', '6_0', '6_1', '7_0' ]
1514
database: [ 'mysql2', 'postgresql' ]
@@ -58,7 +57,7 @@ jobs:
5857
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
5958

6059
steps:
61-
- uses: actions/checkout@v2
60+
- uses: actions/checkout@v4
6261
- uses: ./.github/actions/test
6362
with:
6463
ruby-version: ${{ matrix.ruby }}
@@ -69,7 +68,7 @@ jobs:
6968
timeout-minutes: 12
7069

7170
manticore:
72-
runs-on: ubuntu-20.04
71+
runs-on: ubuntu-22.04
7372

7473
strategy:
7574
fail-fast: false

spec/acceptance/attribute_access_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
describe 'Accessing attributes directly via search results', :live => true do
66
it "allows access to attribute values" do
7-
Book.create! :title => 'American Gods', :year => 2001
7+
Book.create! :title => 'American Gods', :publishing_year => 2001
88
index
99

1010
search = Book.search('gods')
1111
search.context[:panes] << ThinkingSphinx::Panes::AttributesPane
1212

13-
expect(search.first.sphinx_attributes['year']).to eq(2001)
13+
expect(search.first.sphinx_attributes['publishing_year']).to eq(2001)
1414
end
1515

1616
it "provides direct access to the search weight/relevance scores" do
17-
Book.create! :title => 'American Gods', :year => 2001
17+
Book.create! :title => 'American Gods', :publishing_year => 2001
1818
index
1919

2020
search = Book.search 'gods', :select => "*, weight()"
@@ -37,7 +37,7 @@
3737
end
3838

3939
it "can enumerate with the weight" do
40-
gods = Book.create! :title => 'American Gods', :year => 2001
40+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
4141
index
4242

4343
search = Book.search 'gods', :select => "*, weight()"

spec/acceptance/excerpts_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
describe 'Accessing excerpts for methods on a search result', :live => true do
77
it "returns excerpts for a given method" do
8-
Book.create! :title => 'American Gods', :year => 2001
8+
Book.create! :title => 'American Gods', :publishing_year => 2001
99
index
1010

1111
search = Book.search('gods')
@@ -16,7 +16,7 @@
1616
end
1717

1818
it "handles UTF-8 text for excerpts" do
19-
Book.create! :title => 'Война и миръ', :year => 1869
19+
Book.create! :title => 'Война и миръ', :publishing_year => 1869
2020
index
2121

2222
search = Book.search 'миръ'

spec/acceptance/grouping_by_attributes_spec.rb

+20-20
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@
44

55
describe 'Grouping search results by attributes', :live => true do
66
it "groups by the provided attribute" do
7-
snuff = Book.create! :title => 'Snuff', :year => 2011
8-
earth = Book.create! :title => 'The Long Earth', :year => 2012
9-
dodger = Book.create! :title => 'Dodger', :year => 2012
7+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
8+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
9+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
1010

1111
index
1212

13-
expect(Book.search(:group_by => :year).to_a).to eq([snuff, earth])
13+
expect(Book.search(:group_by => :publishing_year).to_a).to eq([snuff, earth])
1414
end
1515

1616
it "allows sorting within the group" do
17-
snuff = Book.create! :title => 'Snuff', :year => 2011
18-
earth = Book.create! :title => 'The Long Earth', :year => 2012
19-
dodger = Book.create! :title => 'Dodger', :year => 2012
17+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
18+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
19+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
2020

2121
index
2222

23-
expect(Book.search(:group_by => :year, :order_group_by => 'title ASC').to_a).
23+
expect(Book.search(:group_by => :publishing_year, :order_group_by => 'title ASC').to_a).
2424
to eq([snuff, dodger])
2525
end
2626

2727
it "allows enumerating by count" do
28-
snuff = Book.create! :title => 'Snuff', :year => 2011
29-
earth = Book.create! :title => 'The Long Earth', :year => 2012
30-
dodger = Book.create! :title => 'Dodger', :year => 2012
28+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
29+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
30+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
3131

3232
index
3333

3434
expectations = [[snuff, 1], [earth, 2]]
3535

36-
Book.search(:group_by => :year).each_with_count do |book, count|
36+
Book.search(:group_by => :publishing_year).each_with_count do |book, count|
3737
expectation = expectations.shift
3838

3939
expect(book).to eq(expectation.first)
@@ -42,15 +42,15 @@
4242
end
4343

4444
it "allows enumerating by group" do
45-
snuff = Book.create! :title => 'Snuff', :year => 2011
46-
earth = Book.create! :title => 'The Long Earth', :year => 2012
47-
dodger = Book.create! :title => 'Dodger', :year => 2012
45+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
46+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
47+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
4848

4949
index
5050

5151
expectations = [[snuff, 2011], [earth, 2012]]
5252

53-
Book.search(:group_by => :year).each_with_group do |book, group|
53+
Book.search(:group_by => :publishing_year).each_with_group do |book, group|
5454
expectation = expectations.shift
5555

5656
expect(book).to eq(expectation.first)
@@ -59,14 +59,14 @@
5959
end
6060

6161
it "allows enumerating by group and count" do
62-
snuff = Book.create! :title => 'Snuff', :year => 2011
63-
earth = Book.create! :title => 'The Long Earth', :year => 2012
64-
dodger = Book.create! :title => 'Dodger', :year => 2012
62+
snuff = Book.create! :title => 'Snuff', :publishing_year => 2011
63+
earth = Book.create! :title => 'The Long Earth', :publishing_year => 2012
64+
dodger = Book.create! :title => 'Dodger', :publishing_year => 2012
6565

6666
index
6767

6868
expectations = [[snuff, 2011, 1], [earth, 2012, 2]]
69-
search = Book.search(:group_by => :year)
69+
search = Book.search(:group_by => :publishing_year)
7070

7171
search.each_with_group_and_count do |book, group, count|
7272
expectation = expectations.shift

spec/acceptance/searching_with_filters_spec.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
end
1313

1414
it "limits results by an array of values" do
15-
gods = Book.create! :title => 'American Gods', :year => 2001
16-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
17-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
15+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
16+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
17+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
1818
index
1919

20-
expect(Book.search(:with => {:year => [2001, 2005]}).to_a).to match_array([gods, boys])
20+
expect(Book.search(:with => {:publishing_year => [2001, 2005]}).to_a).to match_array([gods, boys])
2121
end
2222

2323
it "limits results by a ranged filter" do
@@ -43,12 +43,12 @@
4343
end
4444

4545
it "limits results by exclusive filters on arrays of values" do
46-
gods = Book.create! :title => 'American Gods', :year => 2001
47-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
48-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
46+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
47+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
48+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
4949
index
5050

51-
expect(Book.search(:without => {:year => [2001, 2005]}).to_a).to eq([grave])
51+
expect(Book.search(:without => {:publishing_year => [2001, 2005]}).to_a).to eq([grave])
5252
end
5353

5454
it "limits results by ranged filters on timestamp MVAs" do

spec/acceptance/sorting_search_results_spec.rb

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44

55
describe 'Sorting search results', :live => true do
66
it "sorts by a given clause" do
7-
gods = Book.create! :title => 'American Gods', :year => 2001
8-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
9-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
7+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
8+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
9+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
1010
index
1111

12-
expect(Book.search(:order => 'year ASC').to_a).to eq([gods, boys, grave])
12+
expect(Book.search(:order => 'publishing_year ASC').to_a).to eq([gods, boys, grave])
1313
end
1414

1515
it "sorts by a given attribute in ascending order" do
16-
gods = Book.create! :title => 'American Gods', :year => 2001
17-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
18-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
16+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
17+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
18+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
1919
index
2020

21-
expect(Book.search(:order => :year).to_a).to eq([gods, boys, grave])
21+
expect(Book.search(:order => :publishing_year).to_a).to eq([gods, boys, grave])
2222
end
2323

2424
it "sorts by a given sortable field" do
25-
gods = Book.create! :title => 'American Gods', :year => 2001
26-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
27-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
25+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
26+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
27+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
2828
index
2929

3030
expect(Book.search(:order => :title).to_a).to eq([gods, boys, grave])
@@ -38,13 +38,13 @@
3838
end
3939

4040
it "can sort with a provided expression" do
41-
gods = Book.create! :title => 'American Gods', :year => 2001
42-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
43-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
41+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
42+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
43+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
4444
index
4545

4646
expect(Book.search(
47-
:select => '*, year MOD 2004 as mod_year', :order => 'mod_year ASC'
47+
:select => '*, publishing_year MOD 2004 as mod_year', :order => 'mod_year ASC'
4848
).to_a).to eq([boys, grave, gods])
4949
end
5050
end

spec/acceptance/sphinx_scopes_spec.rb

+16-16
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@
44

55
describe 'Sphinx scopes', :live => true do
66
it "allows calling sphinx scopes from models" do
7-
gods = Book.create! :title => 'American Gods', :year => 2001
8-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
9-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
7+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
8+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
9+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
1010
index
1111

12-
expect(Book.by_year(2009).to_a).to eq([grave])
12+
expect(Book.by_publishing_year(2009).to_a).to eq([grave])
1313
end
1414

1515
it "allows scopes to return both query and options" do
16-
gods = Book.create! :title => 'American Gods', :year => 2001
17-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
18-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
16+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
17+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
18+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
1919
index
2020

21-
expect(Book.by_query_and_year('Graveyard', 2009).to_a).to eq([grave])
21+
expect(Book.by_query_and_publishing_year('Graveyard', 2009).to_a).to eq([grave])
2222
end
2323

2424
it "allows chaining of scopes" do
25-
gods = Book.create! :title => 'American Gods', :year => 2001
26-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
27-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
25+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
26+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
27+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
2828
index
2929

30-
expect(Book.by_year(2001..2005).ordered.to_a).to eq([boys, gods])
30+
expect(Book.by_publishing_year(2001..2005).ordered.to_a).to eq([boys, gods])
3131
end
3232

3333
it "allows chaining of scopes that include queries" do
34-
gods = Book.create! :title => 'American Gods', :year => 2001
35-
boys = Book.create! :title => 'Anansi Boys', :year => 2005
36-
grave = Book.create! :title => 'The Graveyard Book', :year => 2009
34+
gods = Book.create! :title => 'American Gods', :publishing_year => 2001
35+
boys = Book.create! :title => 'Anansi Boys', :publishing_year => 2005
36+
grave = Book.create! :title => 'The Graveyard Book', :publishing_year => 2009
3737
index
3838

39-
expect(Book.by_year(2001).by_query_and_year('Graveyard', 2009).to_a).
39+
expect(Book.by_publishing_year(2001).by_query_and_publishing_year('Graveyard', 2009).to_a).
4040
to eq([grave])
4141
end
4242

spec/internal/app/indices/book_index.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
indexes [title, author], :as => :info
77
indexes blurb_file, :file => true
88

9-
has year
9+
has publishing_year
1010
has created_at, :type => :timestamp
1111
end

spec/internal/app/models/book.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ class Book < ActiveRecord::Base
88
ThinkingSphinx::Callbacks.append(self, :behaviours => [:sql, :deltas])
99

1010
sphinx_scope(:by_query) { |query| query }
11-
sphinx_scope(:by_year) do |year|
12-
{:with => {:year => year}}
11+
sphinx_scope(:by_publishing_year) do |year|
12+
{:with => {:publishing_year => year}}
1313
end
14-
sphinx_scope(:by_query_and_year) do |query, year|
15-
[query, {:with => {:year =>year}}]
14+
sphinx_scope(:by_query_and_publishing_year) do |query, year|
15+
[query, {:with => {:publishing_year =>year}}]
1616
end
17-
sphinx_scope(:ordered) { {:order => 'year DESC'} }
17+
sphinx_scope(:ordered) { {:order => 'publishing_year DESC'} }
1818
end

spec/internal/db/schema.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
create_table(:books, :force => true) do |t|
4040
t.string :title
4141
t.string :author
42-
t.integer :year
42+
t.integer :publishing_year
4343
t.string :blurb_file
4444
t.boolean :delta, :default => true, :null => false
4545
t.string :type, :default => 'Book', :null => false

0 commit comments

Comments
 (0)