Permalink
Browse files

did the description from just bought switch

  • Loading branch information...
1 parent 66598a7 commit a4f93c3e342408dbf9fa53b007dd28db2e9b28ca Cyril David committed with cyx Mar 25, 2010
Showing with 48 additions and 7 deletions.
  1. +6 −1 app/concerns/status_update_concerns.rb
  2. +5 −1 app/models/purchase.rb
  3. +6 −5 app/views/layout.haml
  4. +31 −0 spec/models/purchase_spec.rb
@@ -30,7 +30,8 @@ def initialize( attrs = {} )
attrs.each { |field, value| write(field, value) }
if @item and @body.blank?
- template = render(:url => ItemUrl.make(@item), :username => @item.user.login)
+ template = render(:url => ItemUrl.make(@item), :username => @item.user.login,
+ :content => content)
self.body = sprintf(template, @item.to_s)
end
end
@@ -75,6 +76,10 @@ def item_id=( item_id )
self.item = Item.find(item_id)
end
+ def content
+ ""
+ end
+
private
def render( attrs = {} )
self.class.template.dup.tap do |ret|
View
@@ -1,12 +1,16 @@
class Purchase
include StatusUpdateConcerns
- template "just bought %.64s :url #boughtstuff"
+ template ":content :url #boughtstuff"
@queue = :twitter
def self.perform( item_id, user_id )
item, user = Item.find(item_id), User.find(user_id)
item.update_attribute :twitter_status_id, post( item, user )
end
+
+ def content
+ item.description? ? item.description[0, 76] : "just bought %.64s"
+ end
end
View
@@ -29,8 +29,9 @@
var pageTracker = _gat._getTracker("UA-15297465-1");
pageTracker._trackPageview();
} catch(err) {}
-
- :javascript
- lloogg_clientid = "29000010bb1daf0f";
- = javascript_include_tag "http://lloogg.com/l.js?c=29000010bb1daf0f"
-
+
+ <script type="text/javascript">
+ lloogg_clientid = "29000010bb1daf0f";
+ </script>
+ <script type="text/javascript" src="http://lloogg.com/l.js?c=29000010bb1daf0f"></script>
+
@@ -61,4 +61,35 @@
}
end
+describe Purchase, "with an Item and a description got it in thanks giving" do
+ subject do
+ item = Factory.build(:item, :name => "Magic Mouse",
+ :description => "Got it in thanks giving",
+ :user => Factory(:user, :login => "cyx"))
+
+ item.id = 1001
+ item.save!
+
+ Purchase.new(:item => item, :sender => item.user)
+ end
+
+ its(:body) {
+ should == "Got it in thanks giving http://boughtstuff.com/cyx#1001 #boughtstuff"
+ }
+end
+
+describe Purchase, "with an Item and a description Lorem..." do
+ subject do
+ item = Factory.build(:item, :name => "Magic Mouse",
+ :description => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
+ :user => Factory(:user, :login => "abcdefghijklmno"))
+
+ item.id = 1000000000
+ item.save!
+ Purchase.new(:item => item, :sender => item.user)
+ end
+
+ its(:body) { subject.length.should == 139 }
+ its(:body) { should == "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tem http://boughtstuff.com/abcdefghijklmno#1000000000 #boughtstuff" }
+end

0 comments on commit a4f93c3

Please sign in to comment.