spec/rescue_action_spec.rb in flail-0.0.7 vs spec/rescue_action_spec.rb in flail-0.1.0

- old
+ new

@@ -47,7 +47,41 @@ user = OpenStruct.new(:attributes => {:id => 1, :login => 'jlong'}) FlailArmory.process_action_with_error(:user => user) FlailArmory.payload['user'].should == {'id' => 1, 'login' => 'jlong'} end + + it "should call session.to_hash if available" do + hash_data = {:key => :value} + + session = ActionController::TestSession.new + stub(ActionController::TestSession).new { session } + stub(session).to_hash { hash_data } + + FlailArmory.process_action_with_error + + session.should have_received.to_hash + session.should_not have_received.data + FlailArmory.payload.should_not be_nil + end + + it "should call session.to_hash if available" do + hash_data = {:key => :value} + + session = ActionController::TestSession.new + stub(ActionController::TestSession).new { session } + stub(session).data { hash_data } + + if session.respond_to?(:to_hash) + class << session + undef :to_hash + end + end + + FlailArmory.process_action_with_error + + session.should_not have_received.to_hash + session.should have_received.data + FlailArmory.payload.should_not be_nil + end end end