Sha256: 3da4abb27ed2d14866a4b65c4ce15007de1d5b2547bb2f7cb6982e9f22ada9e6

Contents?: true

Size: 1.04 KB

Versions: 34

Compression:

Stored size: 1.04 KB

Contents

require File.expand_path('../test_helper', __FILE__)

# Mock controller used for testing session handling.
class FacebookController < ApplicationController
  authenticates_using_session
  probes_facebook_access_token
  authenticates_using_facebook
  
  def show
    if current_user
      render :text => "User: #{current_user.id}"
    else
      render :text => "No user"
    end
  end
end

class FacebookControllerTest < ActionController::TestCase
  setup do
    @user = users(:john)
    @new_token = 'facebook:new_token|boom'
  end

  test "no facebook token" do
    get :show
    assert_response :success
    assert_nil assigns(:current_user)
  end
  
  test "facebook token for existing user" do
    set_session_current_facebook_token facebook_tokens(:john).access_token
    get :show, {}
    assert_response :success
    assert_equal @user, assigns(:current_user)
  end
  
  test "new facebook token" do    
    set_session_current_facebook_token @new_token
    get :show, {}
    assert_response :success
    assert !(@user == assigns(:current_user))
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
authpwn_rails-0.9.6 test/facebook_controller_test.rb
authpwn_rails-0.9.5 test/facebook_controller_test.rb
authpwn_rails-0.9.4 test/facebook_controller_test.rb
authpwn_rails-0.9.3 test/facebook_controller_test.rb
authpwn_rails-0.9.2 test/facebook_controller_test.rb
authpwn_rails-0.9.1 test/facebook_controller_test.rb
authpwn_rails-0.9.0 test/facebook_controller_test.rb
authpwn_rails-0.8.3 test/facebook_controller_test.rb
authpwn_rails-0.8.2 test/facebook_controller_test.rb
authpwn_rails-0.8.1 test/facebook_controller_test.rb
authpwn_rails-0.8.0 test/facebook_controller_test.rb
authpwn_rails-0.7.5 test/facebook_controller_test.rb
authpwn_rails-0.7.4 test/facebook_controller_test.rb
authpwn_rails-0.7.3 test/facebook_controller_test.rb
authpwn_rails-0.7.2 test/facebook_controller_test.rb
authpwn_rails-0.7.1 test/facebook_controller_test.rb
authpwn_rails-0.7.0 test/facebook_controller_test.rb
authpwn_rails-0.6.0 test/facebook_controller_test.rb
authpwn_rails-0.5.6 test/facebook_controller_test.rb
authpwn_rails-0.5.5 test/facebook_controller_test.rb