Sha256: 443f191a9eb0d6a716a49e336e16bd7f3650fc6bc659daaaacb5e3bdae7baeba

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe UserSessionsController do

  before(:each) do
    @user = mock("User")
    @user.stubs(:can_be_superuser?).returns true
    @user2 = mock("User")
    @user2.stubs(:can_be_superuser?).returns false
  end
  
  it "should allow for toggling on and off session[:superuser_mode]" do
    controller.stubs(:current_user).returns(@user)
    request.env["HTTP_REFERER"] = ""
    get :superuser
    session[:superuser_mode].should be_true
    get :superuser
    session[:superuser_mode].should be_nil
  end
  
  it "should not allow superuser_mode to be set in session if current_user is not a superuser" do
    controller.stubs(:current_user).returns(@user2)
    request.env["HTTP_REFERER"] = ""
    get :superuser
    session[:superuser_mode].should be_nil
  end
  
  it "should redirect to the referer" do
    controller.stubs(:current_user).returns(@user)
    request.env["HTTP_REFERER"] = hydra_file_assets_path
    get :superuser
    response.should redirect_to(hydra_file_assets_path)
  end
  
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hydra-head-4.1.3 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.1.2 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.1.1 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.1.0 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.3 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.2 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.1 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.0 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.0.rc6 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.0.rc5 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.0.rc4 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.0.rc3 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-4.0.0.rc2 test_support/spec/controllers/user_sessions_controller_spec.rb