Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion of 'Refactor ownship_of_status_message #8059' #8214

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/models/photo.rb
Expand Up @@ -67,11 +67,9 @@ def clear_empty_status_message

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={})
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/posts_steps.rb
Expand Up @@ -32,7 +32,7 @@
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)
FactoryBot.create(:photo, status_message: post)
FactoryBot.create(:photo, status_message: post, author: user.person)
end

Given /^there are (\d+) public posts from "([^"]*)"$/ do |n_posts, email|
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/notifier_spec.rb
Expand Up @@ -216,7 +216,7 @@
end

it "can handle status_messages without text" do
photo = FactoryBot.create(:photo, public: true)
photo = FactoryBot.create(:photo, public: true, author: alice.person)
status = FactoryBot.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)
Expand Down
4 changes: 2 additions & 2 deletions spec/models/status_message_spec.rb
Expand Up @@ -306,7 +306,7 @@
let(:post) { FactoryBot.create(:status_message, author: alice.person) }

it "receives attached photos" do
photo = FactoryBot.create(:photo, status_message: post)
photo = FactoryBot.create(:photo, status_message: post, author: alice.person)

post.receive([bob.id])

Expand All @@ -321,7 +321,7 @@
end

it "works with already received attached photos" do
photo = FactoryBot.create(:photo, status_message: post)
photo = FactoryBot.create(:photo, status_message: post, author: alice.person)

photo.receive([bob.id])
post.receive([bob.id])
Expand Down