Skip to content
Snippets Groups Projects
Commit 56527b63 authored by Valery Sizov's avatar Valery Sizov
Browse files

Ability to search milestones

parent 24b282ae
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -11,6 +11,7 @@ v 8.0.0 (unreleased)
- Allow configuration of import sources for new projects (Artem Sidorenko)
- Search for comments should be case insensetive
- Create cross-reference for closing references on commits pushed to non-default branches (Maël Valais)
- Ability to search milestones
 
v 7.14.0
- Fix bug where non-project members of the target project could set labels on new merge requests.
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ class SearchController < ApplicationController
 
@search_results =
if @project
unless %w(blobs notes issues merge_requests wiki_blobs).
unless %w(blobs notes issues merge_requests milestones wiki_blobs).
include?(@scope)
@scope = 'blobs'
end
Loading
Loading
@@ -36,7 +36,7 @@ class SearchController < ApplicationController
 
Search::SnippetService.new(current_user, params).execute
else
unless %w(projects issues merge_requests).include?(@scope)
unless %w(projects issues merge_requests milestones).include?(@scope)
@scope = 'projects'
end
Search::GlobalService.new(current_user, params).execute
Loading
Loading
Loading
Loading
@@ -47,6 +47,13 @@ class Milestone < ActiveRecord::Base
state :active
end
 
class << self
def search(query)
query = "%#{query}%"
where("title like ? or description like ?", query, query)
end
end
def expired?
if due_date
due_date.past?
Loading
Loading
@@ -54,7 +61,7 @@ class Milestone < ActiveRecord::Base
false
end
end
def open_items_count
self.issues.opened.count + self.merge_requests.opened.count
end
Loading
Loading
Loading
Loading
@@ -21,6 +21,13 @@
Merge requests
%span.badge
= @search_results.merge_requests_count
%li{class: ("active" if @scope == 'milestones')}
= link_to search_filter_path(scope: 'milestones') do
= icon('clock-o fw')
%span
Milestones
%span.badge
= @search_results.milestones_count
%li{class: ("active" if @scope == 'notes')}
= link_to search_filter_path(scope: 'notes') do
= icon('comments fw')
Loading
Loading
@@ -74,4 +81,11 @@
Merge requests
%span.badge
= @search_results.merge_requests_count
%li{class: ("active" if @scope == 'milestones')}
= link_to search_filter_path(scope: 'milestones') do
= icon('clock-o fw')
%span
Milestones
%span.badge
= @search_results.milestones_count
 
.search-result-row
%h4
= link_to [milestone.project.namespace.becomes(Namespace), milestone.project, milestone] do
%span.term.str-truncated= milestone.title
- if milestone.description.present?
.description.term
= preserve do
= search_md_sanitize(markdown(milestone.description))
\ No newline at end of file
Loading
Loading
@@ -23,6 +23,13 @@ Feature: Search
Then I should see "Foo" link in the search results
And I should not see "Bar" link in the search results
 
Scenario: I should see milestones I am looking for
And project has milestones
When I search for "Foo"
When I click "Milestones" link
Then I should see "Foo" link in the search results
And I should not see "Bar" link in the search results
Scenario: I should see project code I am looking for
When I click project "Shop" link
And I search for "rspec"
Loading
Loading
@@ -44,6 +51,14 @@ Feature: Search
Then I should see "Foo" link in the search results
And I should not see "Bar" link in the search results
 
Scenario: I should see project milestones
And project has milestones
When I click project "Shop" link
And I search for "Foo"
And I click "Milestones" link
Then I should see "Foo" link in the search results
And I should not see "Bar" link in the search results
Scenario: I should see Wiki blobs
And project has Wiki content
When I click project "Shop" link
Loading
Loading
Loading
Loading
@@ -41,6 +41,12 @@ class Spinach::Features::Search < Spinach::FeatureSteps
end
end
 
step 'I click "Milestones" link' do
page.within '.search-filter' do
click_link 'Milestones'
end
end
step 'I click "Wiki" link' do
page.within '.search-filter' do
click_link 'Wiki'
Loading
Loading
@@ -72,6 +78,11 @@ class Spinach::Features::Search < Spinach::FeatureSteps
create(:merge_request, :simple, title: "Bar", source_project: project, target_project: project)
end
 
step 'project has milestones' do
create(:milestone, title: "Foo", project: project)
create(:milestone, title: "Bar", project: project)
end
step 'I should see "Foo" link in the search results' do
page.within('.results') do
find(:css, '.search-results').should have_link 'Foo'
Loading
Loading
Loading
Loading
@@ -19,13 +19,15 @@ module Gitlab
issues.page(page).per(per_page)
when 'merge_requests'
merge_requests.page(page).per(per_page)
when 'milestones'
milestones.page(page).per(per_page)
else
Kaminari.paginate_array([]).page(page).per(per_page)
end
end
 
def total_count
@total_count ||= projects_count + issues_count + merge_requests_count
@total_count ||= projects_count + issues_count + merge_requests_count + milestones_count
end
 
def projects_count
Loading
Loading
@@ -40,6 +42,10 @@ module Gitlab
@merge_requests_count ||= merge_requests.count
end
 
def milestones_count
@milestones_count ||= milestones.count
end
def empty?
total_count.zero?
end
Loading
Loading
@@ -60,6 +66,12 @@ module Gitlab
issues.order('updated_at DESC')
end
 
def milestones
milestones = Milestone.where(project_id: limit_project_ids)
milestones = milestones.search(query)
milestones.order('updated_at DESC')
end
def merge_requests
merge_requests = MergeRequest.in_projects(limit_project_ids)
if query =~ /[#!](\d+)\z/
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment