Merge branch 'next-minor' into develop

This commit is contained in:
Dennis Schubert 2016-09-04 03:30:10 +02:00
commit daff91ea20
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E
7 changed files with 26 additions and 19 deletions

View file

@ -13,6 +13,7 @@
* Remove text color from notification mails and fix sender avatar [#7054](https://github.com/diaspora/diaspora/pull/7054) * Remove text color from notification mails and fix sender avatar [#7054](https://github.com/diaspora/diaspora/pull/7054)
* Make the session cookies HttpOnly again [#7041](https://github.com/diaspora/diaspora/pull/7041) * Make the session cookies HttpOnly again [#7041](https://github.com/diaspora/diaspora/pull/7041)
* Invalidate sessions with invalid CSRF tokens [#7050](https://github.com/diaspora/diaspora/pull/7050) * Invalidate sessions with invalid CSRF tokens [#7050](https://github.com/diaspora/diaspora/pull/7050)
* Liking a post will no longer update its interacted timestamp [#7030](https://github.com/diaspora/diaspora/pull/7030)
## Bug fixes ## Bug fixes
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040) * Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)

View file

@ -38,8 +38,9 @@ class Comment < ActiveRecord::Base
self.text.strip! unless self.text.nil? self.text.strip! unless self.text.nil?
end end
after_commit :on => :create do after_commit on: :create do
self.parent.update_comments_counter parent.update_comments_counter
parent.touch(:interacted_at) if parent.respond_to?(:interacted_at)
end end
after_destroy do after_destroy do

View file

@ -11,10 +11,6 @@ module Diaspora
delegate :public?, to: :parent delegate :public?, to: :parent
delegate :author, :diaspora_handle, to: :parent, prefix: true delegate :author, :diaspora_handle, to: :parent, prefix: true
after_commit :on => :create do
parent.touch(:interacted_at) if parent.respond_to?(:interacted_at)
end
end end
end end

View file

@ -83,8 +83,8 @@ describe EvilQuery::Participation do
expect(posts.map(&:id)).to match_array([@status_messageA.id, @status_messageB.id, @status_messageE.id]) expect(posts.map(&:id)).to match_array([@status_messageA.id, @status_messageB.id, @status_messageE.id])
end end
it "returns the posts that the user has commented on or liked with the most recently acted on ones first" do it "returns the posts that the user has commented on most recently first" do
expect(posts.map(&:id)).to eq([@status_messageE.id, @status_messageA.id, @status_messageB.id]) expect(posts.map(&:id)).to eq([@status_messageE.id, @status_messageB.id, @status_messageA.id])
end end
end end

View file

@ -66,6 +66,16 @@ describe Comment, type: :model do
end end
end end
describe "interacted_at" do
it "sets the interacted at of the parent to the created at of the comment" do
Timecop.travel(Time.zone.now + 1.minute)
comment = Comment::Generator.new(alice, status_bob, "why so formal?").build
comment.save
expect(status_bob.reload.interacted_at.to_i).to eq(comment.created_at.to_i)
end
end
it_behaves_like "it is relayable" do it_behaves_like "it is relayable" do
let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) } let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) }
let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) } let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) }

View file

@ -43,6 +43,16 @@ describe Like, type: :model do
end end
end end
describe "interacted_at" do
it "doesn't change the interacted at timestamp of the parent" do
interacted_at = status.reload.interacted_at.to_i
Timecop.travel(Time.zone.now + 1.minute)
Like::Generator.new(alice, status).build.save
expect(status.reload.interacted_at.to_i).to eq(interacted_at)
end
end
it_behaves_like "it is relayable" do it_behaves_like "it is relayable" do
let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) } let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) }
let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) } let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) }

View file

@ -5,17 +5,6 @@
require "spec_helper" require "spec_helper"
shared_examples_for "it is relayable" do shared_examples_for "it is relayable" do
describe "interacted_at" do
it "sets the interacted at of the parent to the created at of the relayable post" do
Timecop.freeze Time.now do
relayable.save
if relayable.parent.respond_to?(:interacted_at) #I'm sorry.
expect(relayable.parent.interacted_at.to_i).to eq(relayable.created_at.to_i)
end
end
end
end
describe "validations" do describe "validations" do
context "author ignored by parent author" do context "author ignored by parent author" do
context "the author is on the parent object author's ignore list when object is created" do context "the author is on the parent object author's ignore list when object is created" do