diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-18 17:14:36 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-11-18 17:14:36 +0200 |
commit | f7bf892cca6bb8106194c14bef1ed9ddfc26ec91 (patch) | |
tree | b9f47db5ffcb682281a52f281069e2bd8a852bad /spec/support/test_env.rb | |
parent | cfee95d0327485dffb8ea4d698d3f7f310fc6c19 (diff) | |
download | gitlab-ce-f7bf892cca6bb8106194c14bef1ed9ddfc26ec91.tar.gz |
Revert "gitlab shell works if multiple rubies installed"
This reverts commit 533f4cdf30b38c587f7a91f0dfd898b907ecd944.
Diffstat (limited to 'spec/support/test_env.rb')
-rw-r--r-- | spec/support/test_env.rb | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index eb665b8b618..e6db410fb1c 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -1,5 +1,4 @@ require 'rspec/mocks' -require 'webrick' module TestEnv extend self @@ -25,6 +24,8 @@ module TestEnv disable_mailer if opts[:mailer] == false # Clean /tmp/tests + tmp_test_path = Rails.root.join('tmp', 'tests') + if File.directory?(tmp_test_path) Dir.entries(tmp_test_path).each do |entry| unless ['.', '..', 'gitlab-shell', factory_repo_name].include?(entry) @@ -38,8 +39,6 @@ module TestEnv # Setup GitLab shell for test instance setup_gitlab_shell - setup_internal_api_mock - # Create repository for FactoryGirl.create(:project) setup_factory_repo end @@ -109,52 +108,4 @@ module TestEnv def factory_repo_name 'gitlab-test' end - - def tmp_test_path - Rails.root.join('tmp', 'tests') - end - - def internal_api_mock_pid_path - File.join(tmp_test_path, 'internal_api_mock.pid') - end - - # This mock server exists because during testing GitLab is not served - # on any port, but gitlab-shell needs to ask the GitLab internal API - # if it is OK to push to repositories. This can happen during blob web - # edit tests. The server always replies yes: this should not modify affect - # web interface tests. - def setup_internal_api_mock - begin - server = WEBrick::HTTPServer.new( - BindAddress: '0.0.0.0', - Port: Gitlab.config.gitlab.port, - AccessLog: [], - Logger: WEBrick::Log.new('/dev/null') - ) - rescue => ex - ex.message.prepend('could not start mock server on configured port. ') - raise ex - end - fork do - trap(:INT) { server.shutdown } - server.mount_proc('/') do |_req, res| - res.status = 200 - res.body = 'true' - end - WEBrick::Daemon.start do - File.write(internal_api_mock_pid_path, Process.pid) - end - server.start - end - # Ideally this should be called from `config.after(:suite)`, - # but on Spinach when user hits Ctrl+C the server does not get killed - # if the hook is set up with `Spinach.hooks.after_run`. - at_exit do - # The file should exist on normal operation, - # but certain errors can lead to it not existing. - if File.exists?(internal_api_mock_pid_path) - Process.kill(:INT, File.read(internal_api_mock_pid_path).to_i) - end - end - end end |