From f83bddadc5508dd3532c39fb3c7829038305f423 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 15 Oct 2010 16:19:07 -0700 Subject: [PATCH] forgot to add the test; and cleaned up the explain partial --- app/views/shared/_public_explain.haml | 4 +- .../status_message_controller_spec.rb | 37 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 spec/controllers/status_message_controller_spec.rb diff --git a/app/views/shared/_public_explain.haml b/app/views/shared/_public_explain.haml index 775051405..b1d2048b2 100644 --- a/app/views/shared/_public_explain.haml +++ b/app/views/shared/_public_explain.haml @@ -1,12 +1,12 @@ %h3 You are about to post a public message! %p Public messages will be available for others outside of Diaspora to see. - + %br + %br - if @logged_in = connected_fb_as(@access_token) - else = link_to "Connect to Facebook", @fb_access_url - %br %br = link_to "OK", '#', :class => "button", :onClick => '$.fancybox.close();' diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb new file mode 100644 index 000000000..8df112285 --- /dev/null +++ b/spec/controllers/status_message_controller_spec.rb @@ -0,0 +1,37 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe StatusMessagesController do + render_views + before do + @user = Factory.create(:user) + @aspect = @user.aspect(:name => "lame-os") + @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' + sign_in :user, @user + end + + describe '#create' do + let(:status_message_hash) {{"aspect_ids" =>"#{@aspect.id.to_s}", "status_message"=>{"public"=>"1", "message"=>"facebook, is that you?"}}} + + before do + @controller.stub!(:logged_into_fb?).and_return(true) + end + + it 'should post to facebook when public is set' do + my_mock = mock("http") + my_mock.stub!(:post) + EventMachine::HttpRequest.should_receive(:new).and_return(my_mock) + post :create, status_message_hash + end + + it 'should not post to facebook when public in not set' do + status_message_hash['status_message']['public'] = '0' + EventMachine::HttpRequest.should_not_receive(:new) + post :create, status_message_hash + end + end +end +