summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-08-21 17:09:37 -0400
committerRobert Speicher <rspeicher@gmail.com>2017-08-22 13:06:25 -0400
commita6fbd8648e782d871482cad5719a4fdd9fa5a6bc (patch)
tree6217eda7bbd22e77288330c788dbbfe2062eabbc
parent8654b771588fff719aa313cd115b0c6fa4ab36f3 (diff)
downloadgitlab-ce-rs-stub-storage-availability-check.tar.gz
Stub `ForkedStorageCheck.storage_available?` by default in all specsrs-stub-storage-availability-check
Add `:broken_storage` metadata to examples to disable this behavior only when necessary.
-rw-r--r--spec/lib/gitlab/git/storage/forked_storage_check_spec.rb2
-rw-r--r--spec/spec_helper.rb12
2 files changed, 13 insertions, 1 deletions
diff --git a/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb b/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb
index 12366151f44..c708b15853a 100644
--- a/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb
+++ b/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::Storage::ForkedStorageCheck, skip_database_cleaner: true do
+describe Gitlab::Git::Storage::ForkedStorageCheck, broken_storage: true, skip_database_cleaner: true do
let(:existing_path) do
existing_path = TestEnv.repos_path
FileUtils.mkdir_p(existing_path)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c10197ff651..ff1754fbe7e 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -105,6 +105,18 @@ RSpec.configure do |config|
reset_delivered_emails!
end
+ # Stub the `ForkedStorageCheck.storage_available?` method unless
+ # `:broken_storage` metadata is defined
+ #
+ # This check can be slow and is unnecessary in a test environment where we
+ # know the storage is available, because we create it at runtime
+ config.before(:example) do |example|
+ unless example.metadata[:broken_storage]
+ allow(Gitlab::Git::Storage::ForkedStorageCheck)
+ .to receive(:storage_available?).and_return(true)
+ end
+ end
+
config.around(:each, :use_clean_rails_memory_store_caching) do |example|
caching_store = Rails.cache
Rails.cache = ActiveSupport::Cache::MemoryStore.new