Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
3d698028840e
Unverified
Commit
4a1654ed
authored
Jan 16, 2014
by
Dmitriy Zaporozhets
Browse files
Replace context with service in specs
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
632cfe7823cc
Changes
6
Hide whitespace changes
Inline
Side-by-side
spec/models/forked_project_link_spec.rb
View file @
3d698028
...
...
@@ -58,7 +58,7 @@
end
def
fork_project
(
from_project
,
user
)
context
=
Projects
::
Fork
Context
.
new
(
from_project
,
user
)
context
=
Projects
::
Fork
Service
.
new
(
from_project
,
user
)
shell
=
double
(
"gitlab_shell"
)
shell
.
stub
(
fork_repository:
true
)
context
.
stub
(
gitlab_shell:
shell
)
...
...
spec/
contexts/fork_context
_spec.rb
→
spec/
services/fork_service
_spec.rb
View file @
3d698028
require
'spec_helper'
describe
Projects
::
Fork
Context
do
describe
Projects
::
Fork
Service
do
describe
:fork_by_user
do
before
do
@from_namespace
=
create
(
:namespace
)
...
...
@@ -47,7 +47,7 @@
end
def
fork_project
(
from_project
,
user
,
fork_success
=
true
)
context
=
Projects
::
Fork
Context
.
new
(
from_project
,
user
)
context
=
Projects
::
Fork
Service
.
new
(
from_project
,
user
)
shell
=
double
(
"gitlab_shell"
)
shell
.
stub
(
fork_repository:
fork_success
)
context
.
stub
(
gitlab_shell:
shell
)
...
...
spec/
context
s/issues/bulk_update_context_spec.rb
→
spec/
service
s/issues/bulk_update_context_spec.rb
View file @
3d698028
require
'spec_helper'
describe
Issues
::
BulkUpdate
Context
do
describe
Issues
::
BulkUpdate
Service
do
before
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
enable
(
:user_observer
)
}
after
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
disable
(
:user_observer
)
}
...
...
@@ -14,7 +14,7 @@
name:
"GitLab"
,
namespace:
@user
.
namespace
}
@project
=
Projects
::
Create
Context
.
new
(
@user
,
opts
).
execute
@project
=
Projects
::
Create
Service
.
new
(
@user
,
opts
).
execute
end
describe
:close_issue
do
...
...
@@ -32,7 +32,7 @@
end
it
{
result
=
Issues
::
BulkUpdate
Context
.
new
(
@project
,
@user
,
@params
).
execute
result
=
Issues
::
BulkUpdate
Service
.
new
(
@project
,
@user
,
@params
).
execute
result
[
:success
].
should
be_true
result
[
:count
].
should
==
@issues
.
count
...
...
@@ -57,7 +57,7 @@
end
it
{
result
=
Issues
::
BulkUpdate
Context
.
new
(
@project
,
@user
,
@params
).
execute
result
=
Issues
::
BulkUpdate
Service
.
new
(
@project
,
@user
,
@params
).
execute
result
[
:success
].
should
be_true
result
[
:count
].
should
==
@issues
.
count
...
...
@@ -80,7 +80,7 @@
end
it
{
result
=
Issues
::
BulkUpdate
Context
.
new
(
@project
,
@user
,
@params
).
execute
result
=
Issues
::
BulkUpdate
Service
.
new
(
@project
,
@user
,
@params
).
execute
result
[
:success
].
should
be_true
result
[
:count
].
should
==
1
...
...
@@ -102,7 +102,7 @@
end
it
{
result
=
Issues
::
BulkUpdate
Context
.
new
(
@project
,
@user
,
@params
).
execute
result
=
Issues
::
BulkUpdate
Service
.
new
(
@project
,
@user
,
@params
).
execute
result
[
:success
].
should
be_true
result
[
:count
].
should
==
1
...
...
spec/
context
s/projects_create_
context
_spec.rb
→
spec/
service
s/projects_create_
service
_spec.rb
View file @
3d698028
require
'spec_helper'
describe
Projects
::
Create
Context
do
describe
Projects
::
Create
Service
do
before
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
enable
(
:user_observer
)
}
after
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
disable
(
:user_observer
)
}
...
...
@@ -136,7 +136,7 @@
end
def
create_project
(
user
,
opts
)
Projects
::
Create
Context
.
new
(
user
,
opts
).
execute
Projects
::
Create
Service
.
new
(
user
,
opts
).
execute
end
end
spec/
context
s/projects_update_
context
_spec.rb
→
spec/
service
s/projects_update_
service
_spec.rb
View file @
3d698028
require
'spec_helper'
describe
Projects
::
Update
Context
do
describe
Projects
::
Update
Service
do
before
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
enable
(
:user_observer
)
}
after
(
:each
)
{
ActiveRecord
::
Base
.
observers
.
disable
(
:user_observer
)
}
...
...
@@ -106,6 +106,6 @@
end
def
update_project
(
project
,
user
,
opts
)
Projects
::
Update
Context
.
new
(
project
,
user
,
opts
).
execute
Projects
::
Update
Service
.
new
(
project
,
user
,
opts
).
execute
end
end
\ No newline at end of file
end
spec/
context
s/search_
context
_spec.rb
→
spec/
service
s/search_
service
_spec.rb
View file @
3d698028
require
'spec_helper'
describe
'Search::Global
Context
'
do
describe
'Search::Global
Service
'
do
let
(
:found_namespace
)
{
create
(
:namespace
,
name:
'searchable namespace'
,
path
:'another_thing'
)
}
let
(
:user
)
{
create
(
:user
,
namespace:
found_namespace
)
}
let!
(
:found_project
)
{
create
(
:project
,
name:
'searchable_project'
,
creator_id:
user
.
id
,
namespace:
found_namespace
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
}
...
...
@@ -19,7 +19,7 @@
describe
'#execute'
do
context
'unauthenticated'
do
it
'should return public projects only'
do
context
=
Search
::
Global
Context
.
new
(
nil
,
search:
"searchable"
)
context
=
Search
::
Global
Service
.
new
(
nil
,
search:
"searchable"
)
results
=
context
.
execute
results
[
:projects
].
should
have
(
1
).
items
results
[
:projects
].
should
include
(
public_project
)
...
...
@@ -28,7 +28,7 @@
context
'authenticated'
do
it
'should return public, internal and private projects'
do
context
=
Search
::
Global
Context
.
new
(
user
,
search:
"searchable"
)
context
=
Search
::
Global
Service
.
new
(
user
,
search:
"searchable"
)
results
=
context
.
execute
results
[
:projects
].
should
have
(
3
).
items
results
[
:projects
].
should
include
(
public_project
)
...
...
@@ -37,7 +37,7 @@
end
it
'should return only public & internal projects'
do
context
=
Search
::
Global
Context
.
new
(
internal_user
,
search:
"searchable"
)
context
=
Search
::
Global
Service
.
new
(
internal_user
,
search:
"searchable"
)
results
=
context
.
execute
results
[
:projects
].
should
have
(
2
).
items
results
[
:projects
].
should
include
(
internal_project
)
...
...
@@ -45,7 +45,7 @@
end
it
'namespace name should be searchable'
do
context
=
Search
::
Global
Context
.
new
(
user
,
search:
"searchable namespace"
)
context
=
Search
::
Global
Service
.
new
(
user
,
search:
"searchable namespace"
)
results
=
context
.
execute
results
[
:projects
].
should
==
[
found_project
]
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