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
a6ac52d3
Commit
a6ac52d3
authored
Apr 05, 2022
by
minahilnichols
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add create logic to company controller instead of trials
parent
5f0b3edf
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
35 deletions
+59
-35
config/routes.rb
config/routes.rb
+1
-1
ee/app/assets/javascripts/registrations/components/company_form.vue
...ets/javascripts/registrations/components/company_form.vue
+1
-1
ee/app/controllers/registrations/company_controller.rb
ee/app/controllers/registrations/company_controller.rb
+33
-0
ee/app/controllers/trials_controller.rb
ee/app/controllers/trials_controller.rb
+2
-7
ee/app/helpers/ee/trial_helper.rb
ee/app/helpers/ee/trial_helper.rb
+1
-1
ee/spec/controllers/trials_controller_spec.rb
ee/spec/controllers/trials_controller_spec.rb
+0
-18
ee/spec/features/trial_registrations/company_information_spec.rb
.../features/trial_registrations/company_information_spec.rb
+21
-7
No files found.
config/routes.rb
View file @
a6ac52d3
...
...
@@ -66,7 +66,7 @@ Rails.application.routes.draw do
end
Gitlab
.
ee
do
resource
s
:company
,
only:
[
:new
]
resource
:company
,
only:
[
:new
,
:create
],
controller:
'company'
resources
:groups
,
only:
[
:new
,
:create
]
resources
:projects
,
only:
[
:new
,
:create
]
resources
:groups_projects
,
only:
[
:new
,
:create
]
do
...
...
ee/app/assets/javascripts/registrations/components/company_form.vue
View file @
a6ac52d3
...
...
@@ -33,7 +33,7 @@ export default {
trial
:
{
type
:
Boolean
,
required
:
false
,
default
:
tru
e
,
default
:
fals
e
,
},
},
data
()
{
...
...
ee/app/controllers/registrations/company_controller.rb
View file @
a6ac52d3
...
...
@@ -5,9 +5,42 @@ module Registrations
layout
'minimal'
before_action
:check_if_gl_com_or_dev
before_action
:authenticate_user!
feature_category
:onboarding
def
new
end
def
create
if
Gitlab
::
Utils
.
to_boolean
(
params
[
:trial
])
result
=
GitlabSubscriptions
::
CreateLeadService
.
new
.
execute
({
trial_user:
company_params
})
redirect_to
(
new_users_sign_up_groups_project_path
(
trial_onboarding_flow:
true
))
&&
return
if
result
[
:success
]
else
result
=
GitlabSubscriptions
::
CreateHandRaiseLeadService
.
new
.
execute
(
company_params
)
redirect_to
(
new_users_sign_up_groups_project_path
(
skip_trial:
true
))
&&
return
if
result
[
:success
]
end
render
:new
end
private
def
company_params
params
.
permit
(
:first_name
,
:last_name
,
:company_name
,
:company_size
,
:phone_number
,
:country
,
:state
,
:website_url
,
:namespace_id
,
:glm_content
,
:glm_source
)
.
merge
(
extra_params
)
end
def
extra_params
{
work_email:
current_user
.
email
,
uid:
current_user
.
id
,
provider:
'gitlab'
,
setup_for_company:
current_user
.
setup_for_company
,
skip_email_confirmation:
true
,
gitlab_com_trial:
true
,
newsletter_segment:
current_user
.
email_opted_in
}
end
end
end
ee/app/controllers/trials_controller.rb
View file @
a6ac52d3
...
...
@@ -27,16 +27,12 @@ class TrialsController < ApplicationController
end
def
create_lead
if
params
.
has_key?
(
:trial
)
return
create_hand_raise_lead
unless
Gitlab
::
Utils
.
to_boolean
(
params
[
:trial
])
end
url_params
=
{
glm_source:
params
[
:glm_source
],
glm_content:
params
[
:glm_content
]
}
@result
=
GitlabSubscriptions
::
CreateLeadService
.
new
.
execute
({
trial_user:
company_params
})
render
(
:new
)
&&
return
unless
@result
[
:success
]
if
params
[
:onboarding
]
==
'true'
||
params
[
:trial
]
==
'true'
if
params
[
:onboarding
]
redirect_to
(
new_users_sign_up_groups_project_path
(
url_params
.
merge
(
trial_onboarding_flow:
true
)))
elsif
@namespace
=
helpers
.
only_trialable_group_namespace
params
[
:namespace_id
]
=
@namespace
.
id
...
...
@@ -50,7 +46,6 @@ class TrialsController < ApplicationController
result
=
GitlabSubscriptions
::
CreateHandRaiseLeadService
.
new
.
execute
(
hand_raise_lead_params
)
if
result
.
success?
redirect_to
new_users_sign_up_groups_project_path
(
skip_trial:
true
)
if
params
.
has_key?
(
:trial
)
head
200
else
render_403
...
...
@@ -137,7 +132,7 @@ class TrialsController < ApplicationController
def
company_params
params
.
permit
(
:company_name
,
:company_size
,
:first_name
,
:last_name
,
:phone_number
,
:country
,
:state
,
:
website_url
,
:
glm_content
,
:glm_source
).
merge
(
extra_params
)
:country
,
:state
,
:glm_content
,
:glm_source
).
merge
(
extra_params
)
end
def
extra_params
...
...
ee/app/helpers/ee/trial_helper.rb
View file @
a6ac52d3
...
...
@@ -27,7 +27,7 @@ module EE
def
create_company_form_data
{
submit_path:
create_lead_trials
_path
(
glm_params
),
submit_path:
users_sign_up_company
_path
(
glm_params
),
trial:
params
[
:trial
],
first_name:
current_user
.
first_name
,
last_name:
current_user
.
last_name
,
...
...
ee/spec/controllers/trials_controller_spec.rb
View file @
a6ac52d3
...
...
@@ -216,24 +216,6 @@ RSpec.describe TrialsController, :saas do
post_create_lead
end
end
context
'when posting new company information'
do
where
(
trial:
[
true
,
false
])
with_them
do
let
(
:post_params
)
{
{
trial:
trial
}
}
let
(
:post_service
)
{
trial
?
GitlabSubscriptions
::
CreateLeadService
:
GitlabSubscriptions
::
CreateHandRaiseLeadService
}
it
'calls the correct service'
do
expect_next_instance_of
(
post_service
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
and_return
(
ServiceResponse
.
success
)
end
post
:create_lead
,
params:
post_params
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
describe
'#create_hand_raise_lead'
do
...
...
ee/spec/features/trial_registrations/company_information_spec.rb
View file @
a6ac52d3
...
...
@@ -34,10 +34,10 @@ RSpec.describe 'Company Information', :js do
"newsletter_segment"
=>
user
.
email_opted_in
,
"website_url"
=>
'gitlab.com'
}
end
lead_params
=
{
trial_user:
ActionController
::
Parameters
.
new
(
trial_user_params
).
permit!
}
let
(
:params
)
{
ActionController
::
Parameters
.
new
(
trial_user_params
).
permit!
}
let
(
:trial_params
)
{
{
trial_user:
params
}
}
fill_in
'company_name'
,
with:
'GitLab'
select
'1 - 99'
,
from:
'company_size'
...
...
@@ -46,11 +46,25 @@ RSpec.describe 'Company Information', :js do
fill_in
'website_url'
,
with:
'gitlab.com'
fill_in
'phone_number'
,
with:
'+1 23 456-78-90'
expect_next_instance_of
(
GitlabSubscriptions
::
CreateLeadService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
lead_params
).
and_return
({
success:
true
})
with_them
do
it
'proceeds to next step'
do
fill_in
'company_name'
,
with:
'GitLab'
select
'1 - 99'
,
from:
'company_size'
select
'United States of America'
,
from:
'country'
select
'California'
,
from:
'state'
fill_in
'website_url'
,
with:
'gitlab.com'
fill_in
'phone_number'
,
with:
'+1 23 456-78-90'
# defaults to trial off, click to turn on
click_button
class:
'gl-toggle'
if
trial
expect_next_instance_of
(
post_service
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
with
(
post_params
).
and_return
({
success:
true
})
end
click_button
'Continue'
expect
(
page
).
to
have_current_path
(
new_users_sign_up_groups_project_path
,
ignore_query:
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