debian-mirror-gitlab/spec/services/ide/terminal_config_service_spec.rb

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

71 lines
1.6 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Ide::TerminalConfigService, feature_category: :web_ide do
2020-11-24 15:15:51 +05:30
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
2021-04-29 21:17:54 +05:30
2020-11-24 15:15:51 +05:30
let(:sha) { 'sha' }
describe '#execute' do
subject { described_class.new(project, user, sha: sha).execute }
before do
project.add_developer(user)
allow(project.repository).to receive(:blob_data_at).with('sha', anything) do
config_content
end
end
context 'content is not valid' do
let(:config_content) { 'invalid content' }
it 'returns an error' do
is_expected.to include(
status: :error,
message: "Invalid configuration format")
end
end
context 'terminal not defined' do
let(:config_content) { '{}' }
it 'returns success' do
is_expected.to include(
status: :success,
terminal: nil)
end
end
context 'terminal enabled' do
let(:config_content) { 'terminal: {}' }
it 'returns success' do
is_expected.to include(
status: :success,
terminal: {
tag_list: [],
2021-04-29 21:17:54 +05:30
job_variables: [],
2020-11-24 15:15:51 +05:30
options: { script: ["sleep 60"] }
})
end
end
context 'custom terminal enabled' do
let(:config_content) { 'terminal: { before_script: [ls] }' }
it 'returns success' do
is_expected.to include(
status: :success,
terminal: {
tag_list: [],
2021-04-29 21:17:54 +05:30
job_variables: [],
2020-11-24 15:15:51 +05:30
options: { before_script: ["ls"], script: ["sleep 60"] }
})
end
end
end
end