Sha256: ce6cc28de194faa149324197e12411a03bacf8a8468a90151f738c7d822db8fc
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' describe DummyController do DummyController.class_eval do before_filter :current_subject end let(:client) { double :client } let(:user) { double :user, language: :en } let(:token) { stub :token, client: client } let(:find) { stub :find, { find_by_token: token } } before do controller.request.env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN] = token end describe "with user token" do before do token.stub(:user).and_return(user) end it "should have user as current_user" do get :index assigns(:current_user).should be_present assigns(:current_user).should eq(user) end it "should have client as current_subject" do get :index assigns(:current_subject).should be_present assigns(:current_subject).should eq(client) end end describe "with client token" do before do token.stub(:user).and_return(nil) end it "should have client as current_subject" do get :index assigns(:current_subject).should be_present assigns(:current_subject).should eq(client) end end end
Version data entries
4 entries across 4 versions & 2 rubygems