diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9d598480c..137705df4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -52,4 +52,8 @@ class ApplicationController < ActionController::Base end end + def logged_into_fb? + @logged_in + end + end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 205156a89..b4bc9fe94 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -12,8 +12,9 @@ class StatusMessagesController < ApplicationController params[:status_message][:to] = params[:aspect_ids] data = clean_hash params[:status_message] + - if @logged_in && params[:status_message][:public] == 'true' + if logged_into_fb? && params[:status_message][:public] == '1' id = 'me' type = 'feed' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7aee9849e..57b9c33f6 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,10 +14,11 @@ = stylesheet_link_tag "blueprint/print", :media => 'print' = stylesheet_link_tag "application", "ui" - = stylesheet_link_tag "/../javascripts/fancybox/jquery.fancybox-1.3.1" = stylesheet_link_tag "fileuploader" - + - if current_user + %link{:rel => "alternate", :href => "#{current_user.public_url}", :type => "application/atom+xml", :title => "Public Diaspora Feed for #{current_user.real_name}"} + /= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" = javascript_include_tag 'jquery-1.4.2.min', 'rails' = javascript_include_tag 'jquery.infieldlabel', 'jquery.cycle/jquery.cycle.min.js' 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 +