mirror of
https://github.com/we-promise/sure.git
synced 2026-05-24 13:04:56 +00:00
* Extract hardcoded strings to i18n
Replace numerous hardcoded English strings with I18n lookups (t / I18n.t) across controllers, views, helpers, and components, and convert model validation error messages to symbol keys. Added multiple locale files under config/locales for models and views. This centralizes user-facing notices/alerts, UI text, import/validation messages, and prepares the app for localization and easier translation maintenance.
* Update en.yml
* Update preview-cleanup.yml
* Revert "Update preview-cleanup.yml"
This reverts commit 1ba6d3c34c.
* test: align i18n assertions with translated messages
* Standardize balance error key and tweak locales
Replace SophtronAccount's :requires_balance error key with :no_balance and update related locale strings for sophtron, plaid, and simplefin accounts to use the new key and clearer copy. Also switch the QIF upload redirect notice to use a relative translation key (t('.qif_uploaded')), remove an unused SSO providers help line, and fix a trailing-newline/whitespace issue in the subscriptions locale. These changes standardize validation keys and improve translation consistency and messaging.
---------
Co-authored-by: KiloClaw <kiloclaw@openclaw.ai>
82 lines
2.6 KiB
Ruby
82 lines
2.6 KiB
Ruby
require "test_helper"
|
|
|
|
class Settings::ProfilesControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
@admin = users(:family_admin)
|
|
@member = users(:family_member)
|
|
@intro_user = users(:intro_user)
|
|
end
|
|
|
|
test "should get show" do
|
|
sign_in @admin
|
|
get settings_profile_path
|
|
assert_response :success
|
|
end
|
|
|
|
test "intro user sees profile without settings navigation" do
|
|
sign_in @intro_user
|
|
get settings_profile_path
|
|
|
|
assert_response :success
|
|
assert_select "#mobile-settings-nav", count: 0
|
|
assert_select "h2", text: I18n.t("settings.profiles.show.household_title"), count: 0
|
|
assert_select "[data-action='app-layout#openMobileSidebar']", count: 0
|
|
assert_select "[data-action='app-layout#closeMobileSidebar']", count: 0
|
|
assert_select "[data-action='app-layout#toggleLeftSidebar']", count: 0
|
|
assert_select "[data-action='app-layout#toggleRightSidebar']", count: 0
|
|
end
|
|
|
|
test "admin can remove a family member" do
|
|
sign_in @admin
|
|
assert_difference("User.count", -1) do
|
|
delete settings_profile_path(user_id: @member)
|
|
end
|
|
|
|
assert_redirected_to settings_profile_path
|
|
assert_equal I18n.t("settings.profiles.destroy.member_removed"), flash[:notice]
|
|
assert_raises(ActiveRecord::RecordNotFound) { User.find(@member.id) }
|
|
end
|
|
|
|
test "admin cannot remove themselves" do
|
|
sign_in @admin
|
|
assert_no_difference("User.count") do
|
|
delete settings_profile_path(user_id: @admin)
|
|
end
|
|
|
|
assert_redirected_to settings_profile_path
|
|
assert_equal I18n.t("settings.profiles.destroy.cannot_remove_self"), flash[:alert]
|
|
assert User.find(@admin.id)
|
|
end
|
|
|
|
test "non-admin cannot remove members" do
|
|
sign_in @member
|
|
assert_no_difference("User.count") do
|
|
delete settings_profile_path(user_id: @admin)
|
|
end
|
|
|
|
assert_redirected_to settings_profile_path
|
|
assert_equal I18n.t("settings.profiles.destroy.not_authorized"), flash[:alert]
|
|
assert User.find(@admin.id)
|
|
end
|
|
|
|
test "admin removing a family member also destroys their invitation" do
|
|
# Create an invitation for the member
|
|
invitation = @admin.family.invitations.create!(
|
|
email: @member.email,
|
|
role: "member",
|
|
inviter: @admin
|
|
)
|
|
|
|
sign_in @admin
|
|
|
|
assert_difference [ "User.count", "Invitation.count" ], -1 do
|
|
delete settings_profile_path(user_id: @member)
|
|
end
|
|
|
|
assert_redirected_to settings_profile_path
|
|
assert_equal I18n.t("settings.profiles.destroy.member_removed"), flash[:notice]
|
|
assert_raises(ActiveRecord::RecordNotFound) { User.find(@member.id) }
|
|
assert_raises(ActiveRecord::RecordNotFound) { Invitation.find(invitation.id) }
|
|
end
|
|
end
|