Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
216d5e2c
Commit
216d5e2c
authored
Jun 07, 2013
by
Izaak Alpert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix intermittently failing notification_service test
Change-Id: Ic23cb46901f8adc77943bf3cc79566587364e22a
parent
5d56da6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
56 deletions
+63
-56
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+1
-0
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+0
-1
spec/support/test_env.rb
spec/support/test_env.rb
+62
-55
No files found.
spec/requests/api/repositories_spec.rb
View file @
216d5e2c
...
@@ -3,6 +3,7 @@ require 'spec_helper'
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
API
::
API
do
describe
API
::
API
do
include
ApiHelpers
include
ApiHelpers
before
(
:each
)
{
enable_observers
}
before
(
:each
)
{
enable_observers
}
after
(
:each
)
{
disable_observers
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
...
...
spec/services/notification_service_spec.rb
View file @
216d5e2c
...
@@ -2,7 +2,6 @@ require 'spec_helper'
...
@@ -2,7 +2,6 @@ require 'spec_helper'
describe
NotificationService
do
describe
NotificationService
do
let
(
:notification
)
{
NotificationService
.
new
}
let
(
:notification
)
{
NotificationService
.
new
}
describe
'Keys'
do
describe
'Keys'
do
describe
:new_key
do
describe
:new_key
do
let
(
:key
)
{
create
(
:personal_key
)
}
let
(
:key
)
{
create
(
:personal_key
)
}
...
...
spec/support/test_env.rb
View file @
216d5e2c
...
@@ -34,43 +34,19 @@ module TestEnv
...
@@ -34,43 +34,19 @@ module TestEnv
setup_test_repos
(
opts
)
if
opts
[
:repos
]
==
true
setup_test_repos
(
opts
)
if
opts
[
:repos
]
==
true
end
end
def
testing_path
def
enable_observers
Rails
.
root
.
join
(
'tmp'
,
'test-git-base-path'
)
ActiveRecord
::
Base
.
observers
.
enable
(
:all
)
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
end
def
repo
(
namespace
,
name
)
def
disable_observers
unless
(
namespace
.
nil?
||
namespace
.
path
.
nil?
||
namespace
.
path
.
strip
.
empty?
)
ActiveRecord
::
Base
.
observers
.
disable
(
:all
)
repo
=
File
.
join
(
testing_path
(),
"
#{
namespace
.
path
}
/
#{
name
}
.git"
)
else
repo
=
File
.
join
(
testing_path
(),
"
#{
name
}
.git"
)
end
end
end
def
satellite
(
namespace
,
name
)
def
disable_mailer
unless
(
namespace
.
nil?
||
namespace
.
path
.
nil?
||
namespace
.
path
.
strip
.
empty?
)
NotificationService
.
any_instance
.
stub
(
mailer:
double
.
as_null_object
)
satellite_repo
=
File
.
join
(
satellite_path
,
namespace
.
path
,
name
)
else
satellite_repo
=
File
.
join
(
satellite_path
,
name
)
end
end
end
def
enable_mailer
NotificationService
.
any_instance
.
unstub
(
:mailer
)
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
end
def
setup_stubs
()
def
setup_stubs
()
...
@@ -110,19 +86,6 @@ module TestEnv
...
@@ -110,19 +86,6 @@ module TestEnv
)
)
end
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
)
def
clear_repo_dir
(
namespace
,
name
)
setup_stubs
setup_stubs
#Clean any .wiki.git that may have been created
#Clean any .wiki.git that may have been created
...
@@ -139,6 +102,60 @@ module TestEnv
...
@@ -139,6 +102,60 @@ module TestEnv
create_satellite
(
repo
,
namespace
,
name
)
create_satellite
(
repo
,
namespace
,
name
)
end
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
# Create a testing satellite, and clone the source repo into it
def
create_satellite
(
source_repo
,
namespace
,
satellite_name
)
def
create_satellite
(
source_repo
,
namespace
,
satellite_name
)
satellite_repo
=
satellite
(
namespace
,
satellite_name
)
satellite_repo
=
satellite
(
namespace
,
satellite_name
)
...
@@ -152,15 +169,5 @@ module TestEnv
...
@@ -152,15 +169,5 @@ module TestEnv
system
(
command
)
system
(
command
)
end
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment