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
7c51d5ef
Commit
7c51d5ef
authored
Mar 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some specs
parent
3058a8fa
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
20 additions
and
61 deletions
+20
-61
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+0
-1
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+2
-8
app/views/events/event/_common.html.haml
app/views/events/event/_common.html.haml
+1
-1
db/migrate/20160320204112_index_namespaces_on_visibility_level.rb
...te/20160320204112_index_namespaces_on_visibility_level.rb
+5
-0
db/schema.rb
db/schema.rb
+1
-0
features/steps/shared/group.rb
features/steps/shared/group.rb
+2
-2
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+0
-40
spec/lib/banzai/filter/redactor_filter_spec.rb
spec/lib/banzai/filter/redactor_filter_spec.rb
+2
-2
spec/models/project_security_spec.rb
spec/models/project_security_spec.rb
+5
-5
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+1
-1
No files found.
app/controllers/admin/projects_controller.rb
View file @
7c51d5ef
class
Admin::ProjectsController
<
Admin
::
ApplicationController
class
Admin::ProjectsController
<
Admin
::
ApplicationController
before_action
:project
,
only:
[
:show
,
:transfer
]
before_action
:project
,
only:
[
:show
,
:transfer
]
before_action
:group
,
only:
[
:show
,
:transfer
]
before_action
:group
,
only:
[
:show
,
:transfer
]
before_action
:repository
,
only:
[
:show
,
:transfer
]
def
index
def
index
@projects
=
Project
.
all
@projects
=
Project
.
all
...
...
app/controllers/projects/application_controller.rb
View file @
7c51d5ef
...
@@ -67,7 +67,7 @@ class Projects::ApplicationController < ApplicationController
...
@@ -67,7 +67,7 @@ class Projects::ApplicationController < ApplicationController
end
end
def
require_non_empty_project
def
require_non_empty_project
redirect_to
@project
if
@project
.
empty_repo?
redirect_to
namespace_project_path
(
@project
.
namespace
,
@project
)
if
@project
.
empty_repo?
end
end
def
require_branch_head
def
require_branch_head
...
...
app/models/project.rb
View file @
7c51d5ef
...
@@ -246,10 +246,6 @@ class Project < ActiveRecord::Base
...
@@ -246,10 +246,6 @@ class Project < ActiveRecord::Base
end
end
class
<<
self
class
<<
self
def
public_and_internal_levels
[
Project
::
PUBLIC
,
Project
::
INTERNAL
]
end
def
abandoned
def
abandoned
where
(
'projects.last_activity_at < ?'
,
6
.
months
.
ago
)
where
(
'projects.last_activity_at < ?'
,
6
.
months
.
ago
)
end
end
...
@@ -976,11 +972,9 @@ class Project < ActiveRecord::Base
...
@@ -976,11 +972,9 @@ class Project < ActiveRecord::Base
end
end
def
visibility_level_allowed_as_fork?
(
level
=
self
.
visibility_level
)
def
visibility_level_allowed_as_fork?
(
level
=
self
.
visibility_level
)
return
true
unless
forked?
&&
forked_project_link
.
forked_from_project_id
.
present?
return
true
unless
forked?
from_project
=
self
.
forked_from_project
Gitlab
::
VisibilityLevel
.
allowed_fork_levels
(
forked_from_project
.
visibility_level
).
include?
(
level
)
from_project
||=
Project
.
find
(
forked_project_link
.
forked_from_project_id
)
Gitlab
::
VisibilityLevel
.
allowed_fork_levels
(
from_project
.
visibility_level
).
include?
(
level
)
end
end
def
visibility_level_allowed_by_group?
(
level
=
self
.
visibility_level
)
def
visibility_level_allowed_by_group?
(
level
=
self
.
visibility_level
)
...
...
app/views/events/event/_common.html.haml
View file @
7c51d5ef
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
=
event_action_name
(
event
)
=
event_action_name
(
event
)
-
if
event
.
target
-
if
event
.
target
%strong
=
link_to
event
.
target
.
to_reference
,
[
event
.
project
.
namespace
.
becomes
(
Namespace
),
event
.
project
,
event
.
target
]
%strong
=
link_to
event
.
target
.
reference_link_text
,
[
event
.
project
.
namespace
.
becomes
(
Namespace
),
event
.
project
,
event
.
target
]
=
event_preposition
(
event
)
=
event_preposition
(
event
)
...
...
db/migrate/20160320204112_index_namespaces_on_visibility_level.rb
0 → 100644
View file @
7c51d5ef
class
IndexNamespacesOnVisibilityLevel
<
ActiveRecord
::
Migration
def
change
add_index
:namespaces
,
:visibility_level
end
end
db/schema.rb
View file @
7c51d5ef
...
@@ -601,6 +601,7 @@ ActiveRecord::Schema.define(version: 20160316204731) do
...
@@ -601,6 +601,7 @@ ActiveRecord::Schema.define(version: 20160316204731) do
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path"
,
unique:
true
,
using: :btree
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path"
,
unique:
true
,
using: :btree
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path_trigram"
,
using: :gin
,
opclasses:
{
"path"
=>
"gin_trgm_ops"
}
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path_trigram"
,
using: :gin
,
opclasses:
{
"path"
=>
"gin_trgm_ops"
}
add_index
"namespaces"
,
[
"type"
],
name:
"index_namespaces_on_type"
,
using: :btree
add_index
"namespaces"
,
[
"type"
],
name:
"index_namespaces_on_type"
,
using: :btree
add_index
"namespaces"
,
[
"visibility_level"
],
name:
"index_namespaces_on_visibility_level"
,
using: :btree
create_table
"notes"
,
force: :cascade
do
|
t
|
create_table
"notes"
,
force: :cascade
do
|
t
|
t
.
text
"note"
t
.
text
"note"
...
...
features/steps/shared/group.rb
View file @
7c51d5ef
...
@@ -38,7 +38,7 @@ module SharedGroup
...
@@ -38,7 +38,7 @@ module SharedGroup
def
is_member_of
(
username
,
groupname
,
role
)
def
is_member_of
(
username
,
groupname
,
role
)
@project_count
||=
0
@project_count
||=
0
user
=
User
.
find_by
(
name:
username
)
||
create
(
:user
,
name:
username
)
user
=
User
.
find_by
(
name:
username
)
||
create
(
:user
,
name:
username
)
group
=
Group
.
find_by
(
name:
groupname
)
||
create
(
:group
,
name:
groupname
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
group
=
Group
.
find_by
(
name:
groupname
)
||
create
(
:group
,
name:
groupname
)
group
.
add_user
(
user
,
role
)
group
.
add_user
(
user
,
role
)
project
||=
create
(
:project
,
namespace:
group
,
path:
"project
#{
@project_count
}
"
)
project
||=
create
(
:project
,
namespace:
group
,
path:
"project
#{
@project_count
}
"
)
create
(
:closed_issue_event
,
project:
project
)
create
(
:closed_issue_event
,
project:
project
)
...
@@ -47,6 +47,6 @@ module SharedGroup
...
@@ -47,6 +47,6 @@ module SharedGroup
end
end
def
owned_group
def
owned_group
@owned_group
||=
Group
.
find_by
(
name:
"Owned"
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
@owned_group
||=
Group
.
find_by
(
name:
"Owned"
)
end
end
end
end
spec/controllers/application_controller_spec.rb
View file @
7c51d5ef
...
@@ -30,44 +30,4 @@ describe ApplicationController do
...
@@ -30,44 +30,4 @@ describe ApplicationController do
controller
.
send
(
:check_password_expiration
)
controller
.
send
(
:check_password_expiration
)
end
end
end
end
describe
'check labels authorization'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:controller
)
{
ApplicationController
.
new
}
before
do
project
.
team
<<
[
user
,
:guest
]
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
controller
).
to
receive
(
:project
).
and_return
(
project
)
end
it
'should succeed if issues and MRs are enabled'
do
project
.
issues_enabled
=
true
project
.
merge_requests_enabled
=
true
controller
.
send
(
:authorize_read_label!
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should succeed if issues are enabled, MRs are disabled'
do
project
.
issues_enabled
=
true
project
.
merge_requests_enabled
=
false
controller
.
send
(
:authorize_read_label!
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should succeed if issues are disabled, MRs are enabled'
do
project
.
issues_enabled
=
false
project
.
merge_requests_enabled
=
true
controller
.
send
(
:authorize_read_label!
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should fail if issues and MRs are disabled'
do
project
.
issues_enabled
=
false
project
.
merge_requests_enabled
=
false
expect
(
controller
).
to
receive
(
:access_denied!
)
controller
.
send
(
:authorize_read_label!
)
end
end
end
end
spec/lib/banzai/filter/redactor_filter_spec.rb
View file @
7c51d5ef
...
@@ -119,7 +119,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
...
@@ -119,7 +119,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
context
'with data-group'
do
context
'with data-group'
do
it
'removes unpermitted Group references'
do
it
'removes unpermitted Group references'
do
user
=
create
(
:user
)
user
=
create
(
:user
)
group
=
create
(
:group
)
group
=
create
(
:group
,
:private
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
user
)
doc
=
filter
(
link
,
current_user:
user
)
...
@@ -129,7 +129,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
...
@@ -129,7 +129,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
it
'allows permitted Group references'
do
it
'allows permitted Group references'
do
user
=
create
(
:user
)
user
=
create
(
:user
)
group
=
create
(
:group
)
group
=
create
(
:group
,
:private
)
group
.
add_developer
(
user
)
group
.
add_developer
(
user
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
...
...
spec/models/project_security_spec.rb
View file @
7c51d5ef
...
@@ -18,11 +18,11 @@ describe Project, models: true do
...
@@ -18,11 +18,11 @@ describe Project, models: true do
let
(
:report_actions
)
{
Ability
.
project_report_rules
}
let
(
:report_actions
)
{
Ability
.
project_report_rules
}
let
(
:dev_actions
)
{
Ability
.
project_dev_rules
}
let
(
:dev_actions
)
{
Ability
.
project_dev_rules
}
let
(
:master_actions
)
{
Ability
.
project_master_rules
}
let
(
:master_actions
)
{
Ability
.
project_master_rules
}
let
(
:
admin_actions
)
{
Ability
.
project_admin
_rules
}
let
(
:
owner_actions
)
{
Ability
.
project_owner
_rules
}
describe
"Non member rules"
do
describe
"Non member rules"
do
it
"should deny for non-project users any actions"
do
it
"should deny for non-project users any actions"
do
admin
_actions
.
each
do
|
action
|
owner
_actions
.
each
do
|
action
|
expect
(
@abilities
.
allowed?
(
@u1
,
action
,
@p1
)).
to
be_falsey
expect
(
@abilities
.
allowed?
(
@u1
,
action
,
@p1
)).
to
be_falsey
end
end
end
end
...
@@ -90,20 +90,20 @@ describe Project, models: true do
...
@@ -90,20 +90,20 @@ describe Project, models: true do
end
end
end
end
describe
"
Admin
Rules"
do
describe
"
Owner
Rules"
do
before
do
before
do
@p1
.
project_members
.
create
(
project:
@p1
,
user:
@u2
,
access_level:
ProjectMember
::
DEVELOPER
)
@p1
.
project_members
.
create
(
project:
@p1
,
user:
@u2
,
access_level:
ProjectMember
::
DEVELOPER
)
@p1
.
project_members
.
create
(
project:
@p1
,
user:
@u3
,
access_level:
ProjectMember
::
MASTER
)
@p1
.
project_members
.
create
(
project:
@p1
,
user:
@u3
,
access_level:
ProjectMember
::
MASTER
)
end
end
it
"should deny for masters admin-specific actions"
do
it
"should deny for masters admin-specific actions"
do
[
admin
_actions
-
master_actions
].
each
do
|
action
|
[
owner
_actions
-
master_actions
].
each
do
|
action
|
expect
(
@abilities
.
allowed?
(
@u2
,
action
,
@p1
)).
to
be_falsey
expect
(
@abilities
.
allowed?
(
@u2
,
action
,
@p1
)).
to
be_falsey
end
end
end
end
it
"should allow for project owner any admin actions"
do
it
"should allow for project owner any admin actions"
do
admin
_actions
.
each
do
|
action
|
owner
_actions
.
each
do
|
action
|
expect
(
@abilities
.
allowed?
(
@u4
,
action
,
@p1
)).
to
be_truthy
expect
(
@abilities
.
allowed?
(
@u4
,
action
,
@p1
)).
to
be_truthy
end
end
end
end
...
...
spec/requests/api/groups_spec.rb
View file @
7c51d5ef
...
@@ -9,7 +9,7 @@ describe API::API, api: true do
...
@@ -9,7 +9,7 @@ describe API::API, api: true do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:avatar_file_path
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
}
let
(
:avatar_file_path
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
}
let!
(
:group1
)
{
create
(
:group
,
avatar:
File
.
open
(
avatar_file_path
))
}
let!
(
:group1
)
{
create
(
:group
,
avatar:
File
.
open
(
avatar_file_path
))
}
let!
(
:group2
)
{
create
(
:group
)
}
let!
(
:group2
)
{
create
(
:group
,
:private
)
}
let!
(
:project1
)
{
create
(
:project
,
namespace:
group1
)
}
let!
(
:project1
)
{
create
(
:project
,
namespace:
group1
)
}
let!
(
:project2
)
{
create
(
:project
,
namespace:
group2
)
}
let!
(
:project2
)
{
create
(
:project
,
namespace:
group2
)
}
...
...
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