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
1502d564
Commit
1502d564
authored
Jan 19, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert most User model specs to use `:empty_project`
parent
d9f53a35
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
45 deletions
+39
-45
spec/models/user_spec.rb
spec/models/user_spec.rb
+39
-45
No files found.
spec/models/user_spec.rb
View file @
1502d564
...
...
@@ -48,7 +48,7 @@ describe User, models: true do
describe
'#project_members'
do
it
'does not include project memberships for which user is a requester'
do
user
=
create
(
:user
)
project
=
create
(
:project
,
:public
,
:access_requestable
)
project
=
create
(
:
empty_
project
,
:public
,
:access_requestable
)
project
.
request_access
(
user
)
expect
(
user
.
project_members
).
to
be_empty
...
...
@@ -386,13 +386,15 @@ describe User, models: true do
describe
'projects'
do
before
do
@user
=
create
:user
@project
=
create
:project
,
namespace:
@user
.
namespace
@project_2
=
create
:project
,
group:
create
(
:group
)
# Grant MASTER access to the user
@project_3
=
create
:project
,
group:
create
(
:group
)
# Grant DEVELOPER access to the user
@user
=
create
(
:user
)
@project_2
.
team
<<
[
@user
,
:master
]
@project_3
.
team
<<
[
@user
,
:developer
]
@project
=
create
(
:empty_project
,
namespace:
@user
.
namespace
)
@project_2
=
create
(
:empty_project
,
group:
create
(
:group
))
do
|
project
|
project
.
add_master
(
@user
)
end
@project_3
=
create
(
:empty_project
,
group:
create
(
:group
))
do
|
project
|
project
.
add_developer
(
@user
)
end
end
it
{
expect
(
@user
.
authorized_projects
).
to
include
(
@project
)
}
...
...
@@ -435,7 +437,7 @@ describe User, models: true do
describe
'namespaced'
do
before
do
@user
=
create
:user
@project
=
create
:project
,
namespace:
@user
.
namespace
@project
=
create
(
:empty_project
,
namespace:
@user
.
namespace
)
end
it
{
expect
(
@user
.
several_namespaces?
).
to
be_falsey
}
...
...
@@ -517,7 +519,7 @@ describe User, models: true do
before
do
User
.
delete_all
@user
=
create
:user
@project
=
create
:project
@project
=
create
(
:empty_project
)
end
it
{
expect
(
User
.
not_in_project
(
@project
)).
to
include
(
@user
,
@project
.
owner
)
}
...
...
@@ -927,8 +929,8 @@ describe User, models: true do
describe
"#starred?"
do
it
"determines if user starred a project"
do
user
=
create
:user
project1
=
create
:project
,
:public
project2
=
create
:project
,
:public
project1
=
create
(
:empty_project
,
:public
)
project2
=
create
(
:empty_project
,
:public
)
expect
(
user
.
starred?
(
project1
)).
to
be_falsey
expect
(
user
.
starred?
(
project2
)).
to
be_falsey
...
...
@@ -954,7 +956,7 @@ describe User, models: true do
describe
"#toggle_star"
do
it
"toggles stars"
do
user
=
create
:user
project
=
create
:project
,
:public
project
=
create
(
:empty_project
,
:public
)
expect
(
user
.
starred?
(
project
)).
to
be_falsey
user
.
toggle_star
(
project
)
...
...
@@ -994,9 +996,9 @@ describe User, models: true do
describe
"#contributed_projects"
do
subject
{
create
(
:user
)
}
let!
(
:project1
)
{
create
(
:project
)
}
let!
(
:project2
)
{
create
(
:project
,
forked_from_project:
project3
)
}
let!
(
:project3
)
{
create
(
:project
)
}
let!
(
:project1
)
{
create
(
:
empty_
project
)
}
let!
(
:project2
)
{
create
(
:
empty_
project
,
forked_from_project:
project3
)
}
let!
(
:project3
)
{
create
(
:
empty_
project
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project2
,
target_project:
project3
,
author:
subject
)
}
let!
(
:push_event
)
{
create
(
:event
,
action:
Event
::
PUSHED
,
project:
project1
,
target:
project1
,
author:
subject
)
}
let!
(
:merge_event
)
{
create
(
:event
,
action:
Event
::
CREATED
,
project:
project3
,
target:
merge_request
,
author:
subject
)
}
...
...
@@ -1038,8 +1040,8 @@ describe User, models: true do
describe
"#recent_push"
do
subject
{
create
(
:user
)
}
let!
(
:project1
)
{
create
(
:project
)
}
let!
(
:project2
)
{
create
(
:project
,
forked_from_project:
project1
)
}
let!
(
:project1
)
{
create
(
:project
,
:repository
)
}
let!
(
:project2
)
{
create
(
:project
,
:repository
,
forked_from_project:
project1
)
}
let!
(
:push_data
)
do
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project2
,
subject
)
end
...
...
@@ -1113,7 +1115,7 @@ describe User, models: true do
it
"includes user's personal projects"
do
user
=
create
(
:user
)
project
=
create
(
:project
,
:private
,
namespace:
user
.
namespace
)
project
=
create
(
:
empty_
project
,
:private
,
namespace:
user
.
namespace
)
expect
(
user
.
authorized_projects
).
to
include
(
project
)
end
...
...
@@ -1121,7 +1123,7 @@ describe User, models: true do
it
"includes personal projects user has been given access to"
do
user1
=
create
(
:user
)
user2
=
create
(
:user
)
project
=
create
(
:project
,
:private
,
namespace:
user1
.
namespace
)
project
=
create
(
:
empty_
project
,
:private
,
namespace:
user1
.
namespace
)
project
.
team
<<
[
user2
,
Gitlab
::
Access
::
DEVELOPER
]
...
...
@@ -1130,7 +1132,7 @@ describe User, models: true do
it
"includes projects of groups user has been added to"
do
group
=
create
(
:group
)
project
=
create
(
:project
,
group:
group
)
project
=
create
(
:
empty_
project
,
group:
group
)
user
=
create
(
:user
)
group
.
add_developer
(
user
)
...
...
@@ -1140,7 +1142,7 @@ describe User, models: true do
it
"does not include projects of groups user has been removed from"
do
group
=
create
(
:group
)
project
=
create
(
:project
,
group:
group
)
project
=
create
(
:
empty_
project
,
group:
group
)
user
=
create
(
:user
)
member
=
group
.
add_developer
(
user
)
...
...
@@ -1152,7 +1154,7 @@ describe User, models: true do
it
"includes projects shared with user's group"
do
user
=
create
(
:user
)
project
=
create
(
:project
,
:private
)
project
=
create
(
:
empty_
project
,
:private
)
group
=
create
(
:group
)
group
.
add_reporter
(
user
)
...
...
@@ -1164,7 +1166,7 @@ describe User, models: true do
it
"does not include destroyed projects user had access to"
do
user1
=
create
(
:user
)
user2
=
create
(
:user
)
project
=
create
(
:project
,
:private
,
namespace:
user1
.
namespace
)
project
=
create
(
:
empty_
project
,
:private
,
namespace:
user1
.
namespace
)
project
.
team
<<
[
user2
,
Gitlab
::
Access
::
DEVELOPER
]
expect
(
user2
.
authorized_projects
).
to
include
(
project
)
...
...
@@ -1175,7 +1177,7 @@ describe User, models: true do
it
"does not include projects of destroyed groups user had access to"
do
group
=
create
(
:group
)
project
=
create
(
:project
,
namespace:
group
)
project
=
create
(
:
empty_
project
,
namespace:
group
)
user
=
create
(
:user
)
group
.
add_developer
(
user
)
...
...
@@ -1190,14 +1192,9 @@ describe User, models: true do
let
(
:user
)
{
create
(
:user
)
}
it
'includes projects for which the user access level is above or equal to reporter'
do
create
(
:project
)
reporter_project
=
create
(
:project
)
developer_project
=
create
(
:project
)
master_project
=
create
(
:project
)
reporter_project
.
team
<<
[
user
,
:reporter
]
developer_project
.
team
<<
[
user
,
:developer
]
master_project
.
team
<<
[
user
,
:master
]
reporter_project
=
create
(
:empty_project
)
{
|
p
|
p
.
add_reporter
(
user
)
}
developer_project
=
create
(
:empty_project
)
{
|
p
|
p
.
add_developer
(
user
)
}
master_project
=
create
(
:empty_project
)
{
|
p
|
p
.
add_master
(
user
)
}
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
eq
([
master_project
,
developer_project
,
reporter_project
])
expect
(
user
.
can?
(
:admin_issue
,
master_project
)).
to
eq
(
true
)
...
...
@@ -1206,10 +1203,8 @@ describe User, models: true do
end
it
'does not include for which the user access level is below reporter'
do
project
=
create
(
:project
)
guest_project
=
create
(
:project
)
guest_project
.
team
<<
[
user
,
:guest
]
project
=
create
(
:empty_project
)
guest_project
=
create
(
:empty_project
)
{
|
p
|
p
.
add_guest
(
user
)
}
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
be_empty
expect
(
user
.
can?
(
:admin_issue
,
guest_project
)).
to
eq
(
false
)
...
...
@@ -1217,15 +1212,14 @@ describe User, models: true do
end
it
'does not include archived projects'
do
project
=
create
(
:project
)
project
.
update_attributes
(
archived:
true
)
project
=
create
(
:empty_project
,
:archived
)
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
be_empty
expect
(
user
.
can?
(
:admin_issue
,
project
)).
to
eq
(
false
)
end
it
'does not include projects for which issues are disabled'
do
project
=
create
(
:project
,
issues_access_level:
ProjectFeature
::
DISABLED
)
project
=
create
(
:
empty_
project
,
issues_access_level:
ProjectFeature
::
DISABLED
)
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
be_empty
expect
(
user
.
can?
(
:admin_issue
,
project
)).
to
eq
(
false
)
...
...
@@ -1241,7 +1235,7 @@ describe User, models: true do
end
context
'without any projects'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:
empty_
project
)
}
it
'does not load'
do
expect
(
user
.
ci_authorized_runners
).
to
be_empty
...
...
@@ -1250,7 +1244,7 @@ describe User, models: true do
context
'with personal projects runners'
do
let
(
:namespace
)
{
create
(
:namespace
,
owner:
user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
let
(
:project
)
{
create
(
:
empty_
project
,
namespace:
namespace
)
}
it
'loads'
do
expect
(
user
.
ci_authorized_runners
).
to
contain_exactly
(
runner
)
...
...
@@ -1281,7 +1275,7 @@ describe User, models: true do
context
'with groups projects runners'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:project
)
{
create
(
:
empty_
project
,
group:
group
)
}
def
add_user
(
access
)
group
.
add_user
(
user
,
access
)
...
...
@@ -1291,7 +1285,7 @@ describe User, models: true do
end
context
'with other projects runners'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:
empty_
project
)
}
def
add_user
(
access
)
project
.
team
<<
[
user
,
access
]
...
...
@@ -1321,8 +1315,8 @@ describe User, models: true do
end
describe
'#projects_with_reporter_access_limited_to'
do
let
(
:project1
)
{
create
(
:project
)
}
let
(
:project2
)
{
create
(
:project
)
}
let
(
:project1
)
{
create
(
:
empty_
project
)
}
let
(
:project2
)
{
create
(
:
empty_
project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
...
...
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