Fix null Crowdin username handling

What does this MR do and why?

Fixes an issue where submitting a null Crowdin username caused the API to return a 500 Internal Server Error.

The controller previously called .strip directly on the submitted value, raising a NoMethodError when the value was nil.

This MR uses safe navigation (&.strip) to handle null values safely and allows users to clear their existing Crowdin username.

Adds a request spec covering the JSON null case and verifying that the existing username is cleared successfully.

Closes #960 (closed)

Design and production fit

  • Preserves existing whitespace trimming behavior for non-null usernames.
  • Handles null values without raising an exception.
  • Allows an existing Crowdin username to be cleared.
  • Preserves existing authorization checks and API response behavior.

Screenshots or screen recordings

Not applicable. This is a backend API change.

Before

Submitting null caused a 500 Internal Server Error.

After

Submitting null returns HTTP 200 and clears the stored Crowdin username.

Validation steps

  • Added a request spec for submitting crowdin_username: nil as JSON.
  • The spec verifies the successful response and confirms the persisted username is nil.
  • git diff --check passes.
  • Automated RSpec execution remains pending.

/cc @leetickett-gitlab

Merge request reports

Loading
Loading