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

Disabling the fulltext option for the repository model for now #223

Merged
merged 2 commits into from
Jul 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ class Repository < ActiveRecord::Base
attributes :name
attributes namespace_name: 'namespace.name'

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

# Handle a push event from the registry.
Expand Down
8 changes: 0 additions & 8 deletions spec/controllers/search_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'rails_helper'

RSpec.describe SearchController, type: :controller do

let(:registry) { create(:registry) }
let(:user) { create(:user) }
let(:team) { create(:team, owners: [user]) }
Expand All @@ -17,13 +16,6 @@
it 'returns http success' do
get :index, search: @repository.name
expect(response).to have_http_status(:success)

# NOTE: we cannot test the contents of @repositories because
# MariaDB does not update the fulltext indexes until the transaction
# is commited. All the data created by the tests is wrapped inside of a
# transaction by rails, so we cannot search for it.
# http://dev.mysql.com/doc/refman/5.6/en/fulltext-restrictions.html
end
end

end
13 changes: 11 additions & 2 deletions spec/policies/repository_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
let(:team2) { create(:team, owners: [user2]) }

describe 'scope' do

before :each do
public_namespace = create(:namespace, team: team2, public: true, registry: registry)
@public_repository = create(:repository, namespace: public_namespace)
Expand All @@ -34,7 +33,17 @@
it 'never shows repositories inside of private namespaces' do
expect(Pundit.policy_scope(user, Repository).to_a).not_to include(@private_repository)
end

end

describe 'search' do
it 'finds the same repository regardless to how it has been written' do
namespace = create(:namespace, team: team, name: 'mssola')
create(:repository, namespace: namespace, name: 'repository')

%w(repository rep epo).each do |name|
repo = Pundit.policy_scope(user, Repository).search(name)
expect(repo.name).to eql 'Repository'
end
end
end
end