2017-01-15 13:20:01 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe SearchController do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'finds issue comments' do
|
2017-09-10 17:25:29 +05:30
|
|
|
project = create(:project, :public)
|
2017-01-15 13:20:01 +05:30
|
|
|
note = create(:note_on_issue, project: project)
|
|
|
|
|
|
|
|
get :show, project_id: project.id, scope: 'notes', search: note.note
|
|
|
|
|
|
|
|
expect(assigns[:search_objects].first).to eq note
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'on restricted projects' do
|
|
|
|
context 'when signed out' do
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
sign_out(user)
|
|
|
|
end
|
2017-01-15 13:20:01 +05:30
|
|
|
|
|
|
|
it "doesn't expose comments on issues" do
|
2017-09-10 17:25:29 +05:30
|
|
|
project = create(:project, :public, :issues_private)
|
2017-01-15 13:20:01 +05:30
|
|
|
note = create(:note_on_issue, project: project)
|
|
|
|
|
|
|
|
get :show, project_id: project.id, scope: 'notes', search: note.note
|
|
|
|
|
|
|
|
expect(assigns[:search_objects].count).to eq(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't expose comments on merge_requests" do
|
2017-09-10 17:25:29 +05:30
|
|
|
project = create(:project, :public, :merge_requests_private)
|
2017-01-15 13:20:01 +05:30
|
|
|
note = create(:note_on_merge_request, project: project)
|
|
|
|
|
|
|
|
get :show, project_id: project.id, scope: 'notes', search: note.note
|
|
|
|
|
|
|
|
expect(assigns[:search_objects].count).to eq(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't expose comments on snippets" do
|
2017-09-10 17:25:29 +05:30
|
|
|
project = create(:project, :public, :snippets_private)
|
2017-01-15 13:20:01 +05:30
|
|
|
note = create(:note_on_project_snippet, project: project)
|
|
|
|
|
|
|
|
get :show, project_id: project.id, scope: 'notes', search: note.note
|
|
|
|
|
|
|
|
expect(assigns[:search_objects].count).to eq(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|