mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 15:24:33 +08:00
FEATURE: User fields required for existing users - Part 2 (#27172)
We want to allow admins to make new required fields apply to existing users. In order for this to work we need to have a way to make those users fill up the fields on their next page load. This is very similar to how adding a 2FA requirement post-fact works. Users will be redirected to a page where they can fill up the remaining required fields, and until they do that they won't be able to do anything else.
This commit is contained in:
52
spec/system/user_page/user_preferences_profile_spec.rb
Normal file
52
spec/system/user_page/user_preferences_profile_spec.rb
Normal file
@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe "User preferences | Profile", type: :system do
|
||||
fab!(:user) { Fabricate(:user, active: true) }
|
||||
let(:user_preferences_profile_page) { PageObjects::Pages::UserPreferencesProfile.new }
|
||||
let(:user_preferences_page) { PageObjects::Pages::UserPreferences.new }
|
||||
|
||||
before { sign_in(user) }
|
||||
|
||||
describe "enforcing required fields" do
|
||||
before do
|
||||
UserRequiredFieldsVersion.create!
|
||||
UserField.create!(
|
||||
field_type: "text",
|
||||
name: "Favourite Pokemon",
|
||||
description: "Hint: It's Mudkip.",
|
||||
requirement: :for_all_users,
|
||||
editable: true,
|
||||
)
|
||||
end
|
||||
|
||||
it "redirects to the profile page to fill up required fields" do
|
||||
visit("/")
|
||||
|
||||
expect(page).to have_current_path("/u/bruce0/preferences/profile")
|
||||
|
||||
expect(page).to have_selector(
|
||||
".alert-error",
|
||||
text: I18n.t("js.user.preferences.profile.enforced_required_fields"),
|
||||
)
|
||||
end
|
||||
|
||||
it "disables client-side routing while missing required fields" do
|
||||
user_preferences_profile_page.visit(user)
|
||||
|
||||
find("#site-logo").click
|
||||
|
||||
expect(page).to have_current_path("/u/bruce0/preferences/profile")
|
||||
end
|
||||
|
||||
it "allows user to fill up required fields" do
|
||||
user_preferences_profile_page.visit(user)
|
||||
|
||||
find(".user-field-favourite-pokemon input").fill_in(with: "Mudkip")
|
||||
find(".save-button .btn-primary").click
|
||||
|
||||
visit("/")
|
||||
|
||||
expect(page).to have_current_path("/")
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user