parent
00296ffda5
commit
655fe2a912
5 changed files with 40 additions and 3 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
* Prevent users from zooming in IE Mobile [#7589](https://github.com/diaspora/diaspora/pull/7589)
|
* Prevent users from zooming in IE Mobile [#7589](https://github.com/diaspora/diaspora/pull/7589)
|
||||||
* Fix recipient prefill on contacts and profile page [#7599](https://github.com/diaspora/diaspora/pull/7599)
|
* Fix recipient prefill on contacts and profile page [#7599](https://github.com/diaspora/diaspora/pull/7599)
|
||||||
* Display likes and reshares without login [#7583](https://github.com/diaspora/diaspora/pull/7583)
|
* Display likes and reshares without login [#7583](https://github.com/diaspora/diaspora/pull/7583)
|
||||||
|
* Fix invalid data in the database for user data export [#7614](https://github.com/diaspora/diaspora/pull/7614)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
* Ask for confirmation when leaving a submittable comment field [#7530](https://github.com/diaspora/diaspora/pull/7530)
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ class Poll < ApplicationRecord
|
||||||
include Diaspora::Fields::Guid
|
include Diaspora::Fields::Guid
|
||||||
|
|
||||||
belongs_to :status_message
|
belongs_to :status_message
|
||||||
has_many :poll_answers, -> { order 'id ASC' }
|
has_many :poll_answers, -> { order "id ASC" }, dependent: :destroy
|
||||||
has_many :poll_participations
|
has_many :poll_participations, dependent: :destroy
|
||||||
has_one :author, through: :status_message
|
has_one :author, through: :status_message
|
||||||
|
|
||||||
#forward some requests to status message, because a poll is just attached to a status message and is not sharable itself
|
#forward some requests to status message, because a poll is just attached to a status message and is not sharable itself
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class StatusMessage < Post
|
||||||
has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid
|
has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid
|
||||||
|
|
||||||
has_one :location
|
has_one :location
|
||||||
has_one :poll, autosave: true
|
has_one :poll, autosave: true, dependent: :destroy
|
||||||
has_many :poll_participations, through: :poll
|
has_many :poll_participations, through: :poll
|
||||||
|
|
||||||
attr_accessor :oembed_url
|
attr_accessor :oembed_url
|
||||||
|
|
|
||||||
19
db/migrate/20170914212336_cleanup_invalid_polls.rb
Normal file
19
db/migrate/20170914212336_cleanup_invalid_polls.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
class CleanupInvalidPolls < ActiveRecord::Migration[5.1]
|
||||||
|
class Poll < ApplicationRecord
|
||||||
|
has_many :poll_answers, dependent: :destroy
|
||||||
|
has_many :poll_participations, dependent: :destroy
|
||||||
|
end
|
||||||
|
class PollAnswer < ApplicationRecord
|
||||||
|
belongs_to :poll
|
||||||
|
has_many :poll_participations
|
||||||
|
end
|
||||||
|
class PollParticipation < ApplicationRecord
|
||||||
|
belongs_to :poll
|
||||||
|
belongs_to :poll_answer
|
||||||
|
end
|
||||||
|
|
||||||
|
def up
|
||||||
|
Poll.joins("LEFT OUTER JOIN posts ON posts.id = polls.status_message_id")
|
||||||
|
.where("posts.id IS NULL").destroy_all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -233,6 +233,23 @@ describe StatusMessage, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "poll" do
|
||||||
|
it "destroys the poll (with all answers and participations) when the status message is destroyed" do
|
||||||
|
poll = FactoryGirl.create(:poll_participation).poll
|
||||||
|
status_message = poll.status_message
|
||||||
|
|
||||||
|
poll_id = poll.id
|
||||||
|
poll_answers = poll.poll_answers.map(&:id)
|
||||||
|
poll_participations = poll.poll_participations.map(&:id)
|
||||||
|
|
||||||
|
status_message.destroy
|
||||||
|
|
||||||
|
expect(Poll.where(id: poll_id)).not_to exist
|
||||||
|
poll_answers.each {|id| expect(PollAnswer.where(id: id)).not_to exist }
|
||||||
|
poll_participations.each {|id| expect(PollParticipation.where(id: id)).not_to exist }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "validation" do
|
describe "validation" do
|
||||||
let(:status_message) { build(:status_message, text: @message_text) }
|
let(:status_message) { build(:status_message, text: @message_text) }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue