Skip to content

Commit

Permalink
Merge branch 'next-minor' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperTux88 committed Jan 8, 2018
2 parents 13d24cc + 1a3c16e commit b3d3445
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -10,6 +10,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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/services/twitter.rb
Expand Up @@ -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+}

Expand Down
14 changes: 9 additions & 5 deletions spec/models/services/twitter_spec.rb
Expand Up @@ -41,8 +41,8 @@

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
Expand All @@ -52,7 +52,7 @@
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
Expand All @@ -67,7 +67,9 @@
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)

Expand All @@ -76,7 +78,9 @@
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)

Expand Down

0 comments on commit b3d3445

Please sign in to comment.