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
Boxiang Sun
gitlab-ce
Commits
96ce4ed2
Commit
96ce4ed2
authored
Jun 11, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work around limitations of expect_any_instance_of by stubbing Project.find
parent
6defeb0a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
9 deletions
+23
-9
spec/models/project_spec.rb
spec/models/project_spec.rb
+5
-1
spec/workers/repository_fork_worker_spec.rb
spec/workers/repository_fork_worker_spec.rb
+8
-3
spec/workers/repository_import_worker_spec.rb
spec/workers/repository_import_worker_spec.rb
+10
-5
No files found.
spec/models/project_spec.rb
View file @
96ce4ed2
...
...
@@ -1726,7 +1726,11 @@ describe Project do
.
with
(
project
.
repository_storage
,
project
.
disk_path
,
project
.
import_url
)
.
and_return
(
true
)
expect_any_instance_of
(
Repository
).
to
receive
(
:after_import
)
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect
(
Project
).
to
receive
(
:find
).
with
(
project
.
id
).
twice
.
and_return
(
project
)
expect
(
project
.
repository
).
to
receive
(
:after_import
)
.
and_call_original
expect
(
project
.
wiki
.
repository
).
to
receive
(
:after_import
)
.
and_call_original
end
...
...
spec/workers/repository_fork_worker_spec.rb
View file @
96ce4ed2
...
...
@@ -55,10 +55,15 @@ describe RepositoryForkWorker do
it
'flushes various caches'
do
expect_fork_repository
.
and_return
(
true
)
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_emptiness_caches
)
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect
(
Project
).
to
receive
(
:find
).
with
(
fork_project
.
id
).
and_return
(
fork_project
)
expect
(
fork_project
.
repository
).
to
receive
(
:expire_emptiness_caches
)
.
and_call_original
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_exists_cache
)
expect
(
fork_project
.
repository
).
to
receive
(
:expire_exists_cache
)
.
and_call_original
expect
(
fork_project
.
wiki
.
repository
).
to
receive
(
:expire_emptiness_caches
)
.
and_call_original
expect
(
fork_project
.
wiki
.
repository
).
to
receive
(
:expire_exists_cache
)
.
and_call_original
perform!
...
...
spec/workers/repository_import_worker_spec.rb
View file @
96ce4ed2
...
...
@@ -22,8 +22,11 @@ describe RepositoryImportWorker do
expect_any_instance_of
(
Projects
::
ImportService
).
to
receive
(
:execute
)
.
and_return
({
status: :ok
})
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_emptiness_caches
)
expect_any_instance_of
(
Project
).
to
receive
(
:import_finish
)
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect
(
Project
).
to
receive
(
:find
).
with
(
project
.
id
).
and_return
(
project
)
expect
(
project
.
repository
).
to
receive
(
:expire_emptiness_caches
)
expect
(
project
.
wiki
.
repository
).
to
receive
(
:expire_emptiness_caches
)
expect
(
project
).
to
receive
(
:import_finish
)
subject
.
perform
(
project
.
id
)
end
...
...
@@ -34,9 +37,11 @@ describe RepositoryImportWorker do
expect_any_instance_of
(
Projects
::
ImportService
).
to
receive
(
:execute
)
.
and_return
({
status: :ok
})
expect_any_instance_of
(
Project
).
to
receive
(
:after_import
).
and_call_original
expect_any_instance_of
(
Repository
).
to
receive
(
:expire_emptiness_caches
)
expect_any_instance_of
(
Project
).
to
receive
(
:import_finish
)
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect
(
Project
).
to
receive
(
:find
).
with
(
project
.
id
).
and_return
(
project
)
expect
(
project
.
repository
).
to
receive
(
:expire_emptiness_caches
)
expect
(
project
.
wiki
.
repository
).
to
receive
(
:expire_emptiness_caches
)
expect
(
project
).
to
receive
(
:import_finish
)
subject
.
perform
(
project
.
id
)
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