summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorIzaak Alpert <ialpert@blackberry.com>2013-06-07 16:39:32 -0400
committerIzaak Alpert <ialpert@blackberry.com>2013-07-17 22:42:51 -0400
commit216d5e2c1adb8470421a99943f09c45e4e515d5b (patch)
tree5fe021393eb8246c97942a26bda1576517ad5492 /spec
parent5d56da6bddcaa4d510fd97a8e38d80e750e3e20f (diff)
downloadgitlab-ce-216d5e2c1adb8470421a99943f09c45e4e515d5b.tar.gz
Fix intermittently failing notification_service test
Change-Id: Ic23cb46901f8adc77943bf3cc79566587364e22a
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/repositories_spec.rb1
-rw-r--r--spec/services/notification_service_spec.rb1
-rw-r--r--spec/support/test_env.rb117
3 files changed, 63 insertions, 56 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index 13e6627840e..afa67d1ecbe 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -3,6 +3,7 @@ require 'spec_helper'
describe API::API do
include ApiHelpers
before(:each) { enable_observers }
+ after(:each) {disable_observers}
let(:user) { create(:user) }
let(:user2) { create(:user) }
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 82f033a6e81..1a7a866307b 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -2,7 +2,6 @@ require 'spec_helper'
describe NotificationService do
let(:notification) { NotificationService.new }
-
describe 'Keys' do
describe :new_key do
let(:key) { create(:personal_key) }
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index b9e03be4ed3..6b83aad0182 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -34,43 +34,19 @@ module TestEnv
setup_test_repos(opts) if opts[:repos] == true
end
- def testing_path
- Rails.root.join('tmp', 'test-git-base-path')
- end
-
- def seed_repo_path
- Rails.root.join('tmp', 'repositories', 'gitlabhq')
- end
-
- def seed_satellite_path
- Rails.root.join('tmp', 'satellite', 'gitlabhq')
- end
-
- def satellite_path
- "#{testing_path()}/satellite"
+ def enable_observers
+ ActiveRecord::Base.observers.enable(:all)
end
- def repo(namespace, name)
- unless (namespace.nil? || namespace.path.nil? || namespace.path.strip.empty?)
- repo = File.join(testing_path(), "#{namespace.path}/#{name}.git")
- else
- repo = File.join(testing_path(), "#{name}.git")
- end
+ def disable_observers
+ ActiveRecord::Base.observers.disable(:all)
end
- def satellite(namespace, name)
- unless (namespace.nil? || namespace.path.nil? || namespace.path.strip.empty?)
- satellite_repo = File.join(satellite_path, namespace.path, name)
- else
- satellite_repo = File.join(satellite_path, name)
- end
+ def disable_mailer
+ NotificationService.any_instance.stub(mailer: double.as_null_object)
end
-
-
- def setup_test_repos(opts ={})
- create_repo(nil, 'gitlabhq') #unless opts[:repo].nil? || !opts[:repo].include?('')
- create_repo(nil, 'source_gitlabhq') #unless opts[:repo].nil? || !opts[:repo].include?('source_')
- create_repo(nil, 'target_gitlabhq') #unless opts[:repo].nil? || !opts[:repo].include?('target_')
+ def enable_mailer
+ NotificationService.any_instance.unstub(:mailer)
end
def setup_stubs()
@@ -110,19 +86,6 @@ module TestEnv
)
end
- def clear_test_repo_dir
- setup_stubs
- # Use tmp dir for FS manipulations
- repos_path = testing_path()
- # Remove tmp/test-git-base-path
- FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
-
- # Recreate tmp/test-git-base-path
- FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
- #Since much more is happening in satellites
- FileUtils.mkdir_p Gitlab.config.satellites.path
- end
-
def clear_repo_dir(namespace, name)
setup_stubs
#Clean any .wiki.git that may have been created
@@ -139,6 +102,60 @@ module TestEnv
create_satellite(repo, namespace, name)
end
+ private
+
+ def testing_path
+ Rails.root.join('tmp', 'test-git-base-path')
+ end
+
+ def seed_repo_path
+ Rails.root.join('tmp', 'repositories', 'gitlabhq')
+ end
+
+ def seed_satellite_path
+ Rails.root.join('tmp', 'satellite', 'gitlabhq')
+ end
+
+ def satellite_path
+ "#{testing_path()}/satellite"
+ end
+
+ def repo(namespace, name)
+ unless (namespace.nil? || namespace.path.nil? || namespace.path.strip.empty?)
+ repo = File.join(testing_path(), "#{namespace.path}/#{name}.git")
+ else
+ repo = File.join(testing_path(), "#{name}.git")
+ end
+ end
+
+ def satellite(namespace, name)
+ unless (namespace.nil? || namespace.path.nil? || namespace.path.strip.empty?)
+ satellite_repo = File.join(satellite_path, namespace.path, name)
+ else
+ satellite_repo = File.join(satellite_path, name)
+ end
+ end
+
+ def setup_test_repos(opts ={})
+ create_repo(nil, 'gitlabhq') #unless opts[:repo].nil? || !opts[:repo].include?('')
+ create_repo(nil, 'source_gitlabhq') #unless opts[:repo].nil? || !opts[:repo].include?('source_')
+ create_repo(nil, 'target_gitlabhq') #unless opts[:repo].nil? || !opts[:repo].include?('target_')
+ end
+
+ def clear_test_repo_dir
+ setup_stubs
+ # Use tmp dir for FS manipulations
+ repos_path = testing_path()
+ # Remove tmp/test-git-base-path
+ FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path
+
+ # Recreate tmp/test-git-base-path
+ FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
+
+ #Since much more is happening in satellites
+ FileUtils.mkdir_p Gitlab.config.satellites.path
+ end
+
# Create a testing satellite, and clone the source repo into it
def create_satellite(source_repo, namespace, satellite_name)
satellite_repo = satellite(namespace, satellite_name)
@@ -152,15 +169,5 @@ module TestEnv
system(command)
end
- def enable_observers
- ActiveRecord::Base.observers.enable(:all)
- end
-
- def disable_observers
- ActiveRecord::Base.observers.disable(:all)
- end
- def disable_mailer
- NotificationService.any_instance.stub(mailer: double.as_null_object)
- end
end