* Prepare to drop profile columns from user * Update code and factory * Also remove unused constant * Move validation from user to profile * Remove Profiles::ExtractData service object * Add more comments * Simplify sameAs attribute generation * Obey me machine, I am your master * Fix condition order in guard clause * Temporarily disable callback * Fix specs * Reduce usage of Profile#refresh_attributes! * Remove leftover comment * Handle social media links differently * More spec fixes * Fix specs for admin profile fields controller * Fix specs after merge * Fix remaining specs * Update user show request spec * Add comment for follow_hiring_tag * Only save profile when user is valid * Fix seeds.rb for profile fields * Switch from before_save to after_save * Undo unrelated formattin change * Update spec/fixtures/files/profile_fields.csv Co-authored-by: Molly Struve <mollylbs@gmail.com> * Remove data update script and spec * Fix spec * Fix typo in comment * Fix typo in comment * Move article resave logic to service object * Move profile field creation to before(:suite) * Refactor error handling in Profiles::Update * Fix Profiles::Update specs and refactor * Temporarily disable spec * Add ProfileValidator * Clean up * Move DB ready check into app/lib * Refresh attributes after importing from CSV * Fix specs * Remove unused file * A girl has no name. A profile neither. * Fix specs * Add responds_to? check * Spec fix * Add name to user fields in profile settings page Co-authored-by: Molly Struve <mollylbs@gmail.com>
46 lines
1.7 KiB
Ruby
46 lines
1.7 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Admin manages profile fields", type: :system do
|
|
let(:admin) { create(:user, :super_admin) }
|
|
let!(:profile_field_group) { create(:profile_field_group, name: "Delete Me") }
|
|
let(:label) { "Delete Me Too" }
|
|
|
|
before do
|
|
create(:profile_field, profile_field_group: profile_field_group, label: label)
|
|
Profile.refresh_attributes!
|
|
allow(FeatureFlag).to receive(:enabled?).with(:profile_admin).and_return(true)
|
|
|
|
sign_in admin
|
|
visit admin_profile_fields_path
|
|
end
|
|
|
|
it "adds a profile group" do
|
|
click_button "Add group"
|
|
find("#add-group-modal #profile_field_group_name").set("Example group")
|
|
click_on "Create Profile field group"
|
|
expect(page).to have_text("Successfully created group: Example group")
|
|
end
|
|
|
|
it "adds a profile field" do
|
|
group_name = profile_field_group.name.gsub(/\s+/, "_")
|
|
within(find("#profile-field-group-#{profile_field_group.id}")) do
|
|
click_button("Add Field")
|
|
input = find("#add-#{group_name}-profile-field-modal #profile_field_label")
|
|
input.set("Example field")
|
|
click_on "Create Profile field"
|
|
end
|
|
expect(page).to have_text("Profile field Example field created")
|
|
end
|
|
|
|
it "deletes a profile_field_group" do
|
|
find("#profile-field-group-#{profile_field_group.id}").click_button("Delete Group")
|
|
expect(page).to have_text("Group #{profile_field_group.name} deleted")
|
|
end
|
|
|
|
it "deletes a profile_field" do
|
|
profile_field = ProfileField.find_by(label: label)
|
|
expect(page).to have_text(profile_field.label.to_s)
|
|
find("#profile-field-#{profile_field.id}").click_button("Delete Profile Field")
|
|
expect(page).to have_text("Profile field #{label} deleted")
|
|
end
|
|
end
|