Stub DetectRepositoryLanguagesWorker for all tests
It performs an expensive operation, but isn't required in most of tests
This commit is contained in:
parent
ab27d66a7f
commit
8dcddb9886
|
@ -456,6 +456,10 @@ class Repository
|
||||||
def after_import
|
def after_import
|
||||||
expire_content_cache
|
expire_content_cache
|
||||||
|
|
||||||
|
# This call is stubbed in tests due to being an expensive operation
|
||||||
|
# It can be reenabled for specific tests via:
|
||||||
|
#
|
||||||
|
# allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_call_original
|
||||||
DetectRepositoryLanguagesWorker.perform_async(project.id)
|
DetectRepositoryLanguagesWorker.perform_async(project.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ shared_examples 'languages and percentages JSON response' do
|
||||||
let(:expected_languages) { project.repository.languages.map { |language| language.values_at(:label, :value)}.to_h }
|
let(:expected_languages) { project.repository.languages.map { |language| language.values_at(:label, :value)}.to_h }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_call_original
|
||||||
|
|
||||||
allow(project.repository).to receive(:languages).and_return(
|
allow(project.repository).to receive(:languages).and_return(
|
||||||
[{ value: 66.69, label: "Ruby", color: "#701516", highlight: "#701516" },
|
[{ value: 66.69, label: "Ruby", color: "#701516", highlight: "#701516" },
|
||||||
{ value: 22.98, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
|
{ value: 22.98, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
|
||||||
|
|
|
@ -148,6 +148,12 @@ RSpec.configure do |config|
|
||||||
.with(:force_autodevops_on_by_default, anything)
|
.with(:force_autodevops_on_by_default, anything)
|
||||||
.and_return(false)
|
.and_return(false)
|
||||||
|
|
||||||
|
# Stub this call due to being an expensive operation
|
||||||
|
# It can be reenabled for specific tests via:
|
||||||
|
#
|
||||||
|
# allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_call_original
|
||||||
|
allow(DetectRepositoryLanguagesWorker).to receive(:perform_async).and_return(true)
|
||||||
|
|
||||||
Gitlab::ThreadMemoryCache.cache_backend.clear
|
Gitlab::ThreadMemoryCache.cache_backend.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ module ProjectForksHelper
|
||||||
# not reset the @exists variable of this forked_project.repository
|
# not reset the @exists variable of this forked_project.repository
|
||||||
# so we have to explicitly call this method to clear the @exists variable.
|
# so we have to explicitly call this method to clear the @exists variable.
|
||||||
# of the instance we're returning here.
|
# of the instance we're returning here.
|
||||||
forked_project.repository.after_import
|
forked_project.repository.expire_content_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
forked_project
|
forked_project
|
||||||
|
|
Loading…
Reference in New Issue