From 2e202b039909611a1c2e2e3848620225ae851982 Mon Sep 17 00:00:00 2001 From: Michael Kohl Date: Mon, 11 Jan 2021 11:22:39 +0700 Subject: [PATCH] Remove looking for work columns (#12173) * Remove looking for work columns * Fix schema.rb * Undo accidental change * Update spec --- .../components/__tests__/ProfileForm.test.jsx | 10 ++--- app/models/profile.rb | 1 - app/policies/user_policy.rb | 2 - .../profile_fields/add_work_fields.rb | 2 - app/views/articles/_user_metadata.html.erb | 10 ----- app/views/pages/_privacy_text.html.erb | 2 +- app/views/users/_metadata.html.erb | 45 +++++++------------ ...1718_remove_looking_for_work_from_users.rb | 8 ++++ db/schema.rb | 4 +- lib/data/dev_profile_fields.csv | 2 - ..._remove_looking_for_work_profile_fields.rb | 10 +++++ .../create_profile_fields_spec.rb | 4 +- spec/services/profiles/update_spec.rb | 8 ++-- 13 files changed, 46 insertions(+), 62 deletions(-) create mode 100644 db/migrate/20210108031718_remove_looking_for_work_from_users.rb create mode 100644 lib/data_update_scripts/20210108033107_remove_looking_for_work_profile_fields.rb diff --git a/app/javascript/onboarding/components/__tests__/ProfileForm.test.jsx b/app/javascript/onboarding/components/__tests__/ProfileForm.test.jsx index 8f84b567e..86303c338 100644 --- a/app/javascript/onboarding/components/__tests__/ProfileForm.test.jsx +++ b/app/javascript/onboarding/components/__tests__/ProfileForm.test.jsx @@ -43,10 +43,10 @@ describe('ProfileForm', () => { profile_fields: [ { id: 36, - attribute_name: 'looking_for_work', + attribute_name: 'education', description: '', - input_type: 'check_box', - label: 'Looking for work?', + input_type: 'text_field', + label: 'Education', placeholder_text: '', }, ], @@ -119,7 +119,7 @@ describe('ProfileForm', () => { it('should render the correct group headings', async () => { const { findByText } = renderProfileForm(); - const heading1 = await findByText(/Looking for work?/i); + const heading1 = await findByText('Education'); const heading2 = await findByText('Name'); expect(heading1).toBeInTheDocument(); @@ -129,7 +129,7 @@ describe('ProfileForm', () => { it('should render the correct fields', async () => { const { findByLabelText } = renderProfileForm(); - const field1 = await findByLabelText(/Looking for work?/i); + const field1 = await findByLabelText(/Education/i); const field2 = await findByLabelText(/Name/i); const field3 = await findByLabelText(/Website URL/i); diff --git a/app/models/profile.rb b/app/models/profile.rb index 0a5b1edc5..db08a43b8 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -15,7 +15,6 @@ class Profile < ApplicationRecord brand_color1: :bg_color_hex, brand_color2: :text_color_hex, display_email_on_profile: :email_public, - display_looking_for_work_on_profile: :looking_for_work_publicly, education: :education, git_lab_url: :gitlab_url, linked_in_url: :linkedin_url, diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index 8da5f823a..7fe551077 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -41,8 +41,6 @@ class UserPolicy < ApplicationPolicy instagram_url linkedin_url location - looking_for_work - looking_for_work_publicly mastodon_url medium_url mobile_comment_notifications diff --git a/app/services/profile_fields/add_work_fields.rb b/app/services/profile_fields/add_work_fields.rb index 096f4fb20..81b979213 100644 --- a/app/services/profile_fields/add_work_fields.rb +++ b/app/services/profile_fields/add_work_fields.rb @@ -7,8 +7,6 @@ module ProfileFields field "Employer name", :text_field, placeholder: "Acme Inc.", display_area: "header" field "Employer URL", :text_field, placeholder: "https://dev.com", display_area: "settings_only" field "Employment title", :text_field, placeholder: "Junior Frontend Engineer", display_area: "header" - field "Looking for work", :check_box, display_area: "settings_only" - field 'Display "looking for work" on profile', :check_box, display_area: "settings_only" field "Recruiters can contact me about job opportunities", :check_box, display_area: "settings_only" end end diff --git a/app/views/articles/_user_metadata.html.erb b/app/views/articles/_user_metadata.html.erb index d85e6329c..b0cfc2e4b 100644 --- a/app/views/articles/_user_metadata.html.erb +++ b/app/views/articles/_user_metadata.html.erb @@ -71,16 +71,6 @@ <% end %> - <% if @user.looking_for_work_publicly == true && @user.looking_for_work == true %> -
  • -
    - Work status -
    -
    - I'm looking for work! -
    -
  • - <% end %> <% if @user.education.present? %>
  • diff --git a/app/views/pages/_privacy_text.html.erb b/app/views/pages/_privacy_text.html.erb index 9764f4b49..3cd751fe5 100644 --- a/app/views/pages/_privacy_text.html.erb +++ b/app/views/pages/_privacy_text.html.erb @@ -33,7 +33,7 @@ We do host first-party advertising on <%= community_name %>. We do not run any code from advertisers and all ad images are hosted on managed <%= community_name %> servers. For more details, see our section on Advertising Details.

    - We may use User Personal Information with your permission, so we can perform services you have authorized. For example, if you indicate you are looking for work, we may contact you with opportunities. + We may use User Personal Information with your permission, so we can perform services you have authorized.

    We may share User Personal Information with a limited number of third party vendors who process it on our behalf to provide or improve our service, and who have agreed to privacy restrictions similar to our own Privacy Statement. Our third party vendors are listed below. diff --git a/app/views/users/_metadata.html.erb b/app/views/users/_metadata.html.erb index 1533a0493..d783a9b13 100644 --- a/app/views/users/_metadata.html.erb +++ b/app/views/users/_metadata.html.erb @@ -13,35 +13,27 @@ <% end %> <%# As we migrate to more generalized profiles, we don't want to break DEV %> <% if SiteConfig.dev_to? %> - <% if @user.employment_title.present? || (@user.looking_for_work_publicly == true && @user.looking_for_work == true) %> - <% if @user.employment_title.present? %> -
    - Work -

    - <%= @user.employment_title %> - <% if @user.employer_name.present? %> - at - <% if @user.employer_url.present? %> - <%= @user.employer_name %> - <% else %> - <%= @user.employer_name %> - <% end %> + <% if @user.employment_title.present? %> +

    + Work +

    + <%= @user.employment_title %> + <% if @user.employer_name.present? %> + at + <% if @user.employer_url.present? %> + <%= @user.employer_name %> + <% else %> + <%= @user.employer_name %> <% end %> -

    -
    - <% end %> - <% if @user.looking_for_work_publicly == true && @user.looking_for_work == true %> -
    - Work status -

    I'm looking for work!

    -
    - <% end %> + <% end %> +

    +
    <% end %> <% end %>
    <% end %> <% else %> - <% if @user.employment_title.present? || (@user.looking_for_work_publicly == true && @user.looking_for_work == true) || @user.education.present? %> + <% if @user.employment_title.present? || @user.education.present? %>
    <% if @user.education.present? %>
    @@ -66,13 +58,6 @@

    <% end %> - - <% if @user.looking_for_work_publicly == true && @user.looking_for_work == true %> -
    - Work status -

    I'm looking for work!

    -
    - <% end %>
    <% end %> <% end %> diff --git a/db/migrate/20210108031718_remove_looking_for_work_from_users.rb b/db/migrate/20210108031718_remove_looking_for_work_from_users.rb new file mode 100644 index 000000000..b51b290b3 --- /dev/null +++ b/db/migrate/20210108031718_remove_looking_for_work_from_users.rb @@ -0,0 +1,8 @@ +class RemoveLookingForWorkFromUsers < ActiveRecord::Migration[6.0] + def change + safety_assured do + remove_column :users, :looking_for_work + remove_column :users, :looking_for_work_publicly + end + end +end diff --git a/db/schema.rb b/db/schema.rb index eec392558..5fac0dba9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_01_05_183127) do +ActiveRecord::Schema.define(version: 2021_01_08_031718) do # These are extensions that must be enabled in order to support this database enable_extension "citext" @@ -1283,8 +1283,6 @@ ActiveRecord::Schema.define(version: 2021_01_05_183127) do t.string "linkedin_url" t.string "location" t.datetime "locked_at" - t.boolean "looking_for_work", default: false - t.boolean "looking_for_work_publicly", default: false t.string "mastodon_url" t.string "medium_url" t.boolean "mobile_comment_notifications", default: true diff --git a/lib/data/dev_profile_fields.csv b/lib/data/dev_profile_fields.csv index 4fd931a77..afa1ddc6c 100644 --- a/lib/data/dev_profile_fields.csv +++ b/lib/data/dev_profile_fields.csv @@ -17,8 +17,6 @@ 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 diff --git a/lib/data_update_scripts/20210108033107_remove_looking_for_work_profile_fields.rb b/lib/data_update_scripts/20210108033107_remove_looking_for_work_profile_fields.rb new file mode 100644 index 000000000..83e316b6a --- /dev/null +++ b/lib/data_update_scripts/20210108033107_remove_looking_for_work_profile_fields.rb @@ -0,0 +1,10 @@ +module DataUpdateScripts + class RemoveLookingForWorkProfileFields + def run + # destroy_by is idempotent by default: if no record can be found an empty + # array will be returned. + ProfileField.destroy_by(attribute_name: "looking_for_work") + ProfileField.destroy_by(attribute_name: "display_looking_for_work_on_profile") + end + end +end diff --git a/spec/lib/data_update_scripts/create_profile_fields_spec.rb b/spec/lib/data_update_scripts/create_profile_fields_spec.rb index 736d7a2ae..bdced85de 100644 --- a/spec/lib/data_update_scripts/create_profile_fields_spec.rb +++ b/spec/lib/data_update_scripts/create_profile_fields_spec.rb @@ -15,7 +15,7 @@ describe DataUpdateScripts::CreateProfileFields do it "creates all profile fields and groups" do expect do described_class.new.run - end.to change { profile_field_and_group_count }.from([0, 0]).to([28, 5]) + end.to change { profile_field_and_group_count }.from([0, 0]).to([26, 5]) end end @@ -29,7 +29,7 @@ describe DataUpdateScripts::CreateProfileFields do expect do described_class.new.run end.not_to change { profile_field_and_group_count } - expect(profile_field_and_group_count).to eq [28, 5] + expect(profile_field_and_group_count).to eq [26, 5] end end end diff --git a/spec/services/profiles/update_spec.rb b/spec/services/profiles/update_spec.rb index 1d708e0d9..cff51fea6 100644 --- a/spec/services/profiles/update_spec.rb +++ b/spec/services/profiles/update_spec.rb @@ -11,14 +11,14 @@ RSpec.describe Profiles::Update, type: :service do end let(:profile) do - create(:profile, data: { looking_for_work: true, removed: "Bla" }) + create(:profile, data: { education: "maybe", removed: "Bla" }) end let(:user) { profile.user } it "correctly typecasts new attributes", :aggregate_failures do - described_class.call(user, profile: { location: 123, looking_for_work: "false" }) + described_class.call(user, profile: { location: 123, education: "false" }) expect(user.location).to eq "123" - expect(profile.looking_for_work).to be false + expect(profile.education).to eq "false" end it "removes old attributes from the profile" do @@ -43,7 +43,7 @@ RSpec.describe Profiles::Update, type: :service do it "updates the profile_updated_at column" do expect do - described_class.call(user, profile: { looking_for_work: "false" }) + described_class.call(user, profile: { education: "false" }) end.to change { user.reload.profile_updated_at } end