Commit e6524a919ee4c92d82518c2520d5c0cabc32eb47
1 parent
db3d90cb
Exists in
master
and in
4 other branches
Wiki search
Very basic, using LIKE, and no search snippets.
Showing
6 changed files
with
50 additions
and
2 deletions
Show diff stats
app/contexts/search_context.rb
... | ... | @@ -13,6 +13,7 @@ class SearchContext |
13 | 13 | result[:projects] = Project.where(id: project_ids).search(query).limit(10) |
14 | 14 | result[:merge_requests] = MergeRequest.where(project_id: project_ids).search(query).limit(10) |
15 | 15 | result[:issues] = Issue.where(project_id: project_ids).search(query).limit(10) |
16 | + result[:wiki_pages] = Wiki.where(project_id: project_ids).search(query).limit(10) | |
16 | 17 | result |
17 | 18 | end |
18 | 19 | |
... | ... | @@ -20,7 +21,8 @@ class SearchContext |
20 | 21 | @result ||= { |
21 | 22 | projects: [], |
22 | 23 | merge_requests: [], |
23 | - issues: [] | |
24 | + issues: [], | |
25 | + wiki_pages: [] | |
24 | 26 | } |
25 | 27 | end |
26 | 28 | end | ... | ... |
app/controllers/search_controller.rb
app/models/wiki.rb
app/views/search/show.html.haml
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | %br |
10 | 10 | %h3 |
11 | 11 | Search results |
12 | - %small (#{@projects.count + @merge_requests.count + @issues.count}) | |
12 | + %small (#{@projects.count + @merge_requests.count + @issues.count + @wiki_pages.count}) | |
13 | 13 | %hr |
14 | 14 | .search_results |
15 | 15 | .row |
... | ... | @@ -69,6 +69,23 @@ |
69 | 69 | %tr |
70 | 70 | %td |
71 | 71 | %h4.nothing_here_message No Issues |
72 | + .span6 | |
73 | + %table | |
74 | + %thead | |
75 | + %tr | |
76 | + %th Wiki | |
77 | + %tbody | |
78 | + - @wiki_pages.each do |wiki_page| | |
79 | + %tr | |
80 | + %td | |
81 | + = link_to project_wiki_path(wiki_page.project, wiki_page) do | |
82 | + %strong.term= truncate wiki_page.title, length: 40 | |
83 | + %strong.right | |
84 | + %span.label= wiki_page.project.name | |
85 | + - if @wiki_pages.blank? | |
86 | + %tr | |
87 | + %td | |
88 | + %h4.nothing_here_message No wiki pages | |
72 | 89 | :javascript |
73 | 90 | $(function() { |
74 | 91 | $(".search_results .term").highlight("#{params[:search]}"); | ... | ... |
features/dashboard/search.feature
... | ... | @@ -2,8 +2,13 @@ Feature: Dashboard Search |
2 | 2 | Background: |
3 | 3 | Given I sign in as a user |
4 | 4 | And I own project "Shop" |
5 | + And Project "Shop" has wiki page "Contibuting guide" | |
5 | 6 | And I visit dashboard search page |
6 | 7 | |
7 | 8 | Scenario: I should see project I am looking for |
8 | 9 | Given I search for "Sho" |
9 | 10 | Then I should see "Shop" project link |
11 | + | |
12 | + Scenario: I should see wiki page I am looking for | |
13 | + Given I search for "Contibuting" | |
14 | + Then I should see "Contibuting guide" wiki link | |
10 | 15 | \ No newline at end of file | ... | ... |
features/steps/dashboard/dashboard_search.rb
... | ... | @@ -15,4 +15,21 @@ class DashboardSearch < Spinach::FeatureSteps |
15 | 15 | @project = Factory :project, :name => "Shop" |
16 | 16 | @project.add_access(@user, :admin) |
17 | 17 | end |
18 | + | |
19 | + Given 'I search for "Contibuting"' do | |
20 | + fill_in "dashboard_search", :with => "Contibuting" | |
21 | + click_button "Search" | |
22 | + end | |
23 | + | |
24 | + And 'Project "Shop" has wiki page "Contibuting guide"' do | |
25 | + @wiki_page = Factory :wiki, :project => @project, | |
26 | + :title => "Contibuting guide", | |
27 | + :slug => "contributing" | |
28 | + end | |
29 | + | |
30 | + Then 'I should see "Contibuting guide" wiki link' do | |
31 | + page.should have_link "Contibuting guide" | |
32 | + end | |
33 | + | |
34 | + | |
18 | 35 | end | ... | ... |