Sha256: 703951bf62f8beafdbc9f750f1ac8088dc7c6214687d48e7632c5e7b28635155

Contents?: true

Size: 1.04 KB

Versions: 28

Compression:

Stored size: 1.04 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"] = file_assets_path
    get :superuser
    response.should redirect_to(file_assets_path)
  end
  
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
hydra-head-3.3.0 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.2.2 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.2.1 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.2.0 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.2.0.pre3 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.2.0.pre2 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.2.0.pre1 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.5 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.4 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.3 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.2 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.1 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.0 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.0.rc2 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.0.rc1 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.0.pre5 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.0.pre4 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.0.pre3 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.0.1 test_support/spec/controllers/user_sessions_controller_spec.rb
hydra-head-3.1.0.pre2 test_support/spec/controllers/user_sessions_controller_spec.rb