Commit 5b284f6a authored by Adam Leonard's avatar Adam Leonard

Add ability to Search issues

parent 86021a7d
...@@ -20,6 +20,7 @@ gem "kaminari" ...@@ -20,6 +20,7 @@ gem "kaminari"
gem "thin" gem "thin"
gem "git" gem "git"
gem "acts_as_list" gem "acts_as_list"
gem "mysql2"
group :assets do group :assets do
gem 'sass-rails', " ~> 3.1.0" gem 'sass-rails', " ~> 3.1.0"
......
...@@ -128,6 +128,7 @@ GEM ...@@ -128,6 +128,7 @@ GEM
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.16) mime-types (1.16)
multi_json (1.0.3) multi_json (1.0.3)
mysql2 (0.3.7)
nokogiri (1.5.0) nokogiri (1.5.0)
orm_adapter (0.0.5) orm_adapter (0.0.5)
polyglot (0.3.2) polyglot (0.3.2)
...@@ -258,6 +259,7 @@ DEPENDENCIES ...@@ -258,6 +259,7 @@ DEPENDENCIES
jquery-rails jquery-rails
kaminari kaminari
launchy launchy
mysql2
pygments.rb (= 0.2.3) pygments.rb (= 0.2.3)
rails (= 3.1.0) rails (= 3.1.0)
rails-footnotes (>= 3.7.5.rc4) rails-footnotes (>= 3.7.5.rc4)
......
...@@ -78,6 +78,13 @@ class IssuesController < ApplicationController ...@@ -78,6 +78,13 @@ class IssuesController < ApplicationController
render :nothing => true render :nothing => true
end end
def search
@project = Project.find(params['project'])
@issues = @project.issues.where("title LIKE ? OR content LIKE ?", "%#{params['terms']}%", "%#{params['terms']}%")
render :partial => 'issues'
end
protected protected
def issue def issue
......
%div %div
- if can? current_user, :write_issue, @project - if can? current_user, :write_issue, @project
.left= link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm" .left
= form_tag search_project_issues_path(@project), :method => :get, :remote => true do
= search_field_tag :issue_search, nil, { :placeholder => 'Search', :class => 'issue_search' }
= link_to 'New Issue', new_project_issue_path(@project), :remote => true, :class => "lbutton vm"
.right .right
= form_tag project_issues_path(@project), :method => :get do = form_tag project_issues_path(@project), :method => :get do
.span-2 .span-2
...@@ -20,6 +24,18 @@ ...@@ -20,6 +24,18 @@
#issues-table-holder= render "issues" #issues-table-holder= render "issues"
%br %br
:javascript :javascript
$('.issue_search').keyup(function() {
var terms = $(this).val();
var project_id = 1;
if (terms.length >= 2) {
$.get($(this).parent().attr('action'), { 'terms': terms, project: project_id }, function(response) {
$('#issues-table').html(response);
setSortable();
});
}
});
$('.delete-issue').live('ajax:success', function() { $('.delete-issue').live('ajax:success', function() {
$(this).closest('tr').fadeOut(); }); $(this).closest('tr').fadeOut(); });
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
# Ensure the SQLite 3 gem is defined in your Gemfile # Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3' # gem 'sqlite3'
development: development:
adapter: sqlite3 adapter: mysql2
database: db/development.sqlite3 database: gitlab_development
username: root
pool: 5 pool: 5
timeout: 5000 timeout: 5000
...@@ -13,13 +14,11 @@ development: ...@@ -13,13 +14,11 @@ development:
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
adapter: sqlite3 adapter: mysql2
database: db/test.sqlite3 database: gitlab_development
pool: 5 username: root
timeout: 5000
production: production:
adapter: sqlite3 adatper: mysql2
database: db/production.sqlite3 database: gitlab_test
pool: 5 username: root
timeout: 5000
...@@ -47,6 +47,9 @@ Gitlab::Application.routes.draw do ...@@ -47,6 +47,9 @@ Gitlab::Application.routes.draw do
collection do collection do
post :sort post :sort
end end
collection do
get :search
end
end end
resources :notes, :only => [:create, :destroy] resources :notes, :only => [:create, :destroy]
end end
......
...@@ -144,4 +144,26 @@ describe "Issues" do ...@@ -144,4 +144,26 @@ describe "Issues" do
end end
end end
end end
describe "Search issue", :js => true do
before do
['foobar', 'foobar2', 'gitlab'].each do |title|
@issue = Factory :issue,
:author => @user,
:assignee => @user,
:project => project,
:title => title
@issue.save
end
end
it "should search and return the correct results" do
visit project_issues_path(project)
fill_in "issue_search", :with => "foobar"
page.should have_content 'foobar'
page.should have_content 'foobar2'
page.should_not have_content 'gitlab'
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment