debian-mirror-gitlab/spec/features/projects/blobs/shortcuts_blob_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Blob shortcuts', :js, feature_category: :projects do
2017-08-17 22:00:37 +05:30
include TreeHelper
let(:project) { create(:project, :public, :repository) }
let(:path) { project.repository.ls_files(project.repository.root_ref)[0] }
let(:sha) { project.repository.commit.sha }
2018-03-17 18:26:18 +05:30
describe 'On a file(blob)', :js do
2017-08-17 22:00:37 +05:30
def get_absolute_url(path = "")
"http://#{page.server.host}:#{page.server.port}#{path}"
end
def visit_blob(fragment = nil)
2017-09-10 17:25:29 +05:30
visit project_blob_path(project, tree_join('master', path), anchor: fragment)
2017-08-17 22:00:37 +05:30
end
describe 'pressing "y"' do
it 'redirects to permalink with commit sha' do
visit_blob
2018-11-20 20:47:30 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
find('body').native.send_key('y')
2017-09-10 17:25:29 +05:30
expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path))), url: true)
2017-08-17 22:00:37 +05:30
end
it 'maintains fragment hash when redirecting' do
fragment = "L1"
visit_blob(fragment)
2018-11-20 20:47:30 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
find('body').native.send_key('y')
2017-09-10 17:25:29 +05:30
expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment)), url: true)
2017-08-17 22:00:37 +05:30
end
end
end
end