update to support 280 character Twitter
closes #7694 closes #7662 fixes #7661
This commit is contained in:
parent
0347507b20
commit
1a3c16eb6e
3 changed files with 11 additions and 6 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
## Refactor
|
||||
* Work on the data downloads: Fixed general layout of buttons, added a timestamp and implemented auto-deletion of old exports [#7684](https://github.com/diaspora/diaspora/pull/7684)
|
||||
* Increase Twitter character limit to 280 [#7694](https://github.com/diaspora/diaspora/pull/7694)
|
||||
|
||||
## Bug fixes
|
||||
* Fix notifications when people remove their birthday date [#7691](https://github.com/diaspora/diaspora/pull/7691)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
class Services::Twitter < Service
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
MAX_CHARACTERS = 140
|
||||
MAX_CHARACTERS = 280
|
||||
SHORTENED_URL_LENGTH = 21
|
||||
LINK_PATTERN = %r{https?://\S+}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ describe Services::Twitter, :type => :model do
|
|||
|
||||
describe "message size limits" do
|
||||
before :each do
|
||||
@long_message_start = SecureRandom.hex(25)
|
||||
@long_message_end = SecureRandom.hex(25)
|
||||
@long_message_start = SecureRandom.hex(165)
|
||||
@long_message_end = SecureRandom.hex(165)
|
||||
end
|
||||
|
||||
it "should not truncate a short message" do
|
||||
|
|
@ -52,7 +52,7 @@ describe Services::Twitter, :type => :model do
|
|||
end
|
||||
|
||||
it "should truncate a long message" do
|
||||
long_message = SecureRandom.hex(220)
|
||||
long_message = SecureRandom.hex(360)
|
||||
long_post = double(message: double(plain_text_without_markdown: long_message), id: 1, photos: [])
|
||||
expect(@service.send(:build_twitter_post, long_post).length).to be < long_message.length
|
||||
end
|
||||
|
|
@ -67,7 +67,9 @@ describe Services::Twitter, :type => :model do
|
|||
end
|
||||
|
||||
it "should not cut links when truncating a post" do
|
||||
long_message = SecureRandom.hex(40) + " http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + SecureRandom.hex(55)
|
||||
long_message = SecureRandom.hex(40) +
|
||||
" http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " +
|
||||
SecureRandom.hex(195)
|
||||
long_post = double(message: double(plain_text_without_markdown: long_message), id: 1, photos: [])
|
||||
answer = @service.send(:build_twitter_post, long_post)
|
||||
|
||||
|
|
@ -76,7 +78,9 @@ describe Services::Twitter, :type => :model do
|
|||
end
|
||||
|
||||
it "should append the otherwise-cut link when truncating a post" do
|
||||
long_message = "http://joindiaspora.com/a-very-long-decoy-url.html " + SecureRandom.hex(20) + " http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + SecureRandom.hex(55) + " http://joindiaspora.com/a-very-long-decoy-url-part-2.html"
|
||||
long_message = "http://joindiaspora.com/a-very-long-decoy-url.html " + SecureRandom.hex(20) +
|
||||
" http://joindiaspora.com/a-very-long-url-name-that-will-be-shortened.html " + SecureRandom.hex(195) +
|
||||
" http://joindiaspora.com/a-very-long-decoy-url-part-2.html"
|
||||
long_post = double(message: double(plain_text_without_markdown: long_message), id: 1, photos: [])
|
||||
answer = @service.send(:build_twitter_post, long_post)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue