Skip to content

Commit a8a9442

Browse files
committed
Slight modification to how the api controller spec is structured
1 parent 4d81157 commit a8a9442

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

app/controllers/apis_controller.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class ApisController < ApplicationController
2-
32
before_filter :authenticate_user!
43

54
def active_users
@@ -13,4 +12,4 @@ def me
1312
format.json { render :json => current_user }
1413
end
1514
end
16-
end
15+
end
+16-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
require "spec_helper"
22

33
describe ApisController do
4-
5-
before :each do
6-
@user = FactoryGirl.create(:user)
7-
request.env['warden'].stub :authenticate! => @user
8-
controller.stub :current_user => @user
9-
end
10-
11-
12-
describe "active_users" do
13-
it "should return json" do
14-
get :active_users, :format => :json
15-
ActiveUsers.stub!(:all).and_return([])
16-
JSON(response.body).should be_kind_of(Array)
4+
describe "#active_users" do
5+
before do
6+
@user = FactoryGirl.create(:user)
7+
end
8+
context "when a user is authenticated" do
9+
before do
10+
request.env['warden'].stub :authenticate! => @user
11+
controller.stub :current_user => @user
12+
get :active_users, :format => :json
13+
end
14+
15+
it "should return json" do
16+
ActiveUsers.stub!(:all).and_return([])
17+
JSON(response.body).should be_kind_of(Array)
18+
end
1719
end
1820
end
19-
end
21+
end

0 commit comments

Comments
 (0)