debian-mirror-gitlab/spec/features/snippets/search_snippets_spec.rb

61 lines
1.7 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2017-08-17 22:00:37 +05:30
2018-11-08 19:23:39 +05:30
describe 'Search Snippets' do
it 'User searches for snippets by title' do
2017-08-17 22:00:37 +05:30
public_snippet = create(:personal_snippet, :public, title: 'Beginning and Middle')
private_snippet = create(:personal_snippet, :private, title: 'Middle and End')
2017-09-10 17:25:29 +05:30
sign_in private_snippet.author
2017-08-17 22:00:37 +05:30
visit dashboard_snippets_path
2019-12-04 20:38:33 +05:30
submit_search('Middle')
select_search_scope('Titles and Filenames')
2017-08-17 22:00:37 +05:30
expect(page).to have_link(public_snippet.title)
expect(page).to have_link(private_snippet.title)
end
2018-11-08 19:23:39 +05:30
it 'User searches for snippet contents' do
2017-08-17 22:00:37 +05:30
create(:personal_snippet,
:public,
title: 'Many lined snippet',
content: <<-CONTENT.strip_heredoc
|line one
|line two
|line three
|line four
|line five
|line six
|line seven
|line eight
|line nine
|line ten
|line eleven
|line twelve
|line thirteen
|line fourteen
CONTENT
)
2017-09-10 17:25:29 +05:30
sign_in create(:user)
2017-08-17 22:00:37 +05:30
visit dashboard_snippets_path
2019-12-04 20:38:33 +05:30
submit_search('line seven')
2017-08-17 22:00:37 +05:30
expect(page).to have_content('line seven')
# 3 lines before the matched line should be visible
expect(page).to have_content('line six')
expect(page).to have_content('line five')
expect(page).to have_content('line four')
expect(page).not_to have_content('line three')
# 3 lines after the matched line should be visible
expect(page).to have_content('line eight')
expect(page).to have_content('line nine')
expect(page).to have_content('line ten')
expect(page).not_to have_content('line eleven')
end
end