Skip to content
This repository
tree: 7ff50be865
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 51 lines (40 sloc) 1.371 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
require 'test_helper'

class ApplicationControllerTest < ActionController::TestCase
  
  include Authlogic::TestCase
  setup :activate_authlogic

  context "getting the current user" do
    context "when a user is logged in" do
      setup do
        UserSession.create(users(:zkim))
        @app_controller = ApplicationController.new
      end
      
      should "return the current user" do
        assert_not_nil @app_controller.send(:current_user_session)
        assert_equal @app_controller.send(:current_user).login, "zkim"
      end
    end
    
    context "when a user is not logged in" do
      setup do
        @app_controller = ApplicationController.new
      end
      
      should "return nil" do
        assert_nil @app_controller.send :current_user_session
        assert_nil @app_controller.send :current_user
      end
    end
    
  end
  
  context "getting recently updated items" do
    setup do
      @app_controller = ApplicationController.new
    end
    
    context "from all libraries" do
      should "give recent updates of the types SeeAlso, Example, Comment" do
        recent = @app_controller.send(:find_recently_updated, 10)
        assert_equal recent.size, 4
        assert recent[0].instance_of? SeeAlso
        assert recent[1].instance_of? Example
        assert recent[2].instance_of? Comment
      end
    end
    
  end
end
Something went wrong with that request. Please try again.