Skip to content

Commit

Permalink
Update messaging to be Bio (forem#18798)
Browse files Browse the repository at this point in the history
* Update messaging to be Bio

* Update app/validators/profile_validator.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/validators/profile_validator.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/validators/profile_validator.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/validators/profile_validator.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update app/validators/profile_validator.rb

Co-authored-by: Joshua Wehner <[email protected]>

* adding rails translation to profile

* implement base for record error

* fix spec

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Joshua Wehner <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2022
1 parent 3170c06 commit 33295ac
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/validators/profile_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ def validate(record)
# NOTE: The summary is a base profile field, which we add to all new Forem
# instances, so it should be safe to validate. The method itself also guards
# against the field's absence.
record.errors.add(:summary, I18n.t("validators.profile_validator.too_long")) if summary_too_long?(record)
if summary_too_long?(record)
record.errors.add(:base,
message: I18n.t("validators.profile_validator.bio_too_long"))
end

ProfileField.all.each do |field|
attribute = field.attribute_name
Expand Down
2 changes: 1 addition & 1 deletion config/locales/validators/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ en:
existing_published_article_id_validator:
default: must be a valid published Article identifier
profile_validator:
too_long: is too long
bio_too_long: Bio is too long
unique_cross_model_slug_validator:
is_taken: is taken
valid_domain_csv_validator:
Expand Down
2 changes: 1 addition & 1 deletion config/locales/validators/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fr:
existing_published_article_id_validator:
default: must be a valid published Article identifier
profile_validator:
too_long: is too long
bio_too_long: Bio is too long
unique_cross_model_slug_validator:
is_taken: is taken
valid_domain_csv_validator:
Expand Down
2 changes: 1 addition & 1 deletion spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
it "is not valid if the summary is too long and the user is not grandfathered" do
profile.summary = invalid_summary
expect(profile).not_to be_valid
expect(profile.errors_as_sentence).to eq "Summary is too long"
expect(profile.errors_as_sentence).to eq "Bio is too long"
end

it "is valid if the summary is less than the limit" do
Expand Down

0 comments on commit 33295ac

Please sign in to comment.