Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog.md1
-rw-r--r--app/models/photo.rb8
-rw-r--r--features/step_definitions/posts_steps.rb2
-rw-r--r--spec/mailers/notifier_spec.rb2
-rw-r--r--spec/models/status_message_spec.rb4
5 files changed, 8 insertions, 9 deletions
diff --git a/Changelog.md b/Changelog.md
index 35d415d8e..abe0252aa 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -12,6 +12,7 @@
* Removed support for defunct Uni Heidelberg OSM tile server, Mapbox is now required if you want to show maps [#8215](https://github.com/diaspora/diaspora/pull/8215)
* Render only two fractional digits in the posts per user/day admin statistics [#8227](https://github.com/diaspora/diaspora/pull/8227)
* Make aspect dropdowns scrollable [#8213](https://github.com/diaspora/diaspora/pull/8213)
+* Fix `Photo#ownserhip_of_status_message` validation [#8214](https://github.com/diaspora/diaspora/pull/8214)
## Features
* Support and recommend TOML as configuration format [#8132](https://github.com/diaspora/diaspora/pull/8132)
diff --git a/app/models/photo.rb b/app/models/photo.rb
index 75d7f83a8..adc604221 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -68,11 +68,9 @@ class Photo < ApplicationRecord
def ownership_of_status_message
message = StatusMessage.find_by_guid(self.status_message_guid)
- if self.status_message_guid && message
- self.diaspora_handle == message.diaspora_handle
- else
- true
- end
+ return unless status_message_guid && message && diaspora_handle != message.diaspora_handle
+
+ errors.add(:base, "Photo must have the same owner as status message")
end
def self.diaspora_initialize(params={})
diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb
index da3ee2924..662e4fa21 100644
--- a/features/step_definitions/posts_steps.rb
+++ b/features/step_definitions/posts_steps.rb
@@ -32,7 +32,7 @@ end
Given /^"([^"]*)" has a public post with text "([^"]*)" and a picture/ do |email, text|
user = User.find_by(email: email)
post = user.post(:status_message, text: text, public: true, to: user.aspect_ids)
- FactoryGirl.create(:photo, status_message: post)
+ FactoryGirl.create(:photo, status_message: post, author: user.person)
end
Given /^there are (\d+) public posts from "([^"]*)"$/ do |n_posts, email|
diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb
index d86d7ef79..a8abde338 100644
--- a/spec/mailers/notifier_spec.rb
+++ b/spec/mailers/notifier_spec.rb
@@ -216,7 +216,7 @@ describe Notifier, type: :mailer do
end
it "can handle status_messages without text" do
- photo = FactoryGirl.create(:photo, public: true)
+ photo = FactoryGirl.create(:photo, public: true, author: alice.person)
status = FactoryGirl.create(:status_message, author: alice.person, text: nil, photos: [photo], public: true)
like = status.likes.create!(author: bob.person)
mail = Notifier.send_notification("liked", alice.id, like.author.id, like.id)
diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb
index 05520de32..9037de305 100644
--- a/spec/models/status_message_spec.rb
+++ b/spec/models/status_message_spec.rb
@@ -306,7 +306,7 @@ describe StatusMessage, type: :model do
let(:post) { FactoryGirl.create(:status_message, author: alice.person) }
it "receives attached photos" do
- photo = FactoryGirl.create(:photo, status_message: post)
+ photo = FactoryGirl.create(:photo, status_message: post, author: alice.person)
post.receive([bob.id])
@@ -321,7 +321,7 @@ describe StatusMessage, type: :model do
end
it "works with already received attached photos" do
- photo = FactoryGirl.create(:photo, status_message: post)
+ photo = FactoryGirl.create(:photo, status_message: post, author: alice.person)
photo.receive([bob.id])
post.receive([bob.id])