diff --git a/spec/controllers/apis_controller_spec.rb b/spec/controllers/apis_controller_spec.rb index 8556f39a..757ffab5 100644 --- a/spec/controllers/apis_controller_spec.rb +++ b/spec/controllers/apis_controller_spec.rb @@ -1,6 +1,8 @@ require "spec_helper" describe ApisController do + include Devise::TestHelpers + describe "#active_users" do before do @user = FactoryGirl.create(:user) @@ -8,14 +10,23 @@ context "when a user is authenticated" do before do - request.env['warden'].stub :authenticate! => @user - controller.stub :current_user => @user + sign_in @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) + expect(JSON(response.body)).to be_kind_of(Array) + end + end + + context "when a user is NOT authenticated" do + before do + get :active_users, :format => :json + end + + it "should not render any data or anything other than a 401" do + expect(response.status).to eq(401) end end end