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
abd0d42c
Commit
abd0d42c
authored
Apr 12, 2022
by
Martin Tan
Committed by
Alex Pooley
Apr 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: add prepend mod to trail registrations controller
parent
9f4f8a74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletion
+45
-1
ee/app/controllers/trial_registrations_controller.rb
ee/app/controllers/trial_registrations_controller.rb
+7
-1
ee/spec/requests/trial_registrations_controller_spec.rb
ee/spec/requests/trial_registrations_controller_spec.rb
+38
-0
No files found.
ee/app/controllers/trial_registrations_controller.rb
View file @
abd0d42c
...
...
@@ -42,13 +42,19 @@ class TrialRegistrationsController < RegistrationsController
def
sign_up_params
if
params
[
:user
]
params
.
require
(
:user
).
permit
(
:first_name
,
:last_name
,
:username
,
:email
,
:password
,
:skip_confirmation
,
:email_opted_in
)
params
.
require
(
:user
).
permit
(
*
sign_up_params_attributes
)
else
{}
end
end
def
sign_up_params_attributes
[
:first_name
,
:last_name
,
:username
,
:email
,
:password
,
:skip_confirmation
,
:email_opted_in
]
end
def
resource
@resource
||=
Users
::
AuthorizedBuildService
.
new
(
current_user
,
sign_up_params
).
execute
end
end
TrialRegistrationsController
.
prepend_mod
ee/spec/requests/trial_registrations_controller_spec.rb
0 → 100644
View file @
abd0d42c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
TrialRegistrationsController
do
let
(
:com
)
{
true
}
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
com
)
end
describe
'POST new'
do
let
(
:user_params
)
do
build_stubbed
(
:user
)
.
slice
(
:first_name
,
:last_name
,
:email
,
:username
,
:password
)
end
context
'when email_opted_in does not exist in params'
do
it
'sets user email_opted_in to false'
do
post
trial_registrations_path
,
params:
{
user:
user_params
}
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
expect
(
User
.
last
.
email_opted_in
).
to
be_nil
end
end
context
'when email_opted_in is true in params'
do
it
'sets user email_opted_in to true'
do
post
trial_registrations_path
,
params:
{
user:
user_params
.
merge
(
email_opted_in:
true
)
}
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
expect
(
User
.
last
.
email_opted_in
).
to
be
true
end
end
end
end
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