debian-mirror-gitlab/spec/features/search/user_searches_for_commits_spec.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'User searches for commits' do
2018-03-17 18:26:18 +05:30
let(:project) { create(:project, :repository) }
let(:sha) { '6d394385cf567f80a8fd85055db1ab4c5295806f' }
let(:user) { create(:user) }
before do
project.add_reporter(user)
sign_in(user)
visit(search_path(project_id: project.id))
end
context 'when searching by SHA' do
it 'finds a commit and redirects to its page' do
2019-12-04 20:38:33 +05:30
submit_search(sha)
2018-03-17 18:26:18 +05:30
expect(page).to have_current_path(project_commit_path(project, sha))
end
it 'finds a commit in uppercase and redirects to its page' do
2019-12-04 20:38:33 +05:30
submit_search(sha.upcase)
2018-03-17 18:26:18 +05:30
expect(page).to have_current_path(project_commit_path(project, sha))
end
end
context 'when searching by message' do
it 'finds a commit and holds on /search page' do
create_commit('Message referencing another sha: "deadbeef"', project, user, 'master')
2019-12-04 20:38:33 +05:30
submit_search('deadbeef')
2018-03-17 18:26:18 +05:30
2019-09-04 21:01:54 +05:30
expect(page).to have_current_path('/search', ignore_query: true)
2018-03-17 18:26:18 +05:30
end
it 'finds multiple commits' do
2019-12-04 20:38:33 +05:30
submit_search('See merge request')
select_search_scope('Commits')
2018-03-17 18:26:18 +05:30
expect(page).to have_selector('.commit-row-description', count: 9)
end
end
end