Specs passing with text

This commit is contained in:
Raphael Sofaer 2011-03-14 10:58:15 -07:00
parent 4b4654a408
commit 1b0445563e
25 changed files with 35 additions and 35 deletions

View file

@ -5,7 +5,7 @@
module StatusMessagesHelper module StatusMessagesHelper
def my_latest_message def my_latest_message
unless @latest_status_message.nil? unless @latest_status_message.nil?
return @latest_status_message.message return @latest_status_message.text
else else
return I18n.t('status_messages.helper.no_message_to_display') return I18n.t('status_messages.helper.no_message_to_display')
end end

View file

@ -10,7 +10,7 @@ class Service < ActiveRecord::Base
def public_message(post, length, url = "") def public_message(post, length, url = "")
url = "" if post.respond_to?(:photos) && post.photos.count == 0 url = "" if post.respond_to?(:photos) && post.photos.count == 0
space_for_url = url.blank? ? 0 : (url.length + 1) space_for_url = url.blank? ? 0 : (url.length + 1)
truncated = truncate(post.message(:plain_text => true), :length => (length - space_for_url)) truncated = truncate(post.text(:plain_text => true), :length => (length - space_for_url))
truncated = "#{truncated} #{url}" unless url.blank? truncated = "#{truncated} #{url}" unless url.blank?
return truncated return truncated
end end

View file

@ -10,7 +10,7 @@ class StatusMessage < Post
acts_as_taggable_on :tags acts_as_taggable_on :tags
validates_length_of :message, :maximum => 1000, :text => "please make your status messages less than 1000 characters" validates_length_of :text, :maximum => 1000, :text => "please make your status messages less than 1000 characters"
xml_name :status_message xml_name :status_message
xml_attr :raw_message xml_attr :raw_message
@ -26,7 +26,7 @@ class StatusMessage < Post
before_create :build_tags before_create :build_tags
def message(opts = {}) def text(opts = {})
self.formatted_message(opts) self.formatted_message(opts)
end end

View file

@ -40,7 +40,7 @@
.span-8.last .span-8.last
%p %p
= markdownify(@photo.status_message.message) = markdownify(@photo.status_message.text)
%span{:style=>'font-size:smaller'} %span{:style=>'font-size:smaller'}
=link_to t('.collection_permalink'), @photo.status_message =link_to t('.collection_permalink'), @photo.status_message
%br %br

View file

@ -27,7 +27,7 @@
= link_to t('photos.show.view'), post_path(@post.status_message) = link_to t('photos.show.view'), post_path(@post.status_message)
%p %p
= @post.status_message.message = @post.status_message.text
%p %p
- for photo in @post.status_message.photos - for photo in @post.status_message.photos

View file

@ -11,7 +11,7 @@
.span-14.append-1.last .span-14.append-1.last
#show_text #show_text
%p %p
= markdownify(@post.message, :youtube_maps => @post[:youtube_titles]) = markdownify(@post.text, :youtube_maps => @post[:youtube_titles])
- for photo in @post.photos - for photo in @post.photos
= link_to (image_tag photo.url(:thumb_small)), post_path(photo) = link_to (image_tag photo.url(:thumb_small)), post_path(photo)

View file

@ -7,5 +7,5 @@
= link_to t('.reshare'), "#" = link_to t('.reshare'), "#"
%ul.reshare_box %ul.reshare_box
= aspect_links(aspects, :prefill => post.message) = aspect_links(aspects, :prefill => post.text)

View file

@ -13,7 +13,7 @@
- else - else
- for photo in photos[1..photos.size] - for photo in photos[1..photos.size]
= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) = link_to (image_tag photo.url(:thumb_small)), photo_path(photo)
= markdownify(post.message, :youtube_maps => post[:youtube_titles]) = markdownify(post.text, :youtube_maps => post[:youtube_titles])
- else - else
= markdownify(post.message, :youtube_maps => post[:youtube_titles]) = markdownify(post.text, :youtube_maps => post[:youtube_titles])

View file

@ -9,7 +9,7 @@
#show_text #show_text
%p %p
= markdownify(@status_message.message, :youtube_maps => @status_message[:youtube_titles]) = markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles])
- for photo in @status_message.photos - for photo in @status_message.photos
= link_to (image_tag photo.url(:thumb_small)), photo_path(photo) = link_to (image_tag photo.url(:thumb_small)), photo_path(photo)

View file

@ -6,7 +6,7 @@
= render 'shared/author_info', :person => @status_message.author, :post => @status_message = render 'shared/author_info', :person => @status_message.author, :post => @status_message
%p %p
= markdownify(@status_message.message, :youtube_maps => @status_message[:youtube_titles]) = markdownify(@status_message.text, :youtube_maps => @status_message[:youtube_titles])
- for photo in @status_message.photos - for photo in @status_message.photos
= link_to (image_tag photo.url(:thumb_small)), photo.url(:thumb_medium) = link_to (image_tag photo.url(:thumb_small)), photo.url(:thumb_medium)

View file

@ -59,7 +59,7 @@ class Postzord::Dispatch
if @object.respond_to?(:public) && @object.public if @object.respond_to?(:public) && @object.public
deliver_to_hub deliver_to_hub
end end
if @object.respond_to?(:message) if @object.instance_of?(StatusMessage)
services.each do |service| services.each do |service|
Resque.enqueue(Job::PostToService, service.id, @object.id, url) Resque.enqueue(Job::PostToService, service.id, @object.id, url)
end end

View file

@ -122,7 +122,7 @@ describe AspectsController do
connect_users(@alice, @alices_aspect_1, user, aspect) connect_users(@alice, @alices_aspect_1, user, aspect)
post = @alice.post(:status_message, :text => "hello#{n}", :to => @alices_aspect_2.id) post = @alice.post(:status_message, :text => "hello#{n}", :to => @alices_aspect_2.id)
8.times do |n| 8.times do |n|
user.comment "yo#{post.message}", :on => post user.comment "yo#{post.text}", :on => post
end end
end end
end end

View file

@ -67,7 +67,7 @@ describe PeopleController do
end end
@posts.each do |post| @posts.each do |post|
@users.each do |user| @users.each do |user|
user.comment "yo#{post.message}", :on => post user.comment "yo#{post.text}", :on => post
end end
end end
end end

View file

@ -26,7 +26,7 @@ describe SocketsController do
it 'actionhashes posts' do it 'actionhashes posts' do
json = @controller.action_hash(@user, @message) json = @controller.action_hash(@user, @message)
json.include?(@message.message).should be_true json.include?(@message.text).should be_true
json.include?('status_message').should be_true json.include?('status_message').should be_true
end end

View file

@ -98,7 +98,7 @@ describe StatusMessagesController do
old_status_message = @user1.post(:status_message, :text => "hello", :to => @aspect1.id) old_status_message = @user1.post(:status_message, :text => "hello", :to => @aspect1.id)
status_message_hash[:status_message][:id] = old_status_message.id status_message_hash[:status_message][:id] = old_status_message.id
post :create, status_message_hash post :create, status_message_hash
old_status_message.reload.message.should == 'hello' old_status_message.reload.text.should == 'hello'
end end
it 'calls dispatch post once subscribers is set' do it 'calls dispatch post once subscribers is set' do

View file

@ -25,7 +25,7 @@ describe UsersController do
it 'renders xml' do it 'renders xml' do
sm = Factory(:status_message, :public => true, :author => @user.person) sm = Factory(:status_message, :public => true, :author => @user.person)
get :public, :username => @user.username get :public, :username => @user.username
response.body.should include(sm.message) response.body.should include(sm.text)
end end
end end

View file

@ -120,7 +120,7 @@ describe 'a user receives a post' do
receive_with_zord(@user2, @user1.person, xml) receive_with_zord(@user2, @user1.person, xml)
status.reload.message.should == 'store this!' status.reload.text.should == 'store this!'
end end
it 'updates posts marked as mutable' do it 'updates posts marked as mutable' do

View file

@ -89,9 +89,9 @@ describe Diaspora::Exporter do
context '<posts>' do context '<posts>' do
let(:posts_xml) {exported.xpath('//posts').to_s} let(:posts_xml) {exported.xpath('//posts').to_s}
it 'should include many posts xml' do it 'should include many posts xml' do
posts_xml.should include @status_message1.message posts_xml.should include @status_message1.text
posts_xml.should include @status_message2.message posts_xml.should include @status_message2.text
posts_xml.should_not include @status_message3.message posts_xml.should_not include @status_message3.text
end end
it 'should include post created at time' do it 'should include post created at time' do

View file

@ -25,11 +25,11 @@ describe Diaspora::OstatusBuilder do
let!(:atom) { director = Diaspora::Director.new; director.build(Diaspora::OstatusBuilder.new(user, public_status_messages)) } let!(:atom) { director = Diaspora::Director.new; director.build(Diaspora::OstatusBuilder.new(user, public_status_messages)) }
it 'should include a users posts' do it 'should include a users posts' do
public_status_messages.each{ |status| atom.should include status.message } public_status_messages.each{ |status| atom.should include status.text}
end end
it 'should iterate through all objects, and not stop if it runs into a post without a to_activity' do it 'should iterate through all objects, and not stop if it runs into a post without a to_activity' do
messages = public_status_messages.collect{|x| x.message} messages = public_status_messages.collect{|x| x.text}
public_status_messages.insert(1, []) public_status_messages.insert(1, [])
director = Diaspora::Director.new; director = Diaspora::Director.new;
atom2 = director.build(Diaspora::OstatusBuilder.new(user, public_status_messages)) atom2 = director.build(Diaspora::OstatusBuilder.new(user, public_status_messages))

View file

@ -102,7 +102,7 @@ describe Notifier do
end end
it 'has the post text in the body' do it 'has the post text in the body' do
@mail.body.encoded.should include(@sm.message) @mail.body.encoded.should include(@sm.text)
end end
it 'should not include translation missing' do it 'should not include translation missing' do

View file

@ -11,7 +11,7 @@ describe Services::Facebook do
describe '#post' do describe '#post' do
it 'posts a status message to facebook' do it 'posts a status message to facebook' do
RestClient.should_receive(:post).with("https://graph.facebook.com/me/feed", :message => @post.message, :access_token => @service.access_token) RestClient.should_receive(:post).with("https://graph.facebook.com/me/feed", :message => @post.text, :access_token => @service.access_token)
@service.post(@post) @service.post(@post)
end end
it 'swallows exception raised by facebook always being down' do it 'swallows exception raised by facebook always being down' do

View file

@ -11,7 +11,7 @@ describe Services::Twitter do
describe '#post' do describe '#post' do
it 'posts a status message to twitter' do it 'posts a status message to twitter' do
Twitter.should_receive(:update).with(@post.message) Twitter.should_receive(:update).with(@post.text)
@service.post(@post) @service.post(@post)
end end

View file

@ -61,7 +61,7 @@ describe StatusMessage do
message = "Users do things" message = "Users do things"
status = @user.post(:status_message, :text => message, :to => @aspect.id) status = @user.post(:status_message, :text => message, :to => @aspect.id)
db_status = StatusMessage.find(status.id) db_status = StatusMessage.find(status.id)
db_status.message.should == message db_status.text.should == message
end end
it 'should require status messages to be less than 1000 characters' do it 'should require status messages to be less than 1000 characters' do
@ -118,7 +118,7 @@ STR
describe '#formatted_message' do describe '#formatted_message' do
it 'escapes the message' do it 'escapes the message' do
xss = "</a> <script> alert('hey'); </script>" xss = "</a> <script> alert('hey'); </script>"
@sm.message << xss @sm.text << xss
@sm.formatted_message.should_not include xss @sm.formatted_message.should_not include xss
end end
@ -235,7 +235,7 @@ STR
end end
it 'serializes the unescaped, unprocessed message' do it 'serializes the unescaped, unprocessed message' do
@message.text = "<script> alert('xss should be federated');</script>" @message.text = "<script> alert('xss should be federated');</script>"
@message.to_xml.to_s.should include @message.message @message.to_xml.to_s.should include @message.text
end end
it 'serializes the message' do it 'serializes the message' do
@xml.should include "<raw_message>I hate WALRUSES!</raw_message>" @xml.should include "<raw_message>I hate WALRUSES!</raw_message>"
@ -250,7 +250,7 @@ STR
@marshalled = StatusMessage.from_xml(@xml) @marshalled = StatusMessage.from_xml(@xml)
end end
it 'marshals the message' do it 'marshals the message' do
@marshalled.message.should == "I hate WALRUSES!" @marshalled.text.should == "I hate WALRUSES!"
end end
it 'marshals the guid' do it 'marshals the guid' do
@marshalled.guid.should == @message.guid @marshalled.guid.should == @message.guid

View file

@ -72,7 +72,7 @@ describe "attack vectors" do
zord = Postzord::Receiver.new(user, :salmon_xml => salmon_xml) zord = Postzord::Receiver.new(user, :salmon_xml => salmon_xml)
zord.perform zord.perform
original_message.reload.message.should == "store this!" original_message.reload.text.should == "store this!"
end end
it 'does not save a message over an old message with the same author' do it 'does not save a message over an old message with the same author' do
@ -91,8 +91,8 @@ describe "attack vectors" do
}.should_not change{user.reload.raw_visible_posts.count} }.should_not change{user.reload.raw_visible_posts.count}
original_message.reload.message.should == "store this!" original_message.reload.text.should == "store this!"
user.raw_visible_posts.first.message.should == "store this!" user.raw_visible_posts.first.text.should == "store this!"
end end
end end
it 'should not overwrite another persons profile profile' do it 'should not overwrite another persons profile profile' do

View file

@ -62,7 +62,7 @@ describe User do
describe '#build_post' do describe '#build_post' do
it 'sets status_message#message' do it 'sets status_message#message' do
post = user.build_post(:status_message, :text => "hey", :to => aspect.id) post = user.build_post(:status_message, :text => "hey", :to => aspect.id)
post.message.should == "hey" post.text.should == "hey"
end end
it 'does not save a status_message' do it 'does not save a status_message' do
post = user.build_post(:status_message, :text => "hey", :to => aspect.id) post = user.build_post(:status_message, :text => "hey", :to => aspect.id)