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
3a696abf
Commit
3a696abf
authored
May 05, 2021
by
Jackie Fraser
Committed by
Stan Hu
May 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor activity_path into separate model methods
parent
06c9f530
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
15 deletions
+59
-15
app/controllers/invites_controller.rb
app/controllers/invites_controller.rb
+2
-2
app/controllers/registrations/welcome_controller.rb
app/controllers/registrations/welcome_controller.rb
+9
-13
app/models/group.rb
app/models/group.rb
+4
-0
app/models/project.rb
app/models/project.rb
+4
-0
spec/controllers/registrations/welcome_controller_spec.rb
spec/controllers/registrations/welcome_controller_spec.rb
+24
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+8
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+8
-0
No files found.
app/controllers/invites_controller.rb
View file @
3a696abf
...
...
@@ -125,14 +125,14 @@ class InvitesController < ApplicationController
name:
member
.
source
.
full_name
,
url:
project_url
(
member
.
source
),
title:
_
(
"project"
),
path:
activity_project_path
(
member
.
source
)
path:
member
.
source
.
activity_path
}
when
Group
{
name:
member
.
source
.
name
,
url:
group_url
(
member
.
source
),
title:
_
(
"group"
),
path:
activity_group_path
(
member
.
source
)
path:
member
.
source
.
activity_path
}
end
end
...
...
app/controllers/registrations/welcome_controller.rb
View file @
3a696abf
...
...
@@ -18,8 +18,10 @@ module Registrations
if
result
[
:status
]
==
:success
return
redirect_to
new_users_sign_up_group_path
if
show_signup_onboarding?
if
current_user
.
members
.
count
==
1
redirect_to
path_for_signed_in_user
(
current_user
),
notice:
helpers
.
invite_accepted_notice
(
current_user
.
members
.
last
)
members
=
current_user
.
members
if
members
.
count
==
1
&&
members
.
last
.
source
.
present?
redirect_to
members_activity_path
(
members
),
notice:
helpers
.
invite_accepted_notice
(
members
.
last
)
else
redirect_to
path_for_signed_in_user
(
current_user
)
end
...
...
@@ -52,20 +54,14 @@ module Registrations
def
path_for_signed_in_user
(
user
)
return
users_almost_there_path
if
requires_confirmation?
(
user
)
stored_location_for
(
user
)
||
members_activity_path
(
user
)
stored_location_for
(
user
)
||
members_activity_path
(
user
.
members
)
end
def
members_activity_path
(
user
)
return
dashboard_projects_path
unless
user
.
members
.
count
>=
1
def
members_activity_path
(
members
)
return
dashboard_projects_path
unless
members
.
any?
return
dashboard_projects_path
unless
members
.
last
.
source
.
present?
case
user
.
members
.
last
.
source
when
Project
activity_project_path
(
user
.
members
.
last
.
source
)
when
Group
activity_group_path
(
user
.
members
.
last
.
source
)
else
dashboard_projects_path
end
members
.
last
.
source
.
activity_path
end
def
show_signup_onboarding?
...
...
app/models/group.rb
View file @
3a696abf
...
...
@@ -708,6 +708,10 @@ class Group < Namespace
model_name
.
singular
end
def
activity_path
Gitlab
::
Routing
.
url_helpers
.
activity_group_path
(
self
)
end
private
def
update_two_factor_requirement
...
...
app/models/project.rb
View file @
3a696abf
...
...
@@ -2570,6 +2570,10 @@ class Project < ApplicationRecord
Feature
.
enabled?
(
:inherited_issuable_templates
,
self
,
default_enabled: :yaml
)
end
def
activity_path
Gitlab
::
Routing
.
url_helpers
.
activity_project_path
(
self
)
end
private
def
set_container_registry_access_level
...
...
spec/controllers/registrations/welcome_controller_spec.rb
View file @
3a696abf
...
...
@@ -77,6 +77,30 @@ RSpec.describe Registrations::WelcomeController do
it
{
is_expected
.
to
redirect_to
(
dashboard_projects_path
)}
context
'when the new user already has any accepted group membership'
do
let!
(
:member1
)
{
create
(
:group_member
,
user:
user
)
}
it
'redirects to the group activity page'
do
expect
(
subject
).
to
redirect_to
(
activity_group_path
(
member1
.
source
))
end
context
'when the new user already has more than 1 accepted group membership'
do
it
'redirects to the most recent membership group activty page'
do
member2
=
create
(
:group_member
,
user:
user
)
expect
(
subject
).
to
redirect_to
(
activity_group_path
(
member2
.
source
))
end
end
context
'when the member has an orphaned source at the time of the welcome'
do
it
'redirects to the project dashboard page'
do
member1
.
source
.
delete
expect
(
subject
).
to
redirect_to
(
dashboard_projects_path
)
end
end
end
context
'when the user opted in'
do
let
(
:email_opted_in
)
{
'1'
}
...
...
spec/models/group_spec.rb
View file @
3a696abf
...
...
@@ -2398,4 +2398,12 @@ RSpec.describe Group do
expect
(
group
.
to_ability_name
).
to
eq
(
'group'
)
end
end
describe
'#activity_path'
do
it
'returns the group activity_path'
do
expected_path
=
"/groups/
#{
group
.
name
}
/-/activity"
expect
(
group
.
activity_path
).
to
eq
(
expected_path
)
end
end
end
spec/models/project_spec.rb
View file @
3a696abf
...
...
@@ -6890,6 +6890,14 @@ RSpec.describe Project, factory_default: :keep do
end
end
end
describe
'#activity_path'
do
it
'returns the project activity_path'
do
expected_path
=
"/
#{
project
.
namespace
.
path
}
/
#{
project
.
name
}
/activity"
expect
(
project
.
activity_path
).
to
eq
(
expected_path
)
end
end
end
describe
'#default_branch_or_main'
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