summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-10 23:28:42 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-10 23:28:42 +0300
commit001f3bc59ef34752b98ab405fde2520b15eff51c (patch)
tree80a74c103fe12efdd374219c01fb113f4e1baede /spec/support
parent0ae892007dac045e58cab793806f778b90ce6c2e (diff)
downloadgitlab-ce-001f3bc59ef34752b98ab405fde2520b15eff51c.tar.gz
Specs refactoring to reduce test time. Disabled observers by default for specs
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/test_env.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 370094d3765..5358143c62b 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -12,7 +12,15 @@ module TestEnv
# - add_key
# - remove_key
#
- def init
+ def init(opts = {})
+ # Disable observers to improve test speed
+ #
+ # You can enable it in whole test case where needed by next string:
+ #
+ # before(:each) { enable_observers }
+ #
+ disable_observers if opts[:observers] == false
+
# Use tmp dir for FS manipulations
repos_path = Rails.root.join('tmp', 'test-git-base-path')
Gitlab.config.gitlab_shell.stub(repos_path: repos_path)
@@ -60,4 +68,12 @@ module TestEnv
command = "git init --quiet --bare #{path};"
system(command)
end
+
+ def enable_observers
+ ActiveRecord::Base.observers.enable(:all)
+ end
+
+ def disable_observers
+ ActiveRecord::Base.observers.disable(:all)
+ end
end