fix all specs minus one from o_embed_data_spec

This commit is contained in:
danielgrippi 2011-12-31 14:19:40 -05:00
parent ab8fb88e74
commit 176a33880f
6 changed files with 11 additions and 81 deletions

View file

@ -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 <span> 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

View file

@ -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

View file

@ -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 => '<html><body>hello there</body></html>')
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

View file

@ -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