2017-02-01 16:49:20 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'View on environment', js: true do
|
|
|
|
let(:branch_name) { 'feature' }
|
|
|
|
let(:file_path) { 'files/ruby/feature.rb' }
|
2017-02-06 19:06:46 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-02-01 16:49:20 -05:00
|
|
|
let(:user) { project.creator }
|
|
|
|
|
|
|
|
before do
|
2017-02-06 19:06:46 -05:00
|
|
|
project.add_master(user)
|
2017-02-01 16:49:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the branch has a route map' do
|
|
|
|
let(:route_map) do
|
|
|
|
<<-MAP.strip_heredoc
|
|
|
|
- source: /files/(.*)\\..*/
|
|
|
|
public: '\\1'
|
|
|
|
MAP
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
Files::CreateService.new(
|
|
|
|
project,
|
|
|
|
user,
|
2017-02-06 19:06:46 -05:00
|
|
|
start_branch: branch_name,
|
2017-04-19 20:37:44 -04:00
|
|
|
branch_name: branch_name,
|
2017-02-01 16:49:20 -05:00
|
|
|
commit_message: "Add .gitlab/route-map.yml",
|
|
|
|
file_path: '.gitlab/route-map.yml',
|
|
|
|
file_content: route_map
|
|
|
|
).execute
|
|
|
|
|
|
|
|
# Update the file so that we still have a commit that will have a file on the environment
|
|
|
|
Files::UpdateService.new(
|
|
|
|
project,
|
|
|
|
user,
|
2017-02-06 19:06:46 -05:00
|
|
|
start_branch: branch_name,
|
2017-04-19 20:37:44 -04:00
|
|
|
branch_name: branch_name,
|
2017-02-01 16:49:20 -05:00
|
|
|
commit_message: "Update feature",
|
|
|
|
file_path: file_path,
|
|
|
|
file_content: "# Noop"
|
|
|
|
).execute
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'and an active deployment' do
|
|
|
|
let(:sha) { project.commit(branch_name).sha }
|
|
|
|
let(:environment) { create(:environment, project: project, name: 'review/feature', external_url: 'http://feature.review.example.com') }
|
|
|
|
let!(:deployment) { create(:deployment, environment: environment, ref: branch_name, sha: sha) }
|
|
|
|
|
|
|
|
context 'when visiting the diff of a merge request for the branch' do
|
|
|
|
let(:merge_request) { create(:merge_request, :simple, source_project: project, source_branch: branch_name) }
|
|
|
|
|
|
|
|
before do
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in(user)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
visit diffs_project_merge_request_path(project, merge_request)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-01 16:49:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a "View on env" button' do
|
|
|
|
within '.diffs' do
|
|
|
|
expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when visiting a comparison for the branch' do
|
|
|
|
before do
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in(user)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_compare_path(project, from: 'master', to: branch_name)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-01 16:49:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a "View on env" button' do
|
|
|
|
expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when visiting a comparison for the commit' do
|
|
|
|
before do
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in(user)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_compare_path(project, from: 'master', to: sha)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-01 16:49:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a "View on env" button' do
|
|
|
|
expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when visiting a blob on the branch' do
|
|
|
|
before do
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in(user)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_blob_path(project, File.join(branch_name, file_path))
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-01 16:49:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a "View on env" button' do
|
|
|
|
expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when visiting a blob on the commit' do
|
|
|
|
before do
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in(user)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_blob_path(project, File.join(sha, file_path))
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-01 16:49:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a "View on env" button' do
|
|
|
|
expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when visiting the commit' do
|
|
|
|
before do
|
2017-06-05 14:44:29 -04:00
|
|
|
gitlab_sign_in(user)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_commit_path(project, sha)
|
2017-02-01 16:49:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-01 16:49:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a "View on env" button' do
|
|
|
|
expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|