Sha256: 7dc459177870f8fccf0c4d6f2921262336fbf32196519411654a08886d6a873e

Contents?: true

Size: 1007 Bytes

Versions: 21

Compression:

Stored size: 1007 Bytes

Contents

# encoding: utf-8
require 'spec_helper'
require 'htmlentities'

ActionDispatch::Flash::FlashHash.class_eval do
  def discard?(key); @used.include?(key); end
  def keep?(key); !discard?(key); end
end

describe FlashController do
  it "should display flash message on redirect" do
    post :redirect, type: :notice, message: 'Glow!'

    flash[:notice].should be == 'Glow!'
    flash.keep?(:notice).should be true
  end

  it "should display flash message on xhr" do 
    xhr :get, :ajax, type: :notice, message: 'Glow!'

    flash[:notice].should be == 'Glow!'
    flash.discard?(:notice).should be true

    @response.headers['X-Message-Type'].should be == 'notice'
    HTMLEntities.new.decode(@response.headers['X-Message']).should be == 'Glow!'
  end

  it "should handle unicode on xhr" do
    xhr :get, :ajax, type: :notice, message: 'utf8: ✓'
    @response.headers['X-Message-Type'].should be == 'notice'
    HTMLEntities.new.decode(@response.headers['X-Message']).should be == 'utf8: ✓'
  end
end

Version data entries

21 entries across 10 versions & 1 rubygems

Version Path
glow-0.0.11 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.11 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.11 test/rails32/spec/controllers/flash_controller_spec.rb
glow-0.0.10 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.10 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.10 test/rails32/spec/controllers/flash_controller_spec.rb
glow-0.0.9 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.9 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.8 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.8 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.7 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.7 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.6 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.6 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.5 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.5 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.4 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.4 test/rails31/spec/controllers/flash_controller_spec.rb
glow-0.0.3 test/rails3/spec/controllers/flash_controller_spec.rb
glow-0.0.3 test/rails31/spec/controllers/flash_controller_spec.rb