From ccd92fb8507f927b24c2893f20d834a74499b055 Mon Sep 17 00:00:00 2001 From: Raphael <raphael@joindiaspora.com> Date: Tue, 2 Nov 2010 16:55:16 -0700 Subject: [PATCH] make requests controller spec a little clearer --- spec/controllers/requests_controller_spec.rb | 84 +++++++++++--------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index 636d6e2b98..4a772c5a33 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -13,48 +13,54 @@ describe RequestsController do @user.aspects.create(:name => "lame-os") end - it "should not error out when requesting to be friends with yourself" do - put("create", "request" => { - "destination_url" => @user.diaspora_handle, - "aspect_id" => @user.aspects[0].id - } - ) - response.should redirect_to aspects_manage_path - end - - it "should not error out when requesting an invalid identity" do - put("create", "request" => { - "destination_url" => "not_a_@valid_email", - "aspect_id" => @user.aspects[0].id - } - ) - response.should redirect_to aspects_manage_path - end + describe '#create' do + it "redirects when requesting to be friends with yourself" do + put("create", "request" => { + "destination_url" => @user.diaspora_handle, + "aspect_id" => @user.aspects[0].id + } + ) + response.should redirect_to aspects_manage_path + end - it "should not error out when requesting an invalid identity with a port number" do - put("create", "request" => { - "destination_url" => "johndoe@email.com:3000", - "aspect_id" => @user.aspects[0].id - } - ) - response.should redirect_to aspects_manage_path - end + it "flashes and redirects when requesting an invalid identity" do + put("create", "request" => { + "destination_url" => "not_a_@valid_email", + "aspect_id" => @user.aspects[0].id + } + ) + flash[:error].should_not be_blank + response.should redirect_to aspects_manage_path + end - it "should not error out when requesting an identity from an invalid server" do - stub_request(:get, /notadiasporaserver\.com/).to_raise(Errno::ETIMEDOUT) - put("create", "request" => { - "destination_url" => "johndoe@notadiasporaserver.com", - "aspect_id" => @user.aspects[0].id - } - ) - response.should redirect_to aspects_manage_path - end + it "flashes and redirects when requesting an invalid identity with a port number" do + put("create", "request" => { + "destination_url" => "johndoe@email.com:3000", + "aspect_id" => @user.aspects[0].id + } + ) + flash[:error].should_not be_blank + response.should redirect_to aspects_manage_path + end - it 'should redirect to the page which you called it from ' do - pending "i need to figure out how to do this" - end + it "redirects when requesting an identity from an invalid server" do + stub_request(:get, /notadiasporaserver\.com/).to_raise(Errno::ETIMEDOUT) + put("create", "request" => { + "destination_url" => "johndoe@notadiasporaserver.com", + "aspect_id" => @user.aspects[0].id + } + ) + response.should redirect_to aspects_manage_path + end - it 'should not blow up if there is a problem mid way thru the webfinger process' do - pending "i need to do this tomorrow" + it 'should redirect to the page which you called it from ' do + pending "This controller should probably redirect to :back" + put("create", "request" => { + "destination_url" => "johndoe@notadiasporaserver.com", + "aspect_id" => @user.aspects[0].id + } + ) + response.should redirect_to(:back) + end end end -- GitLab