1 require File.dirname(__FILE__) + '/../spec_helper'
2 require File.dirname(__FILE__) + '/oauth_controller_spec_helper'
3 require 'oauth/client/action_controller_request'
5 describe OauthClientsController, "index" do
6 include OAuthControllerSpecHelper
8 login_as_application_owner
15 it "should be successful" do
17 response.should be_success
20 it "should query current_users client applications" do
21 @user.should_receive(:client_applications).and_return(@client_applications)
25 it "should assign client_applications" do
27 assigns[:client_applications].should equal(@client_applications)
30 it "should render index template" do
32 response.should render_template('index')
36 describe OauthClientsController, "show" do
37 include OAuthControllerSpecHelper
39 login_as_application_owner
46 it "should be successful" do
48 response.should be_success
51 it "should query current_users client applications" do
52 @user.should_receive(:client_applications).and_return(@client_applications)
53 @client_applications.should_receive(:find).with('3').and_return(@client_application)
57 it "should assign client_applications" do
59 assigns[:client_application].should equal(@client_application)
62 it "should render show template" do
64 response.should render_template('show')
69 describe OauthClientsController, "new" do
70 include OAuthControllerSpecHelper
72 login_as_application_owner
73 ClientApplication.stub!(:new).and_return(@client_application)
80 it "should be successful" do
82 response.should be_success
85 it "should assign client_applications" do
87 assigns[:client_application].should equal(@client_application)
90 it "should render show template" do
92 response.should render_template('new')
97 describe OauthClientsController, "edit" do
98 include OAuthControllerSpecHelper
100 login_as_application_owner
104 get :edit, :id => '3'
107 it "should be successful" do
109 response.should be_success
112 it "should query current_users client applications" do
113 @user.should_receive(:client_applications).and_return(@client_applications)
114 @client_applications.should_receive(:find).with('3').and_return(@client_application)
118 it "should assign client_applications" do
120 assigns[:client_application].should equal(@client_application)
123 it "should render edit template" do
125 response.should render_template('edit')
130 describe OauthClientsController, "create" do
131 include OAuthControllerSpecHelper
134 login_as_application_owner
135 @client_applications.stub!(:build).and_return(@client_application)
136 @client_application.stub!(:save).and_return(true)
140 @client_application.should_receive(:save).and_return(true)
141 post :create, 'client_application'=>{'name' => 'my site'}
145 @client_application.should_receive(:save).and_return(false)
146 post :create, :client_application=>{:name => 'my site'}
149 it "should query current_users client applications" do
150 @client_applications.should_receive(:build).and_return(@client_application)
154 it "should redirect to new client_application" do
156 response.should be_redirect
157 response.should redirect_to(:action => "show", :id => @client_application.id)
160 it "should assign client_applications" do
162 assigns[:client_application].should equal(@client_application)
165 it "should render show template" do
167 response.should render_template('new')
171 describe OauthClientsController, "destroy" do
172 include OAuthControllerSpecHelper
174 login_as_application_owner
175 @client_application.stub!(:destroy)
179 delete :destroy, :id => '3'
182 it "should query current_users client applications" do
183 @user.should_receive(:client_applications).and_return(@client_applications)
184 @client_applications.should_receive(:find).with('3').and_return(@client_application)
188 it "should destroy client applications" do
189 @client_application.should_receive(:destroy)
193 it "should redirect to list" do
195 response.should be_redirect
196 response.should redirect_to(:action => 'index')
201 describe OauthClientsController, "update" do
202 include OAuthControllerSpecHelper
205 login_as_application_owner
209 @client_application.should_receive(:update_attributes).and_return(true)
210 put :update, :id => '1', 'client_application'=>{'name' => 'my site'}
213 def do_invalid_update
214 @client_application.should_receive(:update_attributes).and_return(false)
215 put :update, :id => '1', 'client_application'=>{'name' => 'my site'}
218 it "should query current_users client applications" do
219 @user.should_receive(:client_applications).and_return(@client_applications)
220 @client_applications.should_receive(:find).with('1').and_return(@client_application)
224 it "should redirect to new client_application" do
226 response.should be_redirect
227 response.should redirect_to(:action => "show", :id => @client_application.id)
230 it "should assign client_applications" do
232 assigns[:client_application].should equal(@client_application)
235 it "should render show template" do
237 response.should render_template('edit')