diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/models/web_ide_terminal_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/models/web_ide_terminal_spec.rb')
-rw-r--r-- | spec/models/web_ide_terminal_spec.rb | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/spec/models/web_ide_terminal_spec.rb b/spec/models/web_ide_terminal_spec.rb new file mode 100644 index 00000000000..4103a26c75a --- /dev/null +++ b/spec/models/web_ide_terminal_spec.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe WebIdeTerminal do + let(:build) { create(:ci_build) } + + subject { described_class.new(build) } + + it 'returns the show_path of the build' do + expect(subject.show_path).to end_with("/ide_terminals/#{build.id}") + end + + it 'returns the retry_path of the build' do + expect(subject.retry_path).to end_with("/ide_terminals/#{build.id}/retry") + end + + it 'returns the cancel_path of the build' do + expect(subject.cancel_path).to end_with("/ide_terminals/#{build.id}/cancel") + end + + it 'returns the terminal_path of the build' do + expect(subject.terminal_path).to end_with("/jobs/#{build.id}/terminal.ws") + end + + it 'returns the proxy_websocket_path of the build' do + expect(subject.proxy_websocket_path).to end_with("/jobs/#{build.id}/proxy.ws") + end + + describe 'services' do + let(:services_with_aliases) do + { + services: [{ name: 'postgres', alias: 'postgres' }, + { name: 'docker:stable-dind', alias: 'docker' }] + } + end + + before do + allow(build).to receive(:options).and_return(config) + end + + context 'when image does not have an alias' do + let(:config) do + { image: 'ruby:2.7' }.merge(services_with_aliases) + end + + it 'returns services aliases' do + expect(subject.services).to eq %w(postgres docker) + end + end + + context 'when both image and services have aliases' do + let(:config) do + { image: { name: 'ruby:2.7', alias: 'ruby' } }.merge(services_with_aliases) + end + + it 'returns all aliases' do + expect(subject.services).to eq %w(postgres docker ruby) + end + end + + context 'when image and services does not have any alias' do + let(:config) do + { image: 'ruby:2.7', services: ['postgres'] } + end + + it 'returns an empty array' do + expect(subject.services).to be_empty + end + end + + context 'when no image nor services' do + let(:config) do + { script: %w(echo) } + end + + it 'returns an empty array' do + expect(subject.services).to be_empty + end + end + end +end |