Merge branch 'Ruxton-develop' into develop

This commit is contained in:
Jonne Haß 2013-07-31 14:26:27 +02:00
commit d5fbeff03b
3 changed files with 16 additions and 13 deletions

View file

@ -14,6 +14,7 @@
* Fix missing timeago tooltip in conversations [#4257](https://github.com/diaspora/diaspora/issues/4257) * Fix missing timeago tooltip in conversations [#4257](https://github.com/diaspora/diaspora/issues/4257)
* Fix link to background image [#4289](https://github.com/diaspora/diaspora/pull/4289) * Fix link to background image [#4289](https://github.com/diaspora/diaspora/pull/4289)
* Fix Facebox icons 404s when called from Backbone * Fix Facebox icons 404s when called from Backbone
* Fix deleting a post from Facebook [#4290](https://github.com/diaspora/diaspora/pull/4290)
## Features ## Features
* Admin: add option to find users under 13 (COPPA) [#4252](https://github.com/diaspora/diaspora/pull/4252) * Admin: add option to find users under 13 (COPPA) [#4252](https://github.com/diaspora/diaspora/pull/4252)

View file

@ -34,7 +34,7 @@ class Services::Facebook < Service
end end
def delete_post(post) def delete_post(post)
if post.present? && post.facebbook_id.present? if post.present? && post.facebook_id.present?
Rails.logger.debug("event=delete_from_service type=facebook sender_id=#{self.user_id}") Rails.logger.debug("event=delete_from_service type=facebook sender_id=#{self.user_id}")
delete_from_facebook("https://graph.facebook.com/#{post.facebook_id}/", {:access_token => self.access_token}) delete_from_facebook("https://graph.facebook.com/#{post.facebook_id}/", {:access_token => self.access_token})
end end

View file

@ -4,7 +4,7 @@ describe Services::Facebook do
before do before do
@user = alice @user = alice
@post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id, :public =>true, :facebook_id => "23456", :photos => []) @post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id, :public =>true, :photos => [])
@service = Services::Facebook.new(:access_token => "yeah") @service = Services::Facebook.new(:access_token => "yeah")
@user.services << @service @user.services << @service
end end
@ -18,19 +18,19 @@ describe Services::Facebook do
it 'swallows exception raised by facebook always being down' do it 'swallows exception raised by facebook always being down' do
pending "temporarily disabled to figure out while some requests are failing" pending "temporarily disabled to figure out while some requests are failing"
stub_request(:post,"https://graph.facebook.com/me/feed"). stub_request(:post,"https://graph.facebook.com/me/feed").
to_raise(StandardError) to_raise(StandardError)
@service.post(@post) @service.post(@post)
end end
it 'removes text formatting markdown from post text' do it 'removes text formatting markdown from post text' do
message = "Text with some **bolded** and _italic_ parts." message = "Text with some **bolded** and _italic_ parts."
post = stub(:text => message, :photos => []) post = stub(:text => message, :photos => [])
post_params = @service.create_post_params(post) post_params = @service.create_post_params(post)
post_params[:message].should match "Text with some bolded and italic parts." post_params[:message].should match "Text with some bolded and italic parts."
end end
it 'does not add post link when no photos' do it 'does not add post link when no photos' do
message = "Text with some **bolded** and _italic_ parts." message = "Text with some **bolded** and _italic_ parts."
post = stub(:text => message, :photos => []) post = stub(:text => message, :photos => [])
@ -44,9 +44,9 @@ describe Services::Facebook do
@service.post(@post) @service.post(@post)
@post.facebook_id.should match "12345" @post.facebook_id.should match "12345"
end end
end end
describe "with photo" do describe "with photo" do
before do before do
@photos = [alice.build_post(:photo, :pending => true, :user_file=> File.open(photo_fixture_name)), @photos = [alice.build_post(:photo, :pending => true, :user_file=> File.open(photo_fixture_name)),
@ -60,29 +60,31 @@ describe Services::Facebook do
@status_message.save! @status_message.save!
alice.add_to_streams(@status_message, alice.aspects) alice.add_to_streams(@status_message, alice.aspects)
end end
it "should include post url in message with photos" do it "should include post url in message with photos" do
post_params = @service.create_post_params(@status_message) post_params = @service.create_post_params(@status_message)
post_params[:message].should include 'http' post_params[:message].should include 'http'
end end
end end
describe "#profile_photo_url" do describe "#profile_photo_url" do
it 'returns a large profile photo url' do it 'returns a large profile photo url' do
@service.uid = "abc123" @service.uid = "abc123"
@service.access_token = "token123" @service.access_token = "token123"
@service.profile_photo_url.should == @service.profile_photo_url.should ==
"https://graph.facebook.com/abc123/picture?type=large&access_token=token123" "https://graph.facebook.com/abc123/picture?type=large&access_token=token123"
end end
end end
describe '#delete_post' do describe '#delete_post' do
it 'removes a post from facebook' do it 'removes a post from facebook' do
stub_request(:delete, "https://graph.facebook.com/#{@post.facebook_id}/?access_token=#{@service.access_token}"). @post.facebook_id = "2345"
to_return(:status => 200) url="https://graph.facebook.com/#{@post.facebook_id}/"
stub_request(:delete, "#{url}?access_token=#{@service.access_token}").to_return(:status => 200)
@service.should_receive(:delete_from_facebook).with(url, {access_token: @service.access_token})
@service.delete_post(@post.facebook_id) @service.delete_post(@post)
end end
end end
end end