Deployment Task: Update onboarding fields prior to #11629 (#11704)

This commit is contained in:
Ridhwana 2020-12-07 21:57:18 +02:00 committed by GitHub
parent 31b83a4511
commit 19a048ecec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 73 additions and 44 deletions

View file

@ -3,10 +3,24 @@ module ProfileFields
include FieldDefinition
group "Basic" do
field "Display email on profile", :check_box, display_area: "settings_only"
field "Website URL", :text_field, placeholder: "https://yoursite.com", display_area: "header"
field "Summary", :text_area, placeholder: "A short bio...", display_area: "header"
field "Location", :text_field, placeholder: "Halifax, Nova Scotia", display_area: "header"
field "Display email on profile",
:check_box,
display_area: "settings_only"
field "Website URL",
:text_field,
placeholder: "https://yoursite.com",
display_area: "header",
show_in_onboarding: true
field "Summary",
:text_area,
placeholder: "A short bio...",
display_area: "header",
show_in_onboarding: true
field "Location",
:text_field,
placeholder: "Halifax, Nova Scotia",
display_area: "header",
show_in_onboarding: true
end
end
end

View file

@ -20,14 +20,16 @@ module ProfileFields
private
def field(label, input_type, placeholder: nil, description: nil, group: @group, display_area: "left_sidebar")
def field(label, input_type, **attributes)
attributes = attributes.reverse_merge(group: @group, display_area: "left_sidebar")
fields << {
label: label,
input_type: input_type,
placeholder_text: placeholder,
description: description,
profile_field_group: group,
display_area: display_area
placeholder_text: attributes[:placeholder],
description: attributes[:description],
profile_field_group: attributes[:group],
display_area: attributes[:display_area],
show_in_onboarding: attributes[:show_in_onboarding]
}.compact
end
end

View file

@ -1,6 +1,6 @@
module ProfileFields
class ImportFromCsv
HEADERS = %i[label input_type placeholder_text description group display_area].freeze
HEADERS = %i[label input_type placeholder_text description group display_area show_in_onboarding].freeze
def self.call(file)
CSV.foreach(file, headers: HEADERS, skip_blanks: true) do |row|

View file

@ -1,28 +1,28 @@
Display email on profile,check_box,,,Basic,settings_only
Website URL,text_field,https://yoursite.com,,Basic,header
Summary,text_area,A short bio...,,Basic,header
Location,text_field,"Halifax, Nova Scotia",,Basic,header
Facebook URL,text_field,https://facebook.com/...,,Links,header
Youtube URL,text_field,https://www.youtube.com/channel/...,,Links,header
StackOverflow URL,text_field,https://stackoverflow.com/users/...,,Links,header
LinkedIn URL,text_field,https://www.linkedin.com/in/...,,Links,header
Behance URL,text_field,https://www.behance.net/...,,Links,header
Dribbble URL,text_field,https://dribbble.com/...,,Links,header
Medium URL,text_field,https://medium.com/@...,,Links,header
GitLab URL,text_field,https://gitlab.com/...,,Links,header
Instagram URL,text_field,https://www.instagram.com/...,,Links,header
Mastodon URL,text_field,https://...,,Links,header
Twitch URL,text_field,https://www.twitch.tv/...,,Links,header
Education,text_field,,,Work,header
Employer name,text_field,Acme Inc.,,Work,header
Employer URL,text_field,https://dev.com,,Work,header
Employment title,text_field,Junior Frontend Engineer,,Work,header
Looking for work,check_box,,,Work,settings_only
"Display ""looking for work"" on profile",check_box,,,Work,settings_only
Recruiters can contact me about job opportunities,check_box,,,Work,settings_only
Skills/Languages,text_area,,What tools and languages are you most experienced with? Are you specialized or more of a generalist?,Coding,left_sidebar
Currently learning,text_area,,"What are you learning right now? What are the new tools and languages you're picking up right now?",Coding,left_sidebar
Currently hacking on,text_area,,What projects are currently occupying most of your time?,Coding,left_sidebar
Available for,text_area,,"What kinds of collaborations or discussions are you available for? What's a good reason to say Hey! to you these days?",Coding,left_sidebar
Brand color 1,color_field,#000000,"Used for backgrounds, borders etc.",Branding,settings_only
Brand color 2,color_field,#000000,Used for texts (usually put on Brand color 1).,Branding,settings_only
Display email on profile,check_box,,,Basic,settings_only,false
Website URL,text_field,https://yoursite.com,,Basic,header,true
Summary,text_area,A short bio...,,Basic,header,true
Location,text_field,"Halifax, Nova Scotia",,Basic,header,true
Facebook URL,text_field,https://facebook.com/...,,Links,header,false
Youtube URL,text_field,https://www.youtube.com/channel/...,,Links,header,false
StackOverflow URL,text_field,https://stackoverflow.com/users/...,,Links,header,false
LinkedIn URL,text_field,https://www.linkedin.com/in/...,,Links,header,false
Behance URL,text_field,https://www.behance.net/...,,Links,header,false
Dribbble URL,text_field,https://dribbble.com/...,,Links,header,false
Medium URL,text_field,https://medium.com/@...,,Links,header,false
GitLab URL,text_field,https://gitlab.com/...,,Links,header,false
Instagram URL,text_field,https://www.instagram.com/...,,Links,header,false
Mastodon URL,text_field,https://...,,Links,header,false
Twitch URL,text_field,https://www.twitch.tv/...,,Links,header,false
Education,text_field,,,Work,header,false
Employer name,text_field,Acme Inc.,,Work,header,false
Employer URL,text_field,https://dev.com,,Work,header,false
Employment title,text_field,Junior Frontend Engineer,,Work,header,false
Looking for work,check_box,,,Work,settings_only,false
"Display ""looking for work"" on profile",check_box,,,Work,settings_only,false
Recruiters can contact me about job opportunities,check_box,,,Work,settings_only,false
Skills/Languages,text_area,,What tools and languages are you most experienced with? Are you specialized or more of a generalist?,Coding,left_sidebar,false
Currently learning,text_area,,"What are you learning right now? What are the new tools and languages you're picking up right now?",Coding,left_sidebar,false
Currently hacking on,text_area,,What projects are currently occupying most of your time?,Coding,left_sidebar,false
Available for,text_area,,"What kinds of collaborations or discussions are you available for? What's a good reason to say Hey! to you these days?",Coding,left_sidebar,false
Brand color 1,color_field,#000000,"Used for backgrounds, borders etc.",Branding,settings_only,false
Brand color 2,color_field,#000000,Used for texts (usually put on Brand color 1).,Branding,settings_only,false

1 Display email on profile check_box Basic settings_only false
2 Website URL text_field https://yoursite.com Basic header true
3 Summary text_area A short bio... Basic header true
4 Location text_field Halifax, Nova Scotia Basic header true
5 Facebook URL text_field https://facebook.com/... Links header false
6 Youtube URL text_field https://www.youtube.com/channel/... Links header false
7 StackOverflow URL text_field https://stackoverflow.com/users/... Links header false
8 LinkedIn URL text_field https://www.linkedin.com/in/... Links header false
9 Behance URL text_field https://www.behance.net/... Links header false
10 Dribbble URL text_field https://dribbble.com/... Links header false
11 Medium URL text_field https://medium.com/@... Links header false
12 GitLab URL text_field https://gitlab.com/... Links header false
13 Instagram URL text_field https://www.instagram.com/... Links header false
14 Mastodon URL text_field https://... Links header false
15 Twitch URL text_field https://www.twitch.tv/... Links header false
16 Education text_field Work header false
17 Employer name text_field Acme Inc. Work header false
18 Employer URL text_field https://dev.com Work header false
19 Employment title text_field Junior Frontend Engineer Work header false
20 Looking for work check_box Work settings_only false
21 Display "looking for work" on profile check_box Work settings_only false
22 Recruiters can contact me about job opportunities check_box Work settings_only false
23 Skills/Languages text_area What tools and languages are you most experienced with? Are you specialized or more of a generalist? Coding left_sidebar false
24 Currently learning text_area What are you learning right now? What are the new tools and languages you're picking up right now? Coding left_sidebar false
25 Currently hacking on text_area What projects are currently occupying most of your time? Coding left_sidebar false
26 Available for text_area What kinds of collaborations or discussions are you available for? What's a good reason to say Hey! to you these days? Coding left_sidebar false
27 Brand color 1 color_field #000000 Used for backgrounds, borders etc. Branding settings_only false
28 Brand color 2 color_field #000000 Used for texts (usually put on Brand color 1). Branding settings_only false

View file

@ -0,0 +1,10 @@
namespace :profile_onboarding_fields do
desc "Setup Onboarding with previously shown fields"
task update: :environment do
ProfileField.where(attribute_name: "summary").update(label: "Bio", show_in_onboarding: true)
ProfileField.where(attribute_name: "location").update(label: "Location", show_in_onboarding: true)
ProfileField.where(attribute_name: "employment_title").update(label: "Employer title",
show_in_onboarding: true)
ProfileField.where(attribute_name: "employer_name").update(label: "Employer name", show_in_onboarding: true)
end
end

View file

@ -1,4 +1,4 @@
Test name,text_field,John Doe,,Basic,header
Test languages,text_area,,Programming languages,Coding,left_sidebar
Test name,text_field,John Doe,,Basic,header,false
Test languages,text_area,,Programming languages,Coding,left_sidebar,false
Test color,color_field,#000000,"Used for backgrounds, borders etc.",Branding,settings_only
Test color,color_field,#000000,"Used for backgrounds, borders etc.",Branding,settings_only,false

1 Test name text_field John Doe Basic header false
2 Test languages text_area Programming languages Coding left_sidebar false
3 Test color color_field #000000 Used for backgrounds, borders etc. Branding settings_only false
4

View file

@ -27,16 +27,19 @@ RSpec.describe "ProfileFieldGroups", type: :request do
expect(json_response[:profile_field_groups].size).to eq ProfileFieldGroup.all.size
end
it "returns only groups with onboarding fields when onboarding=true" do
it "returns only groups with onboarding fields when onboarding=true", :aggregate_failures do
get profile_field_groups_path, params: { onboarding: true }
json_response = JSON.parse(response.body, symbolize_names: true)
expect(json_response[:profile_field_groups].size).to eq 1
groups = json_response[:profile_field_groups]
expect(groups.any? { |g| g[:name] == group1.name }).to be true
expect(groups.any? { |g| g[:name] == group2.name }).to be false
end
it "only returns the onboarding fields in the group", :aggregate_failures do
get profile_field_groups_path, params: { onboarding: true }
json_response = JSON.parse(response.body, symbolize_names: true)
group = json_response[:profile_field_groups].first
groups = json_response[:profile_field_groups]
group = groups.detect { |g| g[:name] == group1.name }
expect(group[:profile_fields].size).to eq 1
field1 = ProfileField.find_by(label: "Field 1")
expect(group[:profile_fields].first[:id]).to eq field1.id