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

Add ability to Search issues

parent 86021a7d
......@@ -20,6 +20,7 @@ gem "kaminari"
gem "thin"
gem "git"
gem "acts_as_list"
gem "mysql2"
group :assets do
gem 'sass-rails', " ~> 3.1.0"
......
......@@ -128,6 +128,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.16)
multi_json (1.0.3)
mysql2 (0.3.7)
nokogiri (1.5.0)
orm_adapter (0.0.5)
polyglot (0.3.2)
......@@ -258,6 +259,7 @@ DEPENDENCIES
jquery-rails
kaminari
launchy
mysql2
pygments.rb (= 0.2.3)
rails (= 3.1.0)
rails-footnotes (>= 3.7.5.rc4)
......
......@@ -78,6 +78,13 @@ class IssuesController < ApplicationController
render :nothing => true
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
def issue
......
%div
- 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
= form_tag project_issues_path(@project), :method => :get do
.span-2
......@@ -20,6 +24,18 @@
#issues-table-holder= render "issues"
%br
: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() {
$(this).closest('tr').fadeOut(); });
......
......@@ -4,8 +4,9 @@
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
adapter: mysql2
database: gitlab_development
username: root
pool: 5
timeout: 5000
......@@ -13,13 +14,11 @@ development:
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
adapter: mysql2
database: gitlab_development
username: root
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
adatper: mysql2
database: gitlab_test
username: root
......@@ -47,6 +47,9 @@ Gitlab::Application.routes.draw do
collection do
post :sort
end
collection do
get :search
end
end
resources :notes, :only => [:create, :destroy]
end
......
......@@ -144,4 +144,26 @@ describe "Issues" do
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
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