Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 02911b6

Browse files
committed
Merge pull request #223 from mssola/search
Disabling the `fulltext` option for the repository model for now
2 parents 28b98d2 + e3dcee9 commit 02911b6

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

app/models/repository.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ class Repository < ActiveRecord::Base
1010
attributes :name
1111
attributes namespace_name: 'namespace.name'
1212

13-
options :name, type: :fulltext
14-
options :namespace_name, type: :fulltext
13+
# TODO: (mssola): we are experiencing some issues with MariaDB's fulltext
14+
# support. Because of that, the following two options have been disabled
15+
# until we find a solution for it.
16+
# options :name, type: :fulltext
17+
# options :namespace_name, type: :fulltext
1518
end
1619

1720
# Handle a push event from the registry.
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'rails_helper'
22

33
RSpec.describe SearchController, type: :controller do
4-
54
let(:registry) { create(:registry) }
65
let(:user) { create(:user) }
76
let(:team) { create(:team, owners: [user]) }
@@ -17,13 +16,6 @@
1716
it 'returns http success' do
1817
get :index, search: @repository.name
1918
expect(response).to have_http_status(:success)
20-
21-
# NOTE: we cannot test the contents of @repositories because
22-
# MariaDB does not update the fulltext indexes until the transaction
23-
# is commited. All the data created by the tests is wrapped inside of a
24-
# transaction by rails, so we cannot search for it.
25-
# http://dev.mysql.com/doc/refman/5.6/en/fulltext-restrictions.html
2619
end
2720
end
28-
2921
end

spec/policies/repository_policy_spec.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
let(:team2) { create(:team, owners: [user2]) }
1212

1313
describe 'scope' do
14-
1514
before :each do
1615
public_namespace = create(:namespace, team: team2, public: true, registry: registry)
1716
@public_repository = create(:repository, namespace: public_namespace)
@@ -34,7 +33,17 @@
3433
it 'never shows repositories inside of private namespaces' do
3534
expect(Pundit.policy_scope(user, Repository).to_a).not_to include(@private_repository)
3635
end
37-
3836
end
3937

38+
describe 'search' do
39+
it 'finds the same repository regardless to how it has been written' do
40+
namespace = create(:namespace, team: team, name: 'mssola')
41+
create(:repository, namespace: namespace, name: 'repository')
42+
43+
%w(repository rep epo).each do |name|
44+
repo = Pundit.policy_scope(user, Repository).search(name)
45+
expect(repo.name).to eql 'Repository'
46+
end
47+
end
48+
end
4049
end

0 commit comments

Comments
 (0)