From a8a944262c6f5e088b9890982377025b82fa2f20 Mon Sep 17 00:00:00 2001 From: Alex Manelis Date: Wed, 23 Jan 2013 19:19:06 -0800 Subject: [PATCH] Slight modification to how the api controller spec is structured --- app/controllers/apis_controller.rb | 3 +-- spec/controllers/apis_controller_spec.rb | 30 +++++++++++++----------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/controllers/apis_controller.rb b/app/controllers/apis_controller.rb index 7ac42573..54674349 100644 --- a/app/controllers/apis_controller.rb +++ b/app/controllers/apis_controller.rb @@ -1,5 +1,4 @@ class ApisController < ApplicationController - before_filter :authenticate_user! def active_users @@ -13,4 +12,4 @@ def me format.json { render :json => current_user } end end -end +end \ No newline at end of file diff --git a/spec/controllers/apis_controller_spec.rb b/spec/controllers/apis_controller_spec.rb index 726b83b9..516c5261 100644 --- a/spec/controllers/apis_controller_spec.rb +++ b/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 \ No newline at end of file