require 'spec_helper'

# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the Controller, code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator.  If you are using any extension libraries to generate different
# Controller,code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails.  There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec.  Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.

describe AdminController, controllers: true do
#TODO
context 'being_admin' do  
  before(:each) do
    @user = Factory(:user_vish)
  end

  after(:each) do
    @user.destroy
  end

  it 'index_for' do
    @user.make_me_admin
    sign_in @user
    get :index
    assert_response :success
  end

  it 'closed_reports' do
    pending('Doesnt work make me admin')
    sign_in @user
    get :closed_reports
    response.should redirect_to(:home)
  end


  it 'users' do
    pending('Doesnt work make me admin')
    sign_in @user
    @user.make_me_admin
    get :users
    response.should redirect_to("/admin/users")
  end
end

context 'not_being_admin' do 
 before(:each) do
    @user = Factory(:user_vish)
  end

  it 'index_for?' do
    sign_in @user
    get :index
    response.should redirect_to(:home)
  end

  it 'closed_reports?' do
    sign_in @user
    get :closed_reports
    response.should redirect_to(:home)
  end


  it 'users?' do 
    sign_in @user
    get :users
    response.should redirect_to(:home)
  end
end

end
