Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/lotus/action/flash.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'forwardable'

module Lotus
module Action
# Container useful to transport data with the HTTP session
Expand All @@ -6,6 +8,11 @@ module Action
# @since x.x.x
# @api private
class Flash
extend Forwardable

# Delegate iteration to the underlying data storage
def_delegator :data, :each, :each

# Session key where the data is stored
#
# @since x.x.x
Expand Down
21 changes: 21 additions & 0 deletions test/action/flash_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'test_helper'

describe Lotus::Action::Flash do
let (:flash) { Lotus::Action::Flash.new({},12312) }

it '#each returns Enumerable' do
assert_kind_of Enumerator, flash.each
end

describe 'iteration' do

it '#each yields all flashes to the block' do
flash[:success], flash[:error] = 'Success', 'Error'
accum = []
flash.each { |k, v| accum << { :"#{k}".to_sym => v} }
assert_equal accum, [{success: 'Success'}, {error: 'Error'}]
end

after { flash.clear }
end
end