Merge branch 'next-minor' into develop
This commit is contained in:
commit
cb2a00fbeb
5 changed files with 59 additions and 15 deletions
4
Gemfile
4
Gemfile
|
|
@ -13,7 +13,7 @@ gem "unicorn-worker-killer", "0.4.4"
|
||||||
|
|
||||||
# Federation
|
# Federation
|
||||||
|
|
||||||
gem "diaspora_federation-rails", "0.1.3"
|
gem "diaspora_federation-rails", "0.1.4"
|
||||||
|
|
||||||
# API and JSON
|
# API and JSON
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ group :test do
|
||||||
gem "webmock", "2.1.0", require: false
|
gem "webmock", "2.1.0", require: false
|
||||||
gem "shoulda-matchers", "3.1.1"
|
gem "shoulda-matchers", "3.1.1"
|
||||||
|
|
||||||
gem "diaspora_federation-test", "0.1.3"
|
gem "diaspora_federation-test", "0.1.4"
|
||||||
|
|
||||||
# Coverage
|
# Coverage
|
||||||
gem 'coveralls', require: false
|
gem 'coveralls', require: false
|
||||||
|
|
|
||||||
14
Gemfile.lock
14
Gemfile.lock
|
|
@ -177,17 +177,17 @@ GEM
|
||||||
devise
|
devise
|
||||||
rails (>= 3.0.4)
|
rails (>= 3.0.4)
|
||||||
diaspora-prosody-config (0.0.5)
|
diaspora-prosody-config (0.0.5)
|
||||||
diaspora_federation (0.1.3)
|
diaspora_federation (0.1.4)
|
||||||
faraday (~> 0.9.0)
|
faraday (~> 0.9.0)
|
||||||
faraday_middleware (~> 0.10.0)
|
faraday_middleware (~> 0.10.0)
|
||||||
nokogiri (~> 1.6, >= 1.6.8)
|
nokogiri (~> 1.6, >= 1.6.8)
|
||||||
typhoeus (~> 1.0)
|
typhoeus (~> 1.0)
|
||||||
valid (~> 1.0)
|
valid (~> 1.0)
|
||||||
diaspora_federation-rails (0.1.3)
|
diaspora_federation-rails (0.1.4)
|
||||||
diaspora_federation (= 0.1.3)
|
diaspora_federation (= 0.1.4)
|
||||||
rails (~> 4.2)
|
rails (~> 4.2)
|
||||||
diaspora_federation-test (0.1.3)
|
diaspora_federation-test (0.1.4)
|
||||||
diaspora_federation (= 0.1.3)
|
diaspora_federation (= 0.1.4)
|
||||||
factory_girl (~> 4.7)
|
factory_girl (~> 4.7)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
docile (1.1.5)
|
docile (1.1.5)
|
||||||
|
|
@ -934,8 +934,8 @@ DEPENDENCIES
|
||||||
devise-token_authenticatable (= 0.5.2)
|
devise-token_authenticatable (= 0.5.2)
|
||||||
devise_lastseenable (= 0.0.6)
|
devise_lastseenable (= 0.0.6)
|
||||||
diaspora-prosody-config (= 0.0.5)
|
diaspora-prosody-config (= 0.0.5)
|
||||||
diaspora_federation-rails (= 0.1.3)
|
diaspora_federation-rails (= 0.1.4)
|
||||||
diaspora_federation-test (= 0.1.3)
|
diaspora_federation-test (= 0.1.4)
|
||||||
entypo-rails (= 3.0.0.pre.rc2)
|
entypo-rails (= 3.0.0.pre.rc2)
|
||||||
eye (= 0.8.1)
|
eye (= 0.8.1)
|
||||||
factory_girl_rails (= 4.7.0)
|
factory_girl_rails (= 4.7.0)
|
||||||
|
|
|
||||||
|
|
@ -138,9 +138,8 @@ class PostPresenter < BasePresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
tags = @post.is_a?(Reshare) ? @post.root.tags : @post.tags
|
tags = @post.is_a?(Reshare) ? @post.absolute_root.try(:tags) : @post.tags
|
||||||
return tags.map(&:name) if tags
|
tags ? tags.map(&:name) : []
|
||||||
[]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def comma_separated_tags
|
def comma_separated_tags
|
||||||
|
|
@ -152,6 +151,6 @@ class PostPresenter < BasePresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def description
|
def description
|
||||||
message.plain_text_without_markdown(truncate: 1000)
|
message.try(:plain_text_without_markdown, truncate: 1000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ module Workers
|
||||||
DiasporaFederation::Salmon::SenderKeyNotFound,
|
DiasporaFederation::Salmon::SenderKeyNotFound,
|
||||||
DiasporaFederation::Salmon::InvalidEnvelope,
|
DiasporaFederation::Salmon::InvalidEnvelope,
|
||||||
DiasporaFederation::Salmon::InvalidSignature,
|
DiasporaFederation::Salmon::InvalidSignature,
|
||||||
|
DiasporaFederation::Salmon::InvalidDataType,
|
||||||
DiasporaFederation::Salmon::InvalidAlgorithm,
|
DiasporaFederation::Salmon::InvalidAlgorithm,
|
||||||
DiasporaFederation::Salmon::InvalidEncoding,
|
DiasporaFederation::Salmon::InvalidEncoding,
|
||||||
Diaspora::Federation::AuthorIgnored,
|
Diaspora::Federation::AuthorIgnored,
|
||||||
|
|
|
||||||
|
|
@ -89,4 +89,48 @@ describe PostPresenter do
|
||||||
expect(presenter.as_json).to be_a(Hash)
|
expect(presenter.as_json).to be_a(Hash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#tags" do
|
||||||
|
it "returns the tag of the post" do
|
||||||
|
post = FactoryGirl.create(:status_message, text: "#hello #world", public: true)
|
||||||
|
|
||||||
|
expect(PostPresenter.new(post).send(:tags)).to match_array(%w(hello world))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns the tag of the absolute_root of a Reshare" do
|
||||||
|
post = FactoryGirl.create(:status_message, text: "#hello #world", public: true)
|
||||||
|
first_reshare = FactoryGirl.create(:reshare, root: post)
|
||||||
|
second_reshare = FactoryGirl.create(:reshare, root: first_reshare)
|
||||||
|
|
||||||
|
expect(PostPresenter.new(second_reshare).send(:tags)).to match_array(%w(hello world))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not raise if the root of a reshare does not exist anymore" do
|
||||||
|
reshare = FactoryGirl.create(:reshare)
|
||||||
|
reshare.root = nil
|
||||||
|
|
||||||
|
expect(PostPresenter.new(reshare).send(:tags)).to eq([])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#description" do
|
||||||
|
it "returns the first 1000 chars of the text" do
|
||||||
|
post = FactoryGirl.create(:status_message, text: "a" * 1001, public: true)
|
||||||
|
|
||||||
|
expect(PostPresenter.new(post).send(:description)).to eq("#{'a' * 997}...")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not change the message if less or equal 1000 chars" do
|
||||||
|
post = FactoryGirl.create(:status_message, text: "a" * 1000, public: true)
|
||||||
|
|
||||||
|
expect(PostPresenter.new(post).send(:description)).to eq("a" * 1000)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not raise if the root of a reshare does not exist anymore" do
|
||||||
|
reshare = FactoryGirl.create(:reshare)
|
||||||
|
reshare.root = nil
|
||||||
|
|
||||||
|
expect(PostPresenter.new(reshare).send(:description)).to eq(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue