Sha256: fcf5118c9fd98352b5425b439ec0d59a9101333a5fb936c305fef5ed0b6557f5

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe UnobtrusiveFlash::ControllerMixin do
  describe '.sanitize_flash' do
    it 'should escape messages that are not html safe' do
      expect(described_class.sanitize_flash({:notice => '<bar>'}, [:notice])).to eq([["notice", '&lt;bar&gt;']])
    end

    it 'should not escape messages that are html safe' do
      expect(described_class.sanitize_flash({:notice => '<bar>'.html_safe}, [:notice])).to eq([["notice", '<bar>']])
    end

    it 'should remove messages that are not whitelisted to be displayed' do
      expect(described_class.sanitize_flash({:timedout => true}, [:notice])).to eq([])
    end
  end

  describe '.append_flash_to_cookie' do
    it 'should create a cookie if there is none' do
      expect(described_class.append_flash_to_cookie(nil, {:baz => 'qux'}, [:baz])).to eq('[["baz","qux"]]')
    end

    it 'should reuse existing cookie' do
      expect(described_class.append_flash_to_cookie('[["foo","bar"]]', {:baz => 'qux'}, [:baz])).to eq('[["foo","bar"],["baz","qux"]]')
    end

    it 'should not insert flash is already in the cookie' do
      expect(described_class.append_flash_to_cookie('[["foo","bar"]]', {:foo => 'bar'}, [:foo])).to eq('[["foo","bar"]]')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unobtrusive_flash-3.3.1 spec/sanitize_flash_spec.rb
unobtrusive_flash-3.3.0 spec/sanitize_flash_spec.rb