firefly 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- firefly (1.3.1)
4
+ firefly (1.4.0)
5
5
  dm-aggregates (~> 1.0.2)
6
6
  dm-core (~> 1.0.2)
7
7
  dm-migrations (~> 1.0.2)
data/HISTORY CHANGED
@@ -1,3 +1,8 @@
1
+ = 1.4.1 - 2011-02-11
2
+
3
+ * 2011-02-11 Strip leading and trailing whitespace from titles when sharing [ariejan]
4
+ * 2011-02-11 Make sure shared titles don't exceed a total of 140 characters for twitter [ariejan]
5
+
1
6
  = 1.4.0 - 2011-02-11
2
7
 
3
8
  * 2011-02-21 Added support for 'share to twitter' links [ariejan]
@@ -105,10 +105,11 @@ module Firefly
105
105
 
106
106
  # Format a tweet
107
107
  def tweet(url, message = nil)
108
- if message.nil?
108
+ if message.nil? || message == ""
109
109
  config[:tweet].gsub('%short_url%', url)
110
110
  else
111
- "#{message} #{url}"
111
+ max_length = 140-1-url.size
112
+ [message.strip.slice(0...max_length), url].join(' ')
112
113
  end
113
114
  end
114
115
 
@@ -1,3 +1,3 @@
1
1
  module Firefly
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
@@ -60,6 +60,26 @@ describe "Sharing" do
60
60
  self.send verb, '/api/share', @params.merge(:target => 'facebook')
61
61
  }.should_not change(Firefly::Url, :count)
62
62
  end
63
+
64
+ it "should shorten long titles to fit within the 140 character limit" do
65
+ title = "This is a very long title that will never fit in the current one hundred and forty character limit enforce by twitter. Or does it?"
66
+ self.send verb, '/api/share', @params.merge(:title => title)
67
+ url = Firefly::Url.first(:url => @params[:url])
68
+
69
+ short_url = "http://test.host/#{url.code}"
70
+ expected = title.slice(0...(140-1-short_url.length)) + ' ' + short_url
71
+
72
+ last_response['Location'].should include(URI.escape(expected))
73
+ end
74
+
75
+ it "should strip the title to remove any unnecessary white space" do
76
+ title = " Test post "
77
+ self.send verb, '/api/share', @params.merge(:title => title)
78
+ url = Firefly::Url.first(:url => @params[:url])
79
+
80
+ last_response['Location'].should include(URI.escape("Test post http://test.host/#{url.code}"))
81
+ last_response['Location'].should_not include(URI.escape(title))
82
+ end
63
83
  end
64
84
  end
65
85
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firefly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 0
10
- version: 1.4.0
9
+ - 1
10
+ version: 1.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ariejan de Vroom