-
-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mutate session when injecting clearance to fix flash messages
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
class FlashesController < ActionController::Base | ||
include Clearance::Authentication | ||
|
||
def set_flash | ||
flash[:notice] = params[:message] | ||
redirect_to view_flash_url | ||
end | ||
|
||
def view_flash | ||
render :text => "<html><body>#{flash[:notice]}</body></html>" | ||
end | ||
end | ||
|
||
describe FlashesController do | ||
before do | ||
Rails.application.routes.draw do | ||
match "set_flash" => "flashes#set_flash" | ||
match "view_flash" => "flashes#view_flash" | ||
end | ||
end | ||
|
||
after do | ||
Rails.application.reload_routes! | ||
end | ||
|
||
it "sets and views a flash" do | ||
visit "/set_flash?message=hello" | ||
page.should have_content("hello") | ||
end | ||
end |