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
a7ce8a837527
Commit
a7ce8a83
authored
Jun 30, 2014
by
Dmitriy Zaporozhets
Browse files
Fix signup and project visibility
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
89213926d653
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/controllers/registrations_controller.rb
View file @
a7ce8a83
...
...
@@ -13,7 +13,6 @@
def
build_resource
(
hash
=
nil
)
super
self
.
resource
.
with_defaults
end
private
...
...
app/models/project.rb
View file @
a7ce8a83
...
...
@@ -97,6 +97,9 @@
message:
"only letters, digits & '_' '-' '.' allowed. Letter or digit should be first"
}
validates
:issues_enabled
,
:merge_requests_enabled
,
:wiki_enabled
,
inclusion:
{
in:
[
true
,
false
]
}
validates
:visibility_level
,
exclusion:
{
in:
gitlab_config
.
restricted_visibility_levels
},
if:
->
{
gitlab_config
.
restricted_visibility_levels
.
any?
}
validates
:issues_tracker_id
,
length:
{
maximum:
255
},
allow_blank:
true
validates
:namespace
,
presence:
true
validates_uniqueness_of
:name
,
scope: :namespace_id
...
...
lib/api/users.rb
View file @
a7ce8a83
...
...
@@ -96,7 +96,7 @@
admin
=
attrs
.
delete
(
:admin
)
user
.
admin
=
admin
unless
admin
.
nil?
if
user
.
update_attributes
(
attrs
,
as: :admin
)
if
user
.
update_attributes
(
attrs
)
present
user
,
with:
Entities
::
UserFull
else
not_found!
...
...
spec/requests/api/users_spec.rb
View file @
a7ce8a83
...
...
@@ -97,19 +97,6 @@
response
.
status
.
should
==
201
end
it
"creating a user should respect default project limit"
do
limit
=
123456
Gitlab
.
config
.
gitlab
.
stub
(
:default_projects_limit
).
and_return
(
limit
)
attr
=
attributes_for
(
:user
)
expect
{
post
api
(
"/users"
,
admin
),
attr
}.
to
change
{
User
.
count
}.
by
(
1
)
user
=
User
.
find_by
(
username:
attr
[
:username
])
user
.
projects_limit
.
should
==
limit
user
.
theme_id
.
should
==
Gitlab
::
Theme
::
MARS
Gitlab
.
config
.
gitlab
.
unstub
(
:default_projects_limit
)
end
it
"should not create user with invalid email"
do
post
api
(
"/users"
,
admin
),
{
email:
"invalid email"
,
password:
'password'
}
response
.
status
.
should
==
400
...
...
spec/services/notes/create_service_spec.rb
View file @
a7ce8a83
...
...
@@ -11,7 +11,6 @@
project
.
team
<<
[
user
,
:master
]
opts
=
{
note:
'Awesome comment'
,
description:
'please fix'
,
noteable_type:
'Issue'
,
noteable_id:
issue
.
id
}
...
...
spec/services/projects/create_service_spec.rb
View file @
a7ce8a83
...
...
@@ -55,95 +55,6 @@
it
{
File
.
exists?
(
@path
).
should
be_false
}
end
end
context
'respect configured visibility setting'
do
before
(
:each
)
do
@settings
=
double
(
"settings"
)
@settings
.
stub
(
:issues
)
{
true
}
@settings
.
stub
(
:merge_requests
)
{
true
}
@settings
.
stub
(
:wiki
)
{
true
}
@settings
.
stub
(
:snippets
)
{
true
}
Gitlab
.
config
.
gitlab
.
stub
(
restricted_visibility_levels:
[])
Gitlab
.
config
.
gitlab
.
stub
(
:default_projects_features
).
and_return
(
@settings
)
end
context
'should be public when setting is public'
do
before
do
@settings
.
stub
(
:visibility_level
)
{
Gitlab
::
VisibilityLevel
::
PUBLIC
}
@project
=
create_project
(
@user
,
@opts
)
end
it
{
@project
.
public?
.
should
be_true
}
end
context
'should be private when setting is private'
do
before
do
@settings
.
stub
(
:visibility_level
)
{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
@project
=
create_project
(
@user
,
@opts
)
end
it
{
@project
.
private?
.
should
be_true
}
end
context
'should be internal when setting is internal'
do
before
do
@settings
.
stub
(
:visibility_level
)
{
Gitlab
::
VisibilityLevel
::
INTERNAL
}
@project
=
create_project
(
@user
,
@opts
)
end
it
{
@project
.
internal?
.
should
be_true
}
end
end
context
'respect configured visibility restrictions setting'
do
before
(
:each
)
do
@settings
=
double
(
"settings"
)
@settings
.
stub
(
:issues
)
{
true
}
@settings
.
stub
(
:merge_requests
)
{
true
}
@settings
.
stub
(
:wiki
)
{
true
}
@settings
.
stub
(
:snippets
)
{
true
}
@settings
.
stub
(
:visibility_level
)
{
Gitlab
::
VisibilityLevel
::
PRIVATE
}
@restrictions
=
[
Gitlab
::
VisibilityLevel
::
PUBLIC
]
Gitlab
.
config
.
gitlab
.
stub
(
restricted_visibility_levels:
@restrictions
)
Gitlab
.
config
.
gitlab
.
stub
(
:default_projects_features
).
and_return
(
@settings
)
end
context
'should be private when option is public'
do
before
do
@opts
.
merge!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
@project
=
create_project
(
@user
,
@opts
)
end
it
{
@project
.
private?
.
should
be_true
}
end
context
'should be public when option is public for admin'
do
before
do
@opts
.
merge!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
@project
=
create_project
(
@admin
,
@opts
)
end
it
{
@project
.
public?
.
should
be_true
}
end
context
'should be private when option is private'
do
before
do
@opts
.
merge!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
@project
=
create_project
(
@user
,
@opts
)
end
it
{
@project
.
private?
.
should
be_true
}
end
context
'should be internal when option is internal'
do
before
do
@opts
.
merge!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
@project
=
create_project
(
@user
,
@opts
)
end
it
{
@project
.
internal?
.
should
be_true
}
end
end
end
def
create_project
(
user
,
opts
)
...
...
Write
Preview
Supports
Markdown
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