mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 05:25:16 -05:00
DEV: Update rubocop-discourse to latest version
The lastest version of rubocop-discourse enables rules regarding plugins.
This commit is contained in:
committed by
Loïc Guitaut
parent
7a6ba47e7b
commit
f7d7092a7a
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module DiscoursePoll
|
||||
module PostExtension
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
prepended do
|
||||
attr_accessor :extracted_polls
|
||||
|
||||
has_many :polls, dependent: :destroy
|
||||
|
||||
after_save do
|
||||
polls = self.extracted_polls
|
||||
self.extracted_polls = nil
|
||||
next if polls.blank? || !polls.is_a?(Hash)
|
||||
post = self
|
||||
|
||||
::Poll.transaction do
|
||||
polls.values.each { |poll| DiscoursePoll::Poll.create!(post.id, poll) }
|
||||
post.custom_fields[DiscoursePoll::HAS_POLLS] = true
|
||||
post.save_custom_fields(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module DiscoursePoll
|
||||
module UserExtension
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
prepended { has_many :poll_votes, dependent: :delete_all }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user