* 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>
45 lines
1.7 KiB
Ruby
45 lines
1.7 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "ProfileFieldGroups", type: :request do
|
|
let(:user) { create(:user) }
|
|
|
|
describe "GET /profile_field_groups" do
|
|
let!(:group1) { create(:profile_field_group) }
|
|
let!(:group2) { create(:profile_field_group) }
|
|
|
|
before do
|
|
create(:profile_field, :onboarding, label: "Field 1", profile_field_group: group1)
|
|
create(:profile_field, label: "Field 2", profile_field_group: group1)
|
|
create(:profile_field, label: "Field 3", profile_field_group: group2)
|
|
Profile.refresh_attributes!
|
|
|
|
sign_in user
|
|
end
|
|
|
|
it "returns a successful response" do
|
|
get profile_field_groups_path
|
|
expect(response.status).to eq 200
|
|
end
|
|
|
|
it "returns all groups with all fields by default" do
|
|
get profile_field_groups_path
|
|
json_response = JSON.parse(response.body, symbolize_names: true)
|
|
expect(json_response[:profile_field_groups].size).to eq ProfileFieldGroup.all.size
|
|
end
|
|
|
|
it "returns only groups with onboarding fields when onboarding=true" 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
|
|
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
|
|
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
|
|
end
|
|
end
|
|
end
|