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
5faa7881
Commit
5faa7881
authored
Mar 15, 2022
by
minahilnichols
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hidden params to form
parent
3c16576a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
4 deletions
+104
-4
ee/app/assets/javascripts/registrations/company/new/index.js
ee/app/assets/javascripts/registrations/company/new/index.js
+9
-2
ee/app/assets/javascripts/registrations/components/company_form.vue
...ets/javascripts/registrations/components/company_form.vue
+1
-1
ee/app/controllers/trials_controller.rb
ee/app/controllers/trials_controller.rb
+2
-0
ee/app/helpers/ee/trial_helper.rb
ee/app/helpers/ee/trial_helper.rb
+12
-0
ee/spec/controllers/trials_controller_spec.rb
ee/spec/controllers/trials_controller_spec.rb
+18
-0
ee/spec/frontend/registrations/company/new/components/company_form_spec.js
...registrations/company/new/components/company_form_spec.js
+17
-1
ee/spec/helpers/ee/trial_helper_spec.rb
ee/spec/helpers/ee/trial_helper_spec.rb
+45
-0
No files found.
ee/app/assets/javascripts/registrations/company/new/index.js
View file @
5faa7881
...
@@ -5,12 +5,19 @@ import RegistrationForm from 'ee/registrations/components/company_form.vue';
...
@@ -5,12 +5,19 @@ import RegistrationForm from 'ee/registrations/components/company_form.vue';
export
default
()
=>
{
export
default
()
=>
{
const
el
=
document
.
querySelector
(
'
#js-company-registration-form
'
);
const
el
=
document
.
querySelector
(
'
#js-company-registration-form
'
);
const
{
trial
,
createLeadPath
}
=
el
.
dataset
;
const
{
submitPath
,
trial
,
firstName
,
lastName
,
role
,
jtbd
,
comment
}
=
el
.
dataset
;
return
new
Vue
({
return
new
Vue
({
el
,
el
,
apolloProvider
,
apolloProvider
,
provide
:
{
createLeadPath
},
provide
:
{
submitPath
,
firstName
,
lastName
,
role
,
jtbd
,
comment
,
},
render
(
createElement
)
{
render
(
createElement
)
{
return
createElement
(
RegistrationForm
,
{
return
createElement
(
RegistrationForm
,
{
props
:
{
trial
},
props
:
{
trial
},
...
...
ee/app/assets/javascripts/registrations/components/company_form.vue
View file @
5faa7881
...
@@ -28,7 +28,7 @@ export default {
...
@@ -28,7 +28,7 @@ export default {
CountryOrRegionSelector
,
CountryOrRegionSelector
,
RegistrationTrialToggle
,
RegistrationTrialToggle
,
},
},
inject
:
[
'
createLeadPath
'
],
inject
:
[
'
submitPath
'
,
'
firstName
'
,
'
lastName
'
,
'
role
'
,
'
jtbd
'
,
'
comment
'
],
props
:
{
props
:
{
trial
:
{
trial
:
{
type
:
Boolean
,
type
:
Boolean
,
...
...
ee/app/controllers/trials_controller.rb
View file @
5faa7881
...
@@ -27,6 +27,8 @@ class TrialsController < ApplicationController
...
@@ -27,6 +27,8 @@ class TrialsController < ApplicationController
end
end
def
create_lead
def
create_lead
return
create_hand_raise_lead
unless
Gitlab
::
Utils
.
to_boolean
(
params
[
:trial
])
url_params
=
{
glm_source:
params
[
:glm_source
],
glm_content:
params
[
:glm_content
]
}
url_params
=
{
glm_source:
params
[
:glm_source
],
glm_content:
params
[
:glm_content
]
}
@result
=
GitlabSubscriptions
::
CreateLeadService
.
new
.
execute
({
trial_user:
company_params
})
@result
=
GitlabSubscriptions
::
CreateLeadService
.
new
.
execute
({
trial_user:
company_params
})
...
...
ee/app/helpers/ee/trial_helper.rb
View file @
5faa7881
...
@@ -25,6 +25,18 @@ module EE
...
@@ -25,6 +25,18 @@ module EE
}.
merge
(
params
.
slice
(
:first_name
,
:last_name
,
:company_name
,
:company_size
,
:phone_number
,
:country
,
:state
).
to_unsafe_h
.
symbolize_keys
)
}.
merge
(
params
.
slice
(
:first_name
,
:last_name
,
:company_name
,
:company_size
,
:phone_number
,
:country
,
:state
).
to_unsafe_h
.
symbolize_keys
)
end
end
def
create_company_form_data
{
submit_path:
create_lead_trials_path
(
glm_params
),
trial:
params
[
:trial
],
first_name:
current_user
.
first_name
,
last_name:
current_user
.
last_name
,
role:
params
[
:role
],
jtbd:
params
[
:jtbd
],
comment:
params
[
:comment
]
}.
merge
(
params
.
slice
(
:first_name
,
:last_name
).
to_unsafe_h
.
symbolize_keys
)
end
def
should_ask_company_question?
def
should_ask_company_question?
TRIAL_ONBOARDING_SOURCE_URLS
.
exclude?
(
glm_params
[
:glm_source
])
TRIAL_ONBOARDING_SOURCE_URLS
.
exclude?
(
glm_params
[
:glm_source
])
end
end
...
...
ee/spec/controllers/trials_controller_spec.rb
View file @
5faa7881
...
@@ -216,6 +216,24 @@ RSpec.describe TrialsController, :saas do
...
@@ -216,6 +216,24 @@ RSpec.describe TrialsController, :saas do
post_create_lead
post_create_lead
end
end
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
end
describe
'#create_hand_raise_lead'
do
describe
'#create_hand_raise_lead'
do
...
...
ee/spec/frontend/registrations/company/new/components/company_form_spec.js
View file @
5faa7881
...
@@ -17,7 +17,12 @@ describe('RegistrationForm', () => {
...
@@ -17,7 +17,12 @@ describe('RegistrationForm', () => {
return
mountFunction
(
RegistrationForm
,
{
return
mountFunction
(
RegistrationForm
,
{
localVue
,
localVue
,
provide
:
{
provide
:
{
createLeadPath
:
SUBMIT_PATH
,
submitPath
:
SUBMIT_PATH
,
firstName
:
'
Joe
'
,
lastName
:
'
Doe
'
,
role
:
'
Software Engineer
'
,
jtbd
:
'
Jobs to be done
'
,
comment
:
'
A comment
'
,
},
},
propsData
:
{
trial
:
true
},
propsData
:
{
trial
:
true
},
});
});
...
@@ -68,6 +73,17 @@ describe('RegistrationForm', () => {
...
@@ -68,6 +73,17 @@ describe('RegistrationForm', () => {
`
(
'
has the correct form input in the form content
'
,
({
testid
})
=>
{
`
(
'
has the correct form input in the form content
'
,
({
testid
})
=>
{
expect
(
findFormInput
(
testid
).
exists
()).
toBe
(
true
);
expect
(
findFormInput
(
testid
).
exists
()).
toBe
(
true
);
});
});
it
.
each
`
testid | value
${
'
first_name
'
}
|
${
'
Joe
'
}
${
'
last_name
'
}
|
${
'
Doe
'
}
${
'
role
'
}
|
${
'
Software Engineer
'
}
${
'
jtbd
'
}
|
${
'
Jobs to be done
'
}
${
'
comment
'
}
|
${
'
A comment
'
}
`
(
'
has the hidden injected value for $testid
'
,
({
testid
,
value
})
=>
{
expect
(
findFormInput
(
testid
).
attributes
(
'
value
'
)).
toBe
(
value
);
});
});
});
describe
(
'
submitting
'
,
()
=>
{
describe
(
'
submitting
'
,
()
=>
{
...
...
ee/spec/helpers/ee/trial_helper_spec.rb
View file @
5faa7881
...
@@ -56,6 +56,51 @@ RSpec.describe EE::TrialHelper do
...
@@ -56,6 +56,51 @@ RSpec.describe EE::TrialHelper do
end
end
end
end
describe
'#create_company_form_data'
do
let
(
:user
)
do
double
(
'User'
,
first_name:
'_first_name_'
,
last_name:
'_last_name_'
)
end
let
(
:extra_params
)
do
{
first_name:
'_params_first_name_'
,
last_name:
'_params_last_name_'
}
end
let
(
:params
)
do
ActionController
::
Parameters
.
new
(
extra_params
.
merge
(
glm_source:
'_glm_source_'
,
glm_content:
'_glm_content_'
))
end
before
do
allow
(
helper
).
to
receive
(
:params
).
and_return
(
params
)
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
it
'provides expected form data'
do
keys
=
extra_params
.
keys
+
[
:submit_path
,
:trial
,
:role
,
:jtbd
,
:comment
]
expect
(
helper
.
create_company_form_data
.
keys
.
map
(
&
:to_sym
)).
to
match_array
(
keys
)
end
it
'allows overriding data with params'
do
expect
(
helper
.
create_company_form_data
).
to
match
(
a_hash_including
(
extra_params
))
end
context
'when params are empty'
do
let
(
:extra_params
)
{
{}
}
it
'uses the values from current user'
do
current_user_attributes
=
{
first_name:
user
.
first_name
,
last_name:
user
.
last_name
}
expect
(
helper
.
create_company_form_data
).
to
match
(
a_hash_including
(
current_user_attributes
))
end
end
end
describe
'#should_ask_company_question?'
do
describe
'#should_ask_company_question?'
do
before
do
before
do
allow
(
helper
).
to
receive
(
:glm_params
).
and_return
(
glm_source
?
{
glm_source:
glm_source
}
:
{})
allow
(
helper
).
to
receive
(
:glm_params
).
and_return
(
glm_source
?
{
glm_source:
glm_source
}
:
{})
...
...
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