BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
68f1535a
Commit
68f1535a
authored
Mar 09, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rs-traits-are-good' into 'master'
Make better use of the `visibility_level` factory traits See merge request !3131
parents
bc14d81a
b900304c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
36 deletions
+32
-36
forks_controller_spec.rb
spec/controllers/projects/forks_controller_spec.rb
+1
-1
personal_snippets.rb
spec/factories/personal_snippets.rb
+0
-11
project_snippets.rb
spec/factories/project_snippets.rb
+1
-5
snippets.rb
spec/factories/snippets.rb
+12
-0
snippets_finder_spec.rb
spec/finders/snippets_finder_spec.rb
+12
-13
visibility_level_helper_spec.rb
spec/helpers/visibility_level_helper_spec.rb
+3
-3
project_spec.rb
spec/models/project_spec.rb
+1
-1
update_service_spec.rb
spec/services/projects/update_service_spec.rb
+2
-2
No files found.
spec/controllers/projects/forks_controller_spec.rb
View file @
68f1535a
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Projects
::
ForksController
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
visibility_level:
Project
::
PUBLIC
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:forked_project
)
{
Projects
::
ForkService
.
new
(
project
,
user
).
execute
}
let
(
:group
)
{
create
(
:group
,
owner:
forked_project
.
creator
)
}
...
...
spec/factories/personal_snippets.rb
View file @
68f1535a
FactoryGirl
.
define
do
factory
:personal_snippet
,
parent: :snippet
,
class: :PersonalSnippet
do
trait
:public
do
visibility_level
PersonalSnippet
::
PUBLIC
end
trait
:internal
do
visibility_level
PersonalSnippet
::
INTERNAL
end
trait
:private
do
visibility_level
PersonalSnippet
::
PRIVATE
end
end
end
spec/factories/project_snippets.rb
View file @
68f1535a
FactoryGirl
.
define
do
factory
:project_snippet
do
factory
:project_snippet
,
parent: :snippet
,
class: :ProjectSnippet
do
project
author
title
content
file_name
end
end
spec/factories/snippets.rb
View file @
68f1535a
...
...
@@ -12,5 +12,17 @@ FactoryGirl.define do
title
content
file_name
trait
:public
do
visibility_level
Snippet
::
PUBLIC
end
trait
:internal
do
visibility_level
Snippet
::
INTERNAL
end
trait
:private
do
visibility_level
Snippet
::
PRIVATE
end
end
end
spec/finders/snippets_finder_spec.rb
View file @
68f1535a
...
...
@@ -5,15 +5,14 @@ describe SnippetsFinder do
let
(
:user1
)
{
create
:user
}
let
(
:group
)
{
create
:group
}
let
(
:project1
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
let
(
:project2
)
{
create
(
:empty_project
,
:private
,
group:
group
)
}
let
(
:project1
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
let
(
:project2
)
{
create
(
:empty_project
,
:private
,
group:
group
)
}
context
':all filter'
do
before
do
@snippet1
=
create
(
:personal_snippet
,
visibility_level:
Snippet
::
PRIVATE
)
@snippet2
=
create
(
:personal_snippet
,
visibility_level:
Snippet
::
INTERNAL
)
@snippet3
=
create
(
:personal_snippet
,
visibility_level:
Snippet
::
PUBLIC
)
@snippet1
=
create
(
:personal_snippet
,
:private
)
@snippet2
=
create
(
:personal_snippet
,
:internal
)
@snippet3
=
create
(
:personal_snippet
,
:public
)
end
it
"returns all private and internal snippets"
do
...
...
@@ -31,9 +30,9 @@ describe SnippetsFinder do
context
':by_user filter'
do
before
do
@snippet1
=
create
(
:personal_snippet
,
visibility_level:
Snippet
::
PRIVATE
,
author:
user
)
@snippet2
=
create
(
:personal_snippet
,
visibility_level:
Snippet
::
INTERNAL
,
author:
user
)
@snippet3
=
create
(
:personal_snippet
,
visibility_level:
Snippet
::
PUBLIC
,
author:
user
)
@snippet1
=
create
(
:personal_snippet
,
:private
,
author:
user
)
@snippet2
=
create
(
:personal_snippet
,
:internal
,
author:
user
)
@snippet3
=
create
(
:personal_snippet
,
:public
,
author:
user
)
end
it
"returns all public and internal snippets"
do
...
...
@@ -75,9 +74,9 @@ describe SnippetsFinder do
context
'by_project filter'
do
before
do
@snippet1
=
create
(
:project_snippet
,
visibility_level:
Snippet
::
PRIVATE
,
project:
project1
)
@snippet2
=
create
(
:project_snippet
,
visibility_level:
Snippet
::
INTERNAL
,
project:
project1
)
@snippet3
=
create
(
:project_snippet
,
visibility_level:
Snippet
::
PUBLIC
,
project:
project1
)
@snippet1
=
create
(
:project_snippet
,
:private
,
project:
project1
)
@snippet2
=
create
(
:project_snippet
,
:internal
,
project:
project1
)
@snippet3
=
create
(
:project_snippet
,
:public
,
project:
project1
)
end
it
"returns public snippets for unauthorized user"
do
...
...
@@ -93,7 +92,7 @@ describe SnippetsFinder do
end
it
"returns all snippets for project members"
do
project1
.
team
<<
[
user
,
:developer
]
project1
.
team
<<
[
user
,
:developer
]
snippets
=
SnippetsFinder
.
new
.
execute
(
user
,
filter: :by_project
,
project:
project1
)
expect
(
snippets
).
to
include
(
@snippet1
,
@snippet2
,
@snippet3
)
end
...
...
spec/helpers/visibility_level_helper_spec.rb
View file @
68f1535a
...
...
@@ -58,7 +58,7 @@ describe VisibilityLevelHelper do
describe
"skip_level?"
do
describe
"forks"
do
let
(
:project
)
{
create
(
:project
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
}
let
(
:project
)
{
create
(
:project
,
:internal
)
}
let
(
:fork_project
)
{
create
(
:forked_project_with_submodules
)
}
before
do
...
...
@@ -74,7 +74,7 @@ describe VisibilityLevelHelper do
end
describe
"non-forked project"
do
let
(
:project
)
{
create
(
:project
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
}
let
(
:project
)
{
create
(
:project
,
:internal
)
}
it
"skips levels"
do
expect
(
skip_level?
(
project
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)).
to
be_falsey
...
...
@@ -84,7 +84,7 @@ describe VisibilityLevelHelper do
end
describe
"Snippet"
do
let
(
:snippet
)
{
create
(
:snippet
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
)
}
let
(
:snippet
)
{
create
(
:snippet
,
:internal
)
}
it
"skips levels"
do
expect
(
skip_level?
(
snippet
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)).
to
be_falsey
...
...
spec/models/project_spec.rb
View file @
68f1535a
...
...
@@ -561,7 +561,7 @@ describe Project, models: true do
end
describe
'#visibility_level_allowed?'
do
let
(
:project
)
{
create
:project
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
}
let
(
:project
)
{
create
(
:project
,
:internal
)
}
context
'when checking on non-forked project'
do
it
{
expect
(
project
.
visibility_level_allowed?
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)).
to
be_truthy
}
...
...
spec/services/projects/update_service_spec.rb
View file @
68f1535a
...
...
@@ -102,8 +102,8 @@ describe Projects::UpdateService, services: true do
describe
:visibility_level
do
let
(
:user
)
{
create
:user
,
admin:
true
}
let
(
:project
)
{
create
:project
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
}
let
(
:forked_project
)
{
create
:forked_project_with_submodules
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
}
let
(
:project
)
{
create
(
:project
,
:internal
)
}
let
(
:forked_project
)
{
create
(
:forked_project_with_submodules
,
:internal
)
}
let
(
:opts
)
{
{}
}
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