Skip to content

Commit

Permalink
Slight modification to how the api controller spec is structured
Browse files Browse the repository at this point in the history
  • Loading branch information
amanelis committed Jan 24, 2013
1 parent 4d81157 commit a8a9442
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
3 changes: 1 addition & 2 deletions app/controllers/apis_controller.rb
@@ -1,5 +1,4 @@
class ApisController < ApplicationController

before_filter :authenticate_user!

def active_users
Expand All @@ -13,4 +12,4 @@ def me
format.json { render :json => current_user }
end
end
end
end
30 changes: 16 additions & 14 deletions spec/controllers/apis_controller_spec.rb
@@ -1,19 +1,21 @@
require "spec_helper"

describe ApisController do

before :each do
@user = FactoryGirl.create(:user)
request.env['warden'].stub :authenticate! => @user
controller.stub :current_user => @user
end


describe "active_users" do
it "should return json" do
get :active_users, :format => :json
ActiveUsers.stub!(:all).and_return([])
JSON(response.body).should be_kind_of(Array)
describe "#active_users" do
before do
@user = FactoryGirl.create(:user)
end
context "when a user is authenticated" do
before do
request.env['warden'].stub :authenticate! => @user
controller.stub :current_user => @user
get :active_users, :format => :json
end

it "should return json" do
ActiveUsers.stub!(:all).and_return([])
JSON(response.body).should be_kind_of(Array)
end
end
end
end
end

0 comments on commit a8a9442

Please sign in to comment.