Skip to content

Add prepend_mod to Registrations::CreateProject

Yongbo li requested to merge gitlab-jh/jh-team/gitlab:jh_onboarding into master

What does this MR do and why?

Relates to: New users onboarding with hands-on labs

In order to replace LearnGitLab project template, we need to override the learn_gitlab_template_path method redict to jh own dictionary

Since the instnce method defined in included do block can't overwrite success, i need to remove it

eg:

require 'active_support'
module Foo
  extend ActiveSupport::Concern

  included do
    def puts_1
      puts 1
    end
  end
end

module Foo2
  extend ActiveSupport::Concern

  def puts_1
    puts 3
  end
end

class Bar
  include Foo
  include Foo2
end

pp Bar.ancestors #=> [[Bar, Foo2, Foo, Object, Kernel, BasicObject]]
puts Bar.new.puts_1 # return 1

eg2:

module Registrations::CreateProject
   ...
   
   included do 
     private
     def override_me
       puts 'override fail'
     end
   end
end
...

module JH
  module Registrations::CreateProject
    extend ::Gitlab::Utils::Override
    
    private
    
    override :override_me
    def override_me
      puts "override success"
    end
  end
end


Registrations::GroupsProjectsController.new.send(:override_me) # puts 'override fail'

cc @zhanglinjie @daveliu

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Yongbo li

Merge request reports

Loading