From 176a33880ff41373607f98a1c873ae045b29640d Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Sat, 31 Dec 2011 14:19:40 -0500 Subject: [PATCH] fix all specs minus one from o_embed_data_spec --- app/helpers/profiles_helper.rb | 38 ------------------- spec/helpers/profiles_helper_spec.rb | 36 ------------------ spec/models/jobs/gather_o_embed_data_spec.rb | 16 +++++--- ...il_mentioned_spec.rb => mentioned_spec.rb} | 0 ...essage_spec.rb => private_message_spec.rb} | 2 +- ...mail_reshared_spec.rb => reshared_spec.rb} | 0 6 files changed, 11 insertions(+), 81 deletions(-) delete mode 100644 app/helpers/profiles_helper.rb delete mode 100644 spec/helpers/profiles_helper_spec.rb rename spec/models/jobs/mail/{mail_mentioned_spec.rb => mentioned_spec.rb} (100%) rename spec/models/jobs/mail/{mail_private_message_spec.rb => private_message_spec.rb} (90%) rename spec/models/jobs/mail/{mail_reshared_spec.rb => reshared_spec.rb} (100%) diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb deleted file mode 100644 index 0ac500733..000000000 --- a/app/helpers/profiles_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2010-2011, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - -module ProfilesHelper - - # Creates a profile field with a checked class if set - # - # @param [Profile, Symbol] Profile and field in question - # @return [String] A span element - def profile_field_tag(profile, field) - klass = field_filled_out?(profile, field) ? 'completed' : '' - klass += " profile_field" - field = case field - when :tag_string - :tags - when :full_name - :name - when :image_url - :photo - else - field - end - content_tag(:span, t(".profile_fields.#{field.to_s}"), :class => klass) - end - - private - - # @param [Profile, Symbol] Profile and field in question - # @return [Boolean] The field in question is set? - def field_filled_out?(profile, field) - if field != :image_url - profile.send("#{field}".to_sym).present? - else - profile.send("#{field}".to_sym) != "/images/user/default.png" - end - end -end diff --git a/spec/helpers/profiles_helper_spec.rb b/spec/helpers/profiles_helper_spec.rb deleted file mode 100644 index 851855367..000000000 --- a/spec/helpers/profiles_helper_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2010-2011, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -require 'spec_helper' - -describe ProfilesHelper do - before do - @profile = Factory(:person).profile - end - - describe '#field_filled_out?' do - it 'returns false if not set' do - field_filled_out?(@profile, :bio).should be_false - end - - it 'returns true if field is set' do - @profile.bio = "abc" - field_filled_out?(@profile, :bio).should be_true - end - - it 'returns false if default profile photo is used' do - field_filled_out?(@profile, :image_url).should be_false - end - - it 'returns true if custom profile photo is set' do - @profile.image_url = "abc.jpg" - field_filled_out?(@profile, :image_url).should be_true - end - end - - describe '#profile_field_tag' do - it 'returns' do - profile_field_tag(@profile, :bio).should_not be_blank - end - end -end diff --git a/spec/models/jobs/gather_o_embed_data_spec.rb b/spec/models/jobs/gather_o_embed_data_spec.rb index 5d95a2ff8..a253bac84 100644 --- a/spec/models/jobs/gather_o_embed_data_spec.rb +++ b/spec/models/jobs/gather_o_embed_data_spec.rb @@ -22,37 +22,41 @@ describe Jobs::GatherOEmbedData do @no_oembed_url = 'http://www.we-do-not-support-oembed.com/index.html' + @status_message = Factory(:status_message) + stub_request(:get, @flickr_oembed_get_request).to_return(:status => 200, :body => @flickr_oembed_data.to_json) stub_request(:get, @no_oembed_url).to_return(:status => 200, :body => 'hello there') end describe '.perform' do it 'requests not data from the internet' do - Jobs::GatherOEmbedData.perform("Look at this! "+@flickr_photo_url) + Jobs::GatherOEmbedData.perform(@status_message.id, @flickr_photo_url) a_request(:get, @flickr_oembed_get_request).should have_been_made end it 'requests not data from the internet only once' do - Jobs::GatherOEmbedData.perform("Look at this! "+@flickr_photo_url) - Jobs::GatherOEmbedData.perform("Look at this! "+@flickr_photo_url) + 2.times do |n| + Jobs::GatherOEmbedData.perform(@status_message.id, @flickr_photo_url) + end a_request(:get, @flickr_oembed_get_request).should have_been_made.times(1) end it 'creates one cache entry' do - Jobs::GatherOEmbedData.perform("Look at this! "+@flickr_photo_url) + Jobs::GatherOEmbedData.perform(@status_message.id, @flickr_photo_url) expected_data = @flickr_oembed_data expected_data['trusted_endpoint_url'] = @flickr_oembed_url OEmbedCache.find_by_url(@flickr_photo_url).data.should == expected_data - Jobs::GatherOEmbedData.perform("Look at this! "+@flickr_photo_url) + Jobs::GatherOEmbedData.perform(@status_message.id, @flickr_photo_url) OEmbedCache.count(:conditions => {:url => @flickr_photo_url}).should == 1 end it 'creates no cache entry for unsupported pages' do - Jobs::GatherOEmbedData.perform("This page is lame! It does not support oEmbed: "+@no_oembed_url) + Jobs::GatherOEmbedData.perform(@status_message.id, @no_oembed_url) + OEmbedCache.find_by_url(@no_oembed_url).should be_nil end end diff --git a/spec/models/jobs/mail/mail_mentioned_spec.rb b/spec/models/jobs/mail/mentioned_spec.rb similarity index 100% rename from spec/models/jobs/mail/mail_mentioned_spec.rb rename to spec/models/jobs/mail/mentioned_spec.rb diff --git a/spec/models/jobs/mail/mail_private_message_spec.rb b/spec/models/jobs/mail/private_message_spec.rb similarity index 90% rename from spec/models/jobs/mail/mail_private_message_spec.rb rename to spec/models/jobs/mail/private_message_spec.rb index 5de3328e9..3a74dd4de 100644 --- a/spec/models/jobs/mail/mail_private_message_spec.rb +++ b/spec/models/jobs/mail/private_message_spec.rb @@ -12,7 +12,7 @@ describe Jobs::Mail::PrivateMessage do participant_ids = [user1.contacts.first.person.id, user1.person.id] create_hash = { :author => user1.person, :participant_ids => participant_ids , - :subject => "cool stuff", :text => 'hey'} + :subject => "cool stuff", :messages_attributes => [{:text => 'hey'}]} cnv = Conversation.create(create_hash) message = cnv.messages.first diff --git a/spec/models/jobs/mail/mail_reshared_spec.rb b/spec/models/jobs/mail/reshared_spec.rb similarity index 100% rename from spec/models/jobs/mail/mail_reshared_spec.rb rename to spec/models/jobs/mail/reshared_spec.rb