Skip to content

Commit

Permalink
Changed up when not authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
amanelis committed Jan 24, 2013
1 parent 5409535 commit 2ad13e5
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions spec/controllers/apis_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
require "spec_helper"

describe ApisController do
include Devise::TestHelpers

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
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
Expand Down

0 comments on commit 2ad13e5

Please sign in to comment.