2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-25 22:13:01 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Blob shortcuts', :js do
|
2017-01-25 22:13:01 -05:00
|
|
|
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 }
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
describe 'On a file(blob)', :js do
|
2017-01-25 22:13:01 -05:00
|
|
|
def get_absolute_url(path = "")
|
|
|
|
"http://#{page.server.host}:#{page.server.port}#{path}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_blob(fragment = nil)
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_blob_path(project, tree_join('master', path), anchor: fragment)
|
2017-01-25 22:13:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'pressing "y"' do
|
|
|
|
it 'redirects to permalink with commit sha' do
|
|
|
|
visit_blob
|
2018-08-12 16:19:35 -04:00
|
|
|
wait_for_requests
|
2017-01-25 22:13:01 -05:00
|
|
|
|
|
|
|
find('body').native.send_key('y')
|
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path))), url: true)
|
2017-01-25 22:13:01 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'maintains fragment hash when redirecting' do
|
|
|
|
fragment = "L1"
|
|
|
|
visit_blob(fragment)
|
2018-08-12 16:19:35 -04:00
|
|
|
wait_for_requests
|
2017-01-25 22:13:01 -05:00
|
|
|
|
|
|
|
find('body').native.send_key('y')
|
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment)), url: true)
|
2017-01-25 22:13:01 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|