From e99ab091db75e84280d8e0d4e289926c0533e6d9 Mon Sep 17 00:00:00 2001 From: alex-sig <143193681+alex-sig@users.noreply.github.com> Date: Thu, 7 Mar 2024 12:56:35 +0530 Subject: [PATCH] OTWO-7202 Enlistment page must render without code location (#1772) --- app/null_models/nil_code_location.rb | 6 +++++- app/null_models/null_object.rb | 4 ++++ test/controllers/enlistments_controller_test.rb | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/null_models/nil_code_location.rb b/app/null_models/nil_code_location.rb index 3c407cdb2..247a9f06d 100644 --- a/app/null_models/nil_code_location.rb +++ b/app/null_models/nil_code_location.rb @@ -2,12 +2,16 @@ class NilCodeLocation < NullObject blank_methods :url, :nice_url - nil_methods :branch, :username, :password + nil_methods :branch, :username, :password, :cl_update_event_time, :best_code_set def scm_type :git end + def scm_name_in_english + :Git + end + def do_not_fetch true end diff --git a/app/null_models/null_object.rb b/app/null_models/null_object.rb index 879cb8005..c8d75e3b1 100644 --- a/app/null_models/null_object.rb +++ b/app/null_models/null_object.rb @@ -1,6 +1,10 @@ # frozen_string_literal: true class NullObject + def id + rand(20_000) + end + def nil? true end diff --git a/test/controllers/enlistments_controller_test.rb b/test/controllers/enlistments_controller_test.rb index fe823c47b..4a8a73e15 100644 --- a/test/controllers/enlistments_controller_test.rb +++ b/test/controllers/enlistments_controller_test.rb @@ -46,6 +46,14 @@ class EnlistmentsControllerTest < ActionController::TestCase _(response.body).must_match I18n.t('enlistments.index.failure.dnf_present') end + it 'must render page when code_location is null' do + Enlistment.any_instance.stubs(:code_location).returns(NilCodeLocation.new) + + mock_and_get :index, params: { project_id: @project_id } + + assert_response :ok + end + it 'must render projects/deleted when project is deleted' do login_as @account ApplicationController.any_instance.stubs(:current_user_can_manage?).returns(true)