2019-10-29 02:06:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-27 05:45:52 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe 'environments routing' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-03-27 05:45:52 -04:00
|
|
|
|
|
|
|
let(:environment) do
|
|
|
|
create(:environment, project: project,
|
|
|
|
name: 'staging-1.0/review')
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:environments_route) do
|
2019-12-03 04:09:09 -05:00
|
|
|
"#{project.full_path}/-/environments/"
|
2017-03-27 05:45:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'routing environment folders' do
|
|
|
|
context 'when using JSON format' do
|
|
|
|
it 'correctly matches environment name and JSON format' do
|
|
|
|
expect(get_folder('staging-1.0.json'))
|
|
|
|
.to route_to(*folder_action(id: 'staging-1.0', format: 'json'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when using HTML format' do
|
|
|
|
it 'correctly matches environment name and HTML format' do
|
|
|
|
expect(get_folder('staging-1.0.html'))
|
|
|
|
.to route_to(*folder_action(id: 'staging-1.0', format: 'html'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when using implicit format' do
|
|
|
|
it 'correctly matches environment name' do
|
|
|
|
expect(get_folder('staging-1.0'))
|
|
|
|
.to route_to(*folder_action(id: 'staging-1.0'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_folder(folder)
|
2019-12-03 04:09:09 -05:00
|
|
|
get("#{project.full_path}/-/environments/folders/#{folder}")
|
2017-03-27 05:45:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def folder_action(**opts)
|
2018-11-21 08:13:54 -05:00
|
|
|
options = { namespace_id: project.namespace.path,
|
|
|
|
project_id: project.path }
|
2017-03-27 05:45:52 -04:00
|
|
|
|
|
|
|
['projects/environments#folder', options.merge(opts)]
|
|
|
|
end
|
|
|
|
end
|