[close #23] Changed searching.
This commit is contained in:
parent
88ea7110f3
commit
a946349bb4
|
@ -19,7 +19,7 @@ class ProjectsController < ApplicationController
|
|||
end.accessible_by(current_ability)
|
||||
|
||||
@projects = if params[:query]
|
||||
@projects.where(["name LIKE ?", "%#{params[:query]}%"])
|
||||
@projects.by_name(params[:query]).order("CHAR_LENGTH(name) ASC")
|
||||
else
|
||||
@projects
|
||||
end.paginate(:page => params[:project_page])
|
||||
|
|
|
@ -104,4 +104,19 @@ describe ProjectsController do
|
|||
it_should_behave_like 'projects user with writer rights'
|
||||
it_should_behave_like 'projects user with reader rights'
|
||||
end
|
||||
|
||||
context 'search projects' do
|
||||
|
||||
before(:each) do
|
||||
@admin = Factory(:admin)
|
||||
@project1 = Factory(:project, :name => 'perl-debug')
|
||||
@project2 = Factory(:project, :name => 'perl')
|
||||
set_session_for(@admin)
|
||||
end
|
||||
|
||||
it 'should return projects in right order' do
|
||||
get :index, :query => 'per'
|
||||
assigns(:projects).should eq([@project2, @project1])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue