Browse Source
* Update devise to return a 422 on token error * Update view to display formatted error * Add unit testpull/237/head
baarkerlounger
3 years ago
committed by
GitHub
8 changed files with 78 additions and 32 deletions
@ -0,0 +1,11 @@
|
||||
class ErrorSummaryFullMessagesPresenter |
||||
def initialize(error_messages) |
||||
@error_messages = error_messages |
||||
end |
||||
|
||||
def formatted_error_messages |
||||
@error_messages.map do |attribute, messages| |
||||
[attribute, [attribute.to_s.humanize, messages.first].join(" ")] |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,11 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe ErrorSummaryFullMessagesPresenter do |
||||
let(:error_messages) { { reset_password_token: %w[expired] } } |
||||
let(:formatted_error_messages) { [[:reset_password_token, "Reset password token expired"]] } |
||||
subject { described_class.new(error_messages) } |
||||
|
||||
it "formats messages to include the attribute name" do |
||||
expect(subject.formatted_error_messages).to eq(formatted_error_messages) |
||||
end |
||||
end |
Loading…
Reference in new issue