Commit 6aa50165 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'logged-out-search' into 'master'

Logged out search

Fixes #13676  

See merge request !3045
parents b8f8a55b 4c8721b2
...@@ -8,6 +8,7 @@ v 8.6.0 (unreleased) ...@@ -8,6 +8,7 @@ v 8.6.0 (unreleased)
- Strip leading and trailing spaces in URL validator (evuez) - Strip leading and trailing spaces in URL validator (evuez)
- Return empty array instead of 404 when commit has no statuses in commit status API - Return empty array instead of 404 when commit has no statuses in commit status API
- Update documentation to reflect Guest role not being enforced on internal projects - Update documentation to reflect Guest role not being enforced on internal projects
- Allow search for logged out users
v 8.5.2 v 8.5.2
- Fix sidebar overlapping content when screen width was below 1200px - Fix sidebar overlapping content when screen width was below 1200px
......
...@@ -305,7 +305,7 @@ table { ...@@ -305,7 +305,7 @@ table {
} }
.btn-sign-in { .btn-sign-in {
margin-top: 8px; margin-top: 10px;
text-shadow: none; text-shadow: none;
} }
......
.search-results { .search-results {
.search-result-row { .search-result-row {
border-bottom: 1px solid #DDD; border-bottom: 1px solid $border-color;
padding-bottom: 15px; padding-bottom: $gl-padding;
margin-bottom: 15px; margin-bottom: $gl-padding;
&:last-child {
border-bottom: none;
}
} }
} }
......
class SearchController < ApplicationController class SearchController < ApplicationController
skip_before_action :authenticate_user!, :reject_blocked
include SearchHelper include SearchHelper
layout 'search' layout 'search'
......
...@@ -5,11 +5,7 @@ ...@@ -5,11 +5,7 @@
-# Ideally this would be inside the head, but turbolinks only evaluates page-specific JS in the body. -# Ideally this would be inside the head, but turbolinks only evaluates page-specific JS in the body.
= yield :scripts_body_top = yield :scripts_body_top
- if current_user = render "layouts/header/default", title: header_title
= render "layouts/header/default", title: header_title
- else
= render "layouts/header/public", title: header_title
= render 'layouts/page', sidebar: sidebar = render 'layouts/page', sidebar: sidebar
= yield :scripts_body = yield :scripts_body
...@@ -13,30 +13,35 @@ ...@@ -13,30 +13,35 @@
%li.visible-sm.visible-xs %li.visible-sm.visible-xs
= link_to search_path, title: 'Search', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to search_path, title: 'Search', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('search') = icon('search')
- if session[:impersonator_id] - if current_user
%li.impersonation - if session[:impersonator_id]
= link_to stop_impersonation_admin_users_path, method: :delete, title: 'Stop Impersonation', data: { toggle: 'tooltip', placement: 'bottom', container: 'body' } do %li.impersonation
= icon('user-secret fw') = link_to stop_impersonation_admin_users_path, method: :delete, title: 'Stop Impersonation', data: { toggle: 'tooltip', placement: 'bottom', container: 'body' } do
- if current_user.is_admin? = icon('user-secret fw')
- if current_user.is_admin?
%li
= link_to admin_root_path, title: 'Admin Area', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('wrench fw')
%li %li
= link_to admin_root_path, title: 'Admin Area', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to dashboard_todos_path, title: 'Todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('wrench fw') %span.badge.todos-pending-count
%li = todos_pending_count
= link_to dashboard_todos_path, title: 'Todos', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do - if current_user.can_create_project?
%span.badge.todos-pending-count %li
= todos_pending_count = link_to new_project_path, title: 'New project', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
- if current_user.can_create_project? = icon('plus fw')
- if Gitlab::Sherlock.enabled?
%li
= link_to sherlock_transactions_path, title: 'Sherlock Transactions',
data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('tachometer fw')
%li %li
= link_to new_project_path, title: 'New project', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do = link_to destroy_user_session_path, class: 'logout', method: :delete, title: 'Sign out', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('plus fw') = icon('sign-out')
- if Gitlab::Sherlock.enabled? - else
%li .pull-right
= link_to sherlock_transactions_path, title: 'Sherlock Transactions', = link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in btn-success'
data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('tachometer fw')
%li
= link_to destroy_user_session_path, class: 'logout', method: :delete, title: 'Sign out', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'} do
= icon('sign-out')
%h1.title= title %h1.title= title
......
%header.navbar.navbar-fixed-top.navbar-gitlab{ class: nav_header_class }
%div{ class: fluid_layout ? "container-fluid" : "container-fluid" }
.header-content
- unless current_controller?('sessions')
.pull-right
= link_to "Sign in", new_session_path(:user, redirect_to_referer: 'yes'), class: 'btn btn-sign-in btn-success'
%h1.title= title
= render 'shared/outdated_browser'
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
= button_tag 'Search', class: "btn btn-primary" = button_tag 'Search', class: "btn btn-primary"
- unless params[:snippets].eql? 'true' - unless params[:snippets].eql? 'true'
%br %br
= render 'filter' = render 'filter' if current_user
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
= render 'shared/projects/list', projects: @objects = render 'shared/projects/list', projects: @objects
- else - else
= render partial: "search/results/#{@scope.singularize}", collection: @objects = render partial: "search/results/#{@scope.singularize}", collection: @objects
= paginate @objects, theme: 'gitlab' = paginate @objects, theme: 'gitlab'
:javascript :javascript
$(".search-results .term").highlight("#{escape_javascript(params[:search])}"); $(".search-results .term").highlight("#{escape_javascript(params[:search])}");
...@@ -65,3 +65,25 @@ Feature: Search ...@@ -65,3 +65,25 @@ Feature: Search
And I search for "Wiki content" And I search for "Wiki content"
And I click "Wiki" link And I click "Wiki" link
Then I should see "test_wiki" link in the search results Then I should see "test_wiki" link in the search results
Scenario: I logout and should see project I am looking for
Given project "Shop" is public
And I logout
And I search for "Sho"
Then I should see "Shop" project link
Scenario: I logout and should see issues I am looking for
Given project "Shop" is public
And I logout
And project has issues
When I search for "Foo"
And I click "Issues" link
Then I should see "Foo" link in the search results
And I should not see "Bar" link in the search results
Scenario: I logout and should see project code I am looking for
Given project "Shop" is public
And I logout
When I visit project "Shop" page
And I search for "rspec" on project page
Then I should see code results for project "Shop"
...@@ -18,6 +18,11 @@ class Spinach::Features::Search < Spinach::FeatureSteps ...@@ -18,6 +18,11 @@ class Spinach::Features::Search < Spinach::FeatureSteps
click_button "Search" click_button "Search"
end end
step 'I search for "rspec" on project page' do
fill_in "search", with: "rspec"
click_button "Go"
end
step 'I search for "Wiki content"' do step 'I search for "Wiki content"' do
fill_in "dashboard_search", with: "content" fill_in "dashboard_search", with: "content"
click_button "Search" click_button "Search"
...@@ -103,4 +108,8 @@ class Spinach::Features::Search < Spinach::FeatureSteps ...@@ -103,4 +108,8 @@ class Spinach::Features::Search < Spinach::FeatureSteps
@wiki = ::ProjectWiki.new(project, current_user) @wiki = ::ProjectWiki.new(project, current_user)
@wiki.create_page("test_wiki", "Some Wiki content", :markdown, "first commit") @wiki.create_page("test_wiki", "Some Wiki content", :markdown, "first commit")
end end
step 'project "Shop" is public' do
project.update_attributes(visibility_level: Project::PUBLIC)
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