Sha256: ec16e0062ffec46eea88ffb1e921c0a8f3a0072f7b38ffc993fe4cda95b666cb

Contents?: true

Size: 938 Bytes

Versions: 2

Compression:

Stored size: 938 Bytes

Contents

require File.dirname(__FILE__) + '/../test_helper'

# open up ApplicationController and add public method for testing
class ApplicationController < ActionController::Base
  def test
    # assign current_user to @user so we can test value after before, after and around filters
    @user_from_active_record_base = ActiveRecord::Base.current_user
    render :text => '1, 2. 1, 2. This is just a test.'
  end
end


class ApplicationControllerTest < ActionController::TestCase
  
  context "with a current_user" do
    setup do
      @user = 'my user'
      ApplicationController.any_instance.stubs(:current_user).returns(@user)
    end
    
    context "GET to test" do
      setup do
        get :test
      end
      should_assign_to :user_from_active_record_base
      should "change ActiveRecord::Base.current_user to current user" do
        assert_equal @user, assigns(:user_from_active_record_base)
      end
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gsterndale-warrant-0.2.0 test/rails_root/test/functional/application_controller_test.rb
gsterndale-warrant-0.3.0 test/rails_root/test/functional/application_controller_test.rb