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
Léo-Paul Géneau
gitlab-ce
Commits
14fbff00
Commit
14fbff00
authored
Jul 14, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for changing default branch in a project
parent
613208c3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
10 deletions
+26
-10
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+1
-1
spec/services/projects/update_service_spec.rb
spec/services/projects/update_service_spec.rb
+25
-9
No files found.
app/services/projects/update_service.rb
View file @
14fbff00
...
@@ -10,7 +10,7 @@ module Projects
...
@@ -10,7 +10,7 @@ module Projects
end
end
if
changing_default_branch?
if
changing_default_branch?
project
.
change_head
(
new_branch
)
project
.
change_head
(
params
[
:default_branch
]
)
end
end
if
project
.
update_attributes
(
params
.
except
(
:default_branch
))
if
project
.
update_attributes
(
params
.
except
(
:default_branch
))
...
...
spec/services/projects/update_service_spec.rb
View file @
14fbff00
require
'spec_helper'
require
'spec_helper'
describe
Projects
::
UpdateService
,
services:
true
do
describe
Projects
::
UpdateService
,
'#execute'
,
:services
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:project
)
{
create
(
:empty_project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
describe
'update_by_user'
do
let
(
:project
)
do
create
(
:empty_project
,
creator:
user
,
namespace:
user
.
namespace
)
end
context
'when changing visibility level'
do
context
'when visibility_level is INTERNAL'
do
context
'when visibility_level is INTERNAL'
do
it
'updates the project to internal'
do
it
'updates the project to internal'
do
result
=
update_project
(
project
,
user
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
result
=
update_project
(
project
,
user
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
...
@@ -55,12 +58,13 @@ describe Projects::UpdateService, services: true do
...
@@ -55,12 +58,13 @@ describe Projects::UpdateService, services: true do
end
end
end
end
describe
'
visibility_level
'
do
describe
'
when updating project that has forks
'
do
let
(
:project
)
{
create
(
:empty_project
,
:internal
)
}
let
(
:project
)
{
create
(
:empty_project
,
:internal
)
}
let
(
:forked_project
)
{
create
(
:forked_project_with_submodules
,
:internal
)
}
let
(
:forked_project
)
{
create
(
:forked_project_with_submodules
,
:internal
)
}
before
do
before
do
forked_project
.
build_forked_project_link
(
forked_to_project_id:
forked_project
.
id
,
forked_from_project_id:
project
.
id
)
forked_project
.
build_forked_project_link
(
forked_to_project_id:
forked_project
.
id
,
forked_from_project_id:
project
.
id
)
forked_project
.
save
forked_project
.
save
end
end
...
@@ -89,12 +93,24 @@ describe Projects::UpdateService, services: true do
...
@@ -89,12 +93,24 @@ describe Projects::UpdateService, services: true do
end
end
end
end
context
'when updating a default branch'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
it
'changes a default branch'
do
update_project
(
project
,
admin
,
default_branch:
'feature'
)
expect
(
Project
.
find
(
project
.
id
).
default_branch
).
to
eq
'feature'
end
end
context
'when passing invalid parameters'
do
it
'returns an error result when record cannot be updated'
do
it
'returns an error result when record cannot be updated'
do
result
=
update_project
(
project
,
admin
,
{
name:
'foo&bar'
})
result
=
update_project
(
project
,
admin
,
{
name:
'foo&bar'
})
expect
(
result
).
to
eq
({
status: :error
,
expect
(
result
).
to
eq
({
status: :error
,
message:
'Project could not be updated!'
})
message:
'Project could not be updated!'
})
end
end
end
def
update_project
(
project
,
user
,
opts
)
def
update_project
(
project
,
user
,
opts
)
described_class
.
new
(
project
,
user
,
opts
).
execute
described_class
.
new
(
project
,
user
,
opts
).
execute
...
...
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