Skip to content

Commit

Permalink
Fix: Phantom timeout flash notice.
Browse files Browse the repository at this point in the history
Because
- This is a bug with devise - heartcombo/devise#1777
- When you are timed out, a flash will appear with "true" as the message

This commit
- Do not render the flash component if the type is "timedout"
  • Loading branch information
KevinMulhern committed Jun 15, 2024
1 parent 7404068 commit 6c49967
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/components/alerts/flash_component.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
class Alerts::FlashComponent < ApplicationComponent
DISSALLOWED_TYPES = %i[timedout].freeze

def initialize(type:, message:)
@type = type.to_sym
@message = message
end

def render?
DISSALLOWED_TYPES.exclude?(type)
end

def icon_path
{
alert: 'icons/exclamation-circle-solid.svg',
notice: 'icons/checkmark-circle-solid.svg',
timedout: 'icons/exclamation-circle-solid.svg'
}.fetch(type)
end

Expand Down
8 changes: 8 additions & 0 deletions spec/components/alerts/flash_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@
expect(page).to have_content('Success!')
end
end

context 'when the type is dissallowed' do
it 'does not render the flash' do
component = described_class.new(type: 'timedout', message: 'Timed out')

expect(render_inline(component).inner_html).to eq('')
end
end
end

0 comments on commit 6c49967

Please sign in to comment.