| @@ -15,7 +15,7 @@ class ApplicationController < ActionController::Base | ||
| 15 | 15 | end | 
| 16 | 16 |  | 
| 17 | 17 | def authenticate_admin! | 
| 18 | - redirect_to(root_path, alert: 'Admin access required to view that page.') unless current_user && current_user.admin | |
| 18 | + redirect_to(root_path, alert: 'Admin access required to view that page.') unless current_user && current_user.admin? | |
| 19 | 19 | end | 
| 20 | 20 |  | 
| 21 | 21 | def upgrade_warning | 
| @@ -25,6 +25,7 @@ class ApplicationController < ActionController::Base | ||
| 25 | 25 | end | 
| 26 | 26 |  | 
| 27 | 27 | private | 
| 28 | + | |
| 28 | 29 | def twitter_oauth_check | 
| 29 | 30 | if ENV['TWITTER_OAUTH_KEY'].blank? || ENV['TWITTER_OAUTH_SECRET'].blank? | 
| 30 | 31 |        if @twitter_agent = current_user.agents.where("type like 'Agents::Twitter%'").first | 
| @@ -39,5 +40,4 @@ class ApplicationController < ActionController::Base | ||
| 39 | 40 | @basecamp_agent = current_user.agents.where(type: 'Agents::BasecampAgent').first | 
| 40 | 41 | end | 
| 41 | 42 | end | 
| 42 | - | |
| 43 | 43 | end | 
| @@ -38,8 +38,4 @@ module ApplicationHelper | ||
| 38 | 38 | link_to 'No', agent_path(agent, tab: (agent.recent_error_logs? ? 'logs' : 'details')), class: 'label label-danger' | 
| 39 | 39 | end | 
| 40 | 40 | end | 
| 41 | - | |
| 42 | - def user_is_admin? | |
| 43 | - current_user && current_user.admin == true | |
| 44 | - end | |
| 45 | 41 | end | 
| @@ -10,10 +10,13 @@ describe JobsController do | ||
| 10 | 10 | end | 
| 11 | 11 |  | 
| 12 | 12 | it "does not allow normal users" do | 
| 13 | + users(:bob).should_not be_admin | |
| 13 | 14 | sign_in users(:bob) | 
| 14 | 15 | get(:index).should redirect_to(root_path) | 
| 15 | 16 | end | 
| 16 | - it "returns all jobs", focus: true do | |
| 17 | + | |
| 18 | + it "returns all jobs" do | |
| 19 | + users(:jane).should be_admin | |
| 17 | 20 | sign_in users(:jane) | 
| 18 | 21 | get :index | 
| 19 | 22 | assigns(:jobs).length.should == 2 |