From d56800f9e89f9b285c721fe2506728df2bf10895 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 15 Oct 2010 14:53:36 -0700 Subject: [PATCH 1/5] fixing facebook posting --- app/controllers/status_messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 205156a89..74f8a501a 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -13,7 +13,7 @@ class StatusMessagesController < ApplicationController data = clean_hash params[:status_message] - if @logged_in && params[:status_message][:public] == 'true' + if @logged_in && params[:status_message][:public] == '1' id = 'me' type = 'feed' From a0ce9630b1d3c0a607be77667ccbb8eca9865742 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 15 Oct 2010 16:03:02 -0700 Subject: [PATCH 2/5] added test for facebook posting --- app/controllers/application_controller.rb | 4 ++++ app/controllers/status_messages_controller.rb | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 65b57b252..e44ed343a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -51,4 +51,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 74f8a501a..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] == '1' + if logged_into_fb? && params[:status_message][:public] == '1' id = 'me' type = 'feed' From f83bddadc5508dd3532c39fb3c7829038305f423 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 15 Oct 2010 16:19:07 -0700 Subject: [PATCH 3/5] 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 + From ca604ffe5a6354ed053db7b2cf1af8b53d1104ba Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 15 Oct 2010 16:51:37 -0700 Subject: [PATCH 4/5] added public atom discovery link --- app/views/layouts/application.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7aee9849e..16fb1a2b4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -15,9 +15,11 @@ = stylesheet_link_tag "application", "ui" - = stylesheet_link_tag "/../javascripts/fancybox/jquery.fancybox-1.3.1" + = stylesheet_link_tag "/../japvascripts/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' From adbe5f7c38a8ed18824a6afd28e77e4ff08f849f Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 15 Oct 2010 16:54:56 -0700 Subject: [PATCH 5/5] i love foaf --- app/views/layouts/application.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 16fb1a2b4..57b9c33f6 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,8 +14,7 @@ = stylesheet_link_tag "blueprint/print", :media => 'print' = stylesheet_link_tag "application", "ui" - - = stylesheet_link_tag "/../japvascripts/fancybox/jquery.fancybox-1.3.1" + = 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}"}