diff options
Diffstat (limited to 'spec/helpers/ci/pipelines_helper_spec.rb')
-rw-r--r-- | spec/helpers/ci/pipelines_helper_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/helpers/ci/pipelines_helper_spec.rb b/spec/helpers/ci/pipelines_helper_spec.rb index 751bcc97582..2b76eaa87bc 100644 --- a/spec/helpers/ci/pipelines_helper_spec.rb +++ b/spec/helpers/ci/pipelines_helper_spec.rb @@ -93,4 +93,63 @@ RSpec.describe Ci::PipelinesHelper do end end end + + describe '#pipelines_list_data' do + let_it_be(:project) { create(:project) } + + subject(:data) { helper.pipelines_list_data(project, 'list_url') } + + before do + allow(helper).to receive(:can?).and_return(true) + end + + it 'has the expected keys' do + expect(subject.keys).to match_array([:endpoint, + :project_id, + :default_branch_name, + :params, + :artifacts_endpoint, + :artifacts_endpoint_placeholder, + :pipeline_schedule_url, + :empty_state_svg_path, + :error_state_svg_path, + :no_pipelines_svg_path, + :can_create_pipeline, + :new_pipeline_path, + :ci_lint_path, + :reset_cache_path, + :has_gitlab_ci, + :pipeline_editor_path, + :suggested_ci_templates, + :ci_runner_settings_path]) + end + + describe 'the `any_runners_available` attribute' do + subject { data[:any_runners_available] } + + context 'when the `runners_availability_section` experiment variant is control' do + before do + stub_experiments(runners_availability_section: :control) + end + + it { is_expected.to be_nil } + end + + context 'when the `runners_availability_section` experiment variant is candidate' do + before do + stub_experiments(runners_availability_section: :candidate) + end + + context 'when there are no runners' do + it { is_expected.to eq('false') } + end + + context 'when there are runners' do + let!(:runner) { create(:ci_runner, :project, projects: [project]) } + + it { is_expected.to eq('true') } + end + end + end + end end |