Merge pull request #487 from cantino/minor_admin_cleanup

remove unused method

Andrew Cantino 10 年之前
父节点
当前提交
b25a3ce9c9
共有 3 个文件被更改,包括 6 次插入7 次删除
  1. 2 2
      app/controllers/application_controller.rb
  2. 0 4
      app/helpers/application_helper.rb
  3. 4 1
      spec/controllers/jobs_controller_spec.rb

+ 2 - 2
app/controllers/application_controller.rb

@@ -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

+ 0 - 4
app/helpers/application_helper.rb

@@ -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

+ 4 - 1
spec/controllers/jobs_controller_spec.rb

@@ -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