Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added specs.

  • Loading branch information...
commit f0ca4d9c9fd8140071fa48908fbe2ea97bee58f5 1 parent 9429c9b
@tylerhunt authored
Showing with 57 additions and 0 deletions.
  1. +47 −0 spec/comeback_spec.rb
  2. +10 −0 spec/spec_helper.rb
View
47 spec/comeback_spec.rb
@@ -0,0 +1,47 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "Comeback" do
+ before(:each) do
+ @comeback_controller = Class.new(ActionController::Base).class_eval do
+ include ActionController::TestProcess
+ end
+
+ @request = mock("request")
+ @request.stub!(:env).and_return({ "HTTP_REFERER" => "/referer" })
+ @request.stub!(:url).and_return("/private")
+
+ @controller = @comeback_controller.new
+ @controller.stub!(:request).and_return(@request)
+ @controller.stub!(:session).and_return({})
+ end
+
+ describe "session key" do
+ it "should default to :comeback_to" do
+ @comeback_controller.comeback_session_key.should == :comeback_to
+ end
+
+ it "should be allowed to be overridden" do
+ @comeback_controller.comeback_session_key = :return_to
+ @comeback_controller.comeback_session_key.should == :return_to
+ end
+ end
+
+ describe "#store_location" do
+ it "should store the current location" do
+ @controller.store_location
+ @controller.session[:comeback_to].should == "/private"
+ end
+
+ it "should store the specified location" do
+ @controller.store_location("/other")
+ @controller.session[:comeback_to].should == "/other"
+ end
+ end
+
+ describe "#store_referer" do
+ it "should store the referer" do
+ @controller.store_referer
+ @controller.session[:comeback_to].should == "/referer"
+ end
+ end
+end
View
10 spec/spec_helper.rb
@@ -0,0 +1,10 @@
+require 'rubygems'
+
+gem 'activerecord'
+require 'active_record'
+
+gem 'actionpack'
+require 'action_controller'
+require 'action_controller/test_process'
+
+require 'init'
Please sign in to comment.
Something went wrong with that request. Please try again.