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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
837c3b3d
Commit
837c3b3d
authored
Jul 06, 2018
by
Francisco Javier López
Committed by
Douwe Maan
Jul 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix User role displayed on projects dashboard
parent
83f79ced
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
3 deletions
+62
-3
app/controllers/dashboard/projects_controller.rb
app/controllers/dashboard/projects_controller.rb
+3
-2
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+1
-0
app/helpers/users_helper.rb
app/helpers/users_helper.rb
+8
-0
app/views/shared/projects/_project.html.haml
app/views/shared/projects/_project.html.haml
+1
-1
changelogs/unreleased/fj-43565-wrong-role-displayed.yml
changelogs/unreleased/fj-43565-wrong-role-displayed.yml
+5
-0
spec/features/dashboard/projects_spec.rb
spec/features/dashboard/projects_spec.rb
+28
-0
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+5
-0
spec/spec_helper.rb
spec/spec_helper.rb
+11
-0
No files found.
app/controllers/dashboard/projects_controller.rb
View file @
837c3b3d
...
@@ -7,7 +7,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -7,7 +7,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
skip_cross_project_access_check
:index
,
:starred
skip_cross_project_access_check
:index
,
:starred
def
index
def
index
@projects
=
load_projects
(
params
.
merge
(
non_public:
true
))
.
page
(
params
[
:page
])
@projects
=
load_projects
(
params
.
merge
(
non_public:
true
))
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
@@ -25,7 +25,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -25,7 +25,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
def
starred
def
starred
@projects
=
load_projects
(
params
.
merge
(
starred:
true
))
@projects
=
load_projects
(
params
.
merge
(
starred:
true
))
.
includes
(
:forked_from_project
,
:tags
)
.
page
(
params
[
:page
])
.
includes
(
:forked_from_project
,
:tags
)
@groups
=
[]
@groups
=
[]
...
@@ -51,6 +51,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
...
@@ -51,6 +51,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
.
new
(
params:
finder_params
,
current_user:
current_user
)
.
new
(
params:
finder_params
,
current_user:
current_user
)
.
execute
.
execute
.
includes
(
:route
,
:creator
,
namespace:
[
:route
,
:owner
])
.
includes
(
:route
,
:creator
,
namespace:
[
:route
,
:owner
])
.
page
(
finder_params
[
:page
])
prepare_projects_for_rendering
(
projects
)
prepare_projects_for_rendering
(
projects
)
end
end
...
...
app/helpers/projects_helper.rb
View file @
837c3b3d
...
@@ -177,6 +177,7 @@ module ProjectsHelper
...
@@ -177,6 +177,7 @@ module ProjectsHelper
controller
.
action_name
,
controller
.
action_name
,
Gitlab
::
CurrentSettings
.
cache_key
,
Gitlab
::
CurrentSettings
.
cache_key
,
"cross-project:
#{
can?
(
current_user
,
:read_cross_project
)
}
"
,
"cross-project:
#{
can?
(
current_user
,
:read_cross_project
)
}
"
,
max_project_member_access_cache_key
(
project
),
'v2.6'
'v2.6'
]
]
...
...
app/helpers/users_helper.rb
View file @
837c3b3d
...
@@ -31,6 +31,14 @@ module UsersHelper
...
@@ -31,6 +31,14 @@ module UsersHelper
current_user_menu_items
.
include?
(
item
)
current_user_menu_items
.
include?
(
item
)
end
end
def
max_project_member_access
(
project
)
current_user
&
.
max_member_access_for_project
(
project
.
id
)
||
Gitlab
::
Access
::
NO_ACCESS
end
def
max_project_member_access_cache_key
(
project
)
"access:
#{
max_project_member_access
(
project
)
}
"
end
private
private
def
get_profile_tabs
def
get_profile_tabs
...
...
app/views/shared/projects/_project.html.haml
View file @
837c3b3d
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
-
ci
=
false
unless
local_assigns
[
:ci
]
==
true
-
ci
=
false
unless
local_assigns
[
:ci
]
==
true
-
skip_namespace
=
false
unless
local_assigns
[
:skip_namespace
]
==
true
-
skip_namespace
=
false
unless
local_assigns
[
:skip_namespace
]
==
true
-
user
=
local_assigns
[
:user
]
-
user
=
local_assigns
[
:user
]
-
access
=
user
&
.
max_member_access_for_project
(
project
.
id
)
unless
user
.
nil?
-
access
=
max_project_member_access
(
project
)
-
css_class
=
''
unless
local_assigns
[
:css_class
]
-
css_class
=
''
unless
local_assigns
[
:css_class
]
-
show_last_commit_as_description
=
false
unless
local_assigns
[
:show_last_commit_as_description
]
==
true
&&
can_show_last_commit_in_list?
(
project
)
-
show_last_commit_as_description
=
false
unless
local_assigns
[
:show_last_commit_as_description
]
==
true
&&
can_show_last_commit_in_list?
(
project
)
-
css_class
+=
" no-description"
if
project
.
description
.
blank?
&&
!
show_last_commit_as_description
-
css_class
+=
" no-description"
if
project
.
description
.
blank?
&&
!
show_last_commit_as_description
...
...
changelogs/unreleased/fj-43565-wrong-role-displayed.yml
0 → 100644
View file @
837c3b3d
---
title
:
Fix wrong role badge displayed in projects dashboard
merge_request
:
20374
author
:
type
:
fixed
spec/features/dashboard/projects_spec.rb
View file @
837c3b3d
...
@@ -29,6 +29,34 @@ describe 'Dashboard Projects' do
...
@@ -29,6 +29,34 @@ describe 'Dashboard Projects' do
end
end
end
end
context
'when user has access to the project'
do
it
'shows role badge'
do
visit
dashboard_projects_path
page
.
within
'.user-access-role'
do
expect
(
page
).
to
have_content
(
'Developer'
)
end
end
context
'when role changes'
,
:use_clean_rails_memory_store_fragment_caching
do
it
'displays the right role'
do
visit
dashboard_projects_path
page
.
within
'.user-access-role'
do
expect
(
page
).
to
have_content
(
'Developer'
)
end
project
.
members
.
last
.
update
(
access_level:
40
)
visit
dashboard_projects_path
page
.
within
'.user-access-role'
do
expect
(
page
).
to
have_content
(
'Maintainer'
)
end
end
end
end
context
'when last_repository_updated_at, last_activity_at and update_at are present'
do
context
'when last_repository_updated_at, last_activity_at and update_at are present'
do
it
'shows the last_repository_updated_at attribute as the update date'
do
it
'shows the last_repository_updated_at attribute as the update date'
do
project
.
update_attributes!
(
last_repository_updated_at:
Time
.
now
,
last_activity_at:
1
.
hour
.
ago
)
project
.
update_attributes!
(
last_repository_updated_at:
Time
.
now
,
last_activity_at:
1
.
hour
.
ago
)
...
...
spec/helpers/projects_helper_spec.rb
View file @
837c3b3d
...
@@ -80,6 +80,7 @@ describe ProjectsHelper do
...
@@ -80,6 +80,7 @@ describe ProjectsHelper do
before
do
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:read_cross_project
)
{
true
}
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:read_cross_project
)
{
true
}
allow
(
user
).
to
receive
(
:max_member_access_for_project
).
and_return
(
40
)
end
end
it
"includes the route"
do
it
"includes the route"
do
...
@@ -125,6 +126,10 @@ describe ProjectsHelper do
...
@@ -125,6 +126,10 @@ describe ProjectsHelper do
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
"pipeline-status/
#{
project
.
commit
.
sha
}
-success"
)
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
"pipeline-status/
#{
project
.
commit
.
sha
}
-success"
)
end
end
it
"includes the user max member access"
do
expect
(
helper
.
project_list_cache_key
(
project
)).
to
include
(
'access:40'
)
end
end
end
describe
'#load_pipeline_status'
do
describe
'#load_pipeline_status'
do
...
...
spec/spec_helper.rb
View file @
837c3b3d
...
@@ -170,6 +170,17 @@ RSpec.configure do |config|
...
@@ -170,6 +170,17 @@ RSpec.configure do |config|
redis_queues_cleanup!
redis_queues_cleanup!
end
end
config
.
around
(
:each
,
:use_clean_rails_memory_store_fragment_caching
)
do
|
example
|
caching_store
=
ActionController
::
Base
.
cache_store
ActionController
::
Base
.
cache_store
=
ActiveSupport
::
Cache
::
MemoryStore
.
new
ActionController
::
Base
.
perform_caching
=
true
example
.
run
ActionController
::
Base
.
perform_caching
=
false
ActionController
::
Base
.
cache_store
=
caching_store
end
# The :each scope runs "inside" the example, so this hook ensures the DB is in the
# The :each scope runs "inside" the example, so this hook ensures the DB is in the
# correct state before any examples' before hooks are called. This prevents a
# correct state before any examples' before hooks are called. This prevents a
# problem where `ScheduleIssuesClosedAtTypeChange` (or any migration that depends
# problem where `ScheduleIssuesClosedAtTypeChange` (or any migration that depends
...
...
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