diff options
Diffstat (limited to 'spec/helpers/ci')
-rw-r--r-- | spec/helpers/ci/pipeline_editor_helper_spec.rb | 32 | ||||
-rw-r--r-- | spec/helpers/ci/runners_helper_spec.rb | 30 |
2 files changed, 51 insertions, 11 deletions
diff --git a/spec/helpers/ci/pipeline_editor_helper_spec.rb b/spec/helpers/ci/pipeline_editor_helper_spec.rb index 7686983eb0f..a08517d0c57 100644 --- a/spec/helpers/ci/pipeline_editor_helper_spec.rb +++ b/spec/helpers/ci/pipeline_editor_helper_spec.rb @@ -20,4 +20,36 @@ RSpec.describe Ci::PipelineEditorHelper do expect(subject).to be false end end + + describe '#js_pipeline_editor_data' do + let(:project) { create(:project, :repository) } + + before do + allow(helper) + .to receive(:namespace_project_new_merge_request_path) + .and_return('/mock/project/-/merge_requests/new') + + allow(helper) + .to receive(:image_path) + .and_return('foo') + end + + subject(:pipeline_editor_data) { helper.js_pipeline_editor_data(project) } + + it 'returns pipeline editor data' do + expect(pipeline_editor_data).to eq({ + "ci-config-path": project.ci_config_path_or_default, + "commit-sha" => project.commit.sha, + "default-branch" => project.default_branch, + "empty-state-illustration-path" => 'foo', + "initial-branch-name": nil, + "lint-help-page-path" => help_page_path('ci/lint', anchor: 'validate-basic-logic-and-syntax'), + "new-merge-request-path" => '/mock/project/-/merge_requests/new', + "project-path" => project.path, + "project-full-path" => project.full_path, + "project-namespace" => project.namespace.full_path, + "yml-help-page-path" => help_page_path('ci/yaml/README') + }) + end + end end diff --git a/spec/helpers/ci/runners_helper_spec.rb b/spec/helpers/ci/runners_helper_spec.rb index 6e41afac4ee..94d4d620de9 100644 --- a/spec/helpers/ci/runners_helper_spec.rb +++ b/spec/helpers/ci/runners_helper_spec.rb @@ -3,19 +3,26 @@ require 'spec_helper' RSpec.describe Ci::RunnersHelper do - it "returns - not contacted yet" do - runner = FactoryBot.build :ci_runner - expect(runner_status_icon(runner)).to include("not connected yet") - end + describe '#runner_status_icon', :clean_gitlab_redis_cache do + it "returns - not contacted yet" do + runner = create(:ci_runner) + expect(runner_status_icon(runner)).to include("not connected yet") + end - it "returns offline text" do - runner = FactoryBot.build(:ci_runner, contacted_at: 1.day.ago, active: true) - expect(runner_status_icon(runner)).to include("Runner is offline") - end + it "returns offline text" do + runner = create(:ci_runner, contacted_at: 1.day.ago, active: true) + expect(runner_status_icon(runner)).to include("Runner is offline") + end - it "returns online text" do - runner = FactoryBot.build(:ci_runner, contacted_at: 1.second.ago, active: true) - expect(runner_status_icon(runner)).to include("Runner is online") + it "returns online text" do + runner = create(:ci_runner, contacted_at: 1.second.ago, active: true) + expect(runner_status_icon(runner)).to include("Runner is online") + end + + it "returns paused text" do + runner = create(:ci_runner, contacted_at: 1.second.ago, active: false) + expect(runner_status_icon(runner)).to include("Runner is paused") + end end describe '#runner_contacted_at' do @@ -77,6 +84,7 @@ RSpec.describe Ci::RunnersHelper do describe '#toggle_shared_runners_settings_data' do let_it_be(:group) { create(:group) } + let(:project_with_runners) { create(:project, namespace: group, shared_runners_enabled: true) } let(:project_without_runners) { create(:project, namespace: group, shared_runners_enabled: false) } |