thredded 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/commands/thredded/at_notification_extractor.rb +1 -0
  4. data/app/commands/thredded/autofollow_users.rb +1 -0
  5. data/app/commands/thredded/create_messageboard.rb +1 -0
  6. data/app/commands/thredded/mark_all_read.rb +1 -0
  7. data/app/commands/thredded/moderate_post.rb +1 -0
  8. data/app/commands/thredded/notify_following_users.rb +1 -0
  9. data/app/commands/thredded/notify_private_topic_users.rb +1 -0
  10. data/app/controllers/concerns/thredded/new_post_params.rb +1 -0
  11. data/app/controllers/concerns/thredded/new_private_post_params.rb +1 -0
  12. data/app/controllers/concerns/thredded/new_private_topic_params.rb +1 -0
  13. data/app/controllers/concerns/thredded/new_topic_params.rb +1 -0
  14. data/app/controllers/concerns/thredded/render_preview.rb +1 -0
  15. data/app/controllers/thredded/application_controller.rb +1 -0
  16. data/app/controllers/thredded/autocomplete_users_controller.rb +1 -0
  17. data/app/controllers/thredded/messageboards_controller.rb +4 -3
  18. data/app/controllers/thredded/moderation_controller.rb +1 -0
  19. data/app/controllers/thredded/post_permalinks_controller.rb +1 -0
  20. data/app/controllers/thredded/post_previews_controller.rb +1 -0
  21. data/app/controllers/thredded/posts_controller.rb +1 -0
  22. data/app/controllers/thredded/preferences_controller.rb +4 -3
  23. data/app/controllers/thredded/private_post_permalinks_controller.rb +1 -0
  24. data/app/controllers/thredded/private_post_previews_controller.rb +1 -0
  25. data/app/controllers/thredded/private_posts_controller.rb +1 -0
  26. data/app/controllers/thredded/private_topic_previews_controller.rb +1 -0
  27. data/app/controllers/thredded/private_topics_controller.rb +1 -0
  28. data/app/controllers/thredded/read_states_controller.rb +1 -0
  29. data/app/controllers/thredded/theme_previews_controller.rb +1 -0
  30. data/app/controllers/thredded/topic_previews_controller.rb +1 -0
  31. data/app/controllers/thredded/topics_controller.rb +5 -4
  32. data/app/forms/thredded/edit_topic_form.rb +1 -0
  33. data/app/forms/thredded/post_form.rb +2 -0
  34. data/app/forms/thredded/private_post_form.rb +2 -0
  35. data/app/forms/thredded/private_topic_form.rb +1 -0
  36. data/app/forms/thredded/topic_form.rb +1 -0
  37. data/app/forms/thredded/user_preferences_form.rb +1 -0
  38. data/app/helpers/thredded/application_helper.rb +1 -0
  39. data/app/helpers/thredded/nav_helper.rb +7 -6
  40. data/app/helpers/thredded/render_helper.rb +1 -0
  41. data/app/helpers/thredded/urls_helper.rb +1 -0
  42. data/app/jobs/thredded/activity_updater_job.rb +1 -0
  43. data/app/jobs/thredded/auto_follow_and_notify_job.rb +1 -0
  44. data/app/jobs/thredded/notify_private_topic_users_job.rb +1 -0
  45. data/app/mailer_previews/thredded/base_mailer_preview.rb +2 -1
  46. data/app/mailer_previews/thredded/post_mailer_preview.rb +3 -2
  47. data/app/mailer_previews/thredded/private_topic_mailer_preview.rb +2 -1
  48. data/app/mailers/thredded/base_mailer.rb +1 -0
  49. data/app/mailers/thredded/post_mailer.rb +1 -0
  50. data/app/mailers/thredded/private_topic_mailer.rb +1 -0
  51. data/app/models/concerns/thredded/content_moderation_state.rb +1 -0
  52. data/app/models/concerns/thredded/friendly_id_reserved_words_and_pagination.rb +1 -0
  53. data/app/models/concerns/thredded/moderation_state.rb +2 -1
  54. data/app/models/concerns/thredded/notifier_preference.rb +1 -0
  55. data/app/models/concerns/thredded/post_common.rb +1 -0
  56. data/app/models/concerns/thredded/search_parser.rb +3 -2
  57. data/app/models/concerns/thredded/topic_common.rb +2 -1
  58. data/app/models/concerns/thredded/topics_search.rb +1 -0
  59. data/app/models/concerns/thredded/user_topic_read_state_common.rb +1 -0
  60. data/app/models/thredded/category.rb +2 -1
  61. data/app/models/thredded/messageboard.rb +5 -4
  62. data/app/models/thredded/messageboard_group.rb +1 -0
  63. data/app/models/thredded/messageboard_notifications_for_followed_topics.rb +2 -1
  64. data/app/models/thredded/messageboard_user.rb +1 -0
  65. data/app/models/thredded/notifications_for_followed_topics.rb +2 -1
  66. data/app/models/thredded/notifications_for_private_topics.rb +2 -1
  67. data/app/models/thredded/null_user.rb +1 -0
  68. data/app/models/thredded/null_user_topic_read_state.rb +1 -0
  69. data/app/models/thredded/post.rb +4 -3
  70. data/app/models/thredded/post_moderation_record.rb +3 -2
  71. data/app/models/thredded/private_post.rb +3 -2
  72. data/app/models/thredded/private_topic.rb +4 -3
  73. data/app/models/thredded/private_user.rb +2 -1
  74. data/app/models/thredded/stats.rb +1 -0
  75. data/app/models/thredded/topic.rb +6 -5
  76. data/app/models/thredded/topic_category.rb +1 -0
  77. data/app/models/thredded/user_detail.rb +2 -1
  78. data/app/models/thredded/user_extender.rb +2 -1
  79. data/app/models/thredded/user_messageboard_preference.rb +2 -1
  80. data/app/models/thredded/user_permissions/admin/if_admin_column_true.rb +1 -0
  81. data/app/models/thredded/user_permissions/admin/none.rb +1 -0
  82. data/app/models/thredded/user_permissions/message/readers_of_writeable_boards.rb +1 -0
  83. data/app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb +1 -0
  84. data/app/models/thredded/user_permissions/moderate/none.rb +1 -0
  85. data/app/models/thredded/user_permissions/read/all.rb +1 -0
  86. data/app/models/thredded/user_permissions/write/all.rb +1 -0
  87. data/app/models/thredded/user_permissions/write/none.rb +1 -0
  88. data/app/models/thredded/user_post_notification.rb +2 -1
  89. data/app/models/thredded/user_preference.rb +2 -1
  90. data/app/models/thredded/user_private_topic_read_state.rb +2 -1
  91. data/app/models/thredded/user_topic_follow.rb +3 -2
  92. data/app/models/thredded/user_topic_read_state.rb +2 -1
  93. data/app/notifiers/thredded/base_notifier.rb +1 -1
  94. data/app/notifiers/thredded/email_notifier.rb +1 -0
  95. data/app/policies/thredded/messageboard_group_policy.rb +1 -0
  96. data/app/policies/thredded/messageboard_policy.rb +1 -0
  97. data/app/policies/thredded/post_policy.rb +1 -0
  98. data/app/policies/thredded/private_post_policy.rb +1 -0
  99. data/app/policies/thredded/private_topic_policy.rb +1 -0
  100. data/app/policies/thredded/topic_policy.rb +1 -0
  101. data/app/view_hooks/thredded/all_view_hooks.rb +1 -0
  102. data/app/view_models/thredded/base_topic_view.rb +1 -0
  103. data/app/view_models/thredded/messageboard_group_view.rb +1 -0
  104. data/app/view_models/thredded/post_view.rb +1 -0
  105. data/app/view_models/thredded/posts_page_view.rb +1 -0
  106. data/app/view_models/thredded/private_topic_view.rb +1 -0
  107. data/app/view_models/thredded/private_topics_page_view.rb +1 -0
  108. data/app/view_models/thredded/topic_email_view.rb +1 -0
  109. data/app/view_models/thredded/topic_posts_page_view.rb +1 -0
  110. data/app/view_models/thredded/topic_view.rb +1 -0
  111. data/app/view_models/thredded/topics_page_view.rb +1 -0
  112. data/app/views/thredded/messageboards/index.html.erb +2 -2
  113. data/app/views/thredded/posts_common/actions/_edit.html.erb +2 -1
  114. data/app/views/thredded/private_topics/_header.html.erb +2 -1
  115. data/app/views/thredded/topics/_header.html.erb +2 -1
  116. data/app/views/thredded/topics/index.html.erb +1 -1
  117. data/bin/rails +1 -0
  118. data/bin/rubocop +1 -0
  119. data/config/routes.rb +13 -12
  120. data/db/migrate/20160329231848_create_thredded.rb +75 -66
  121. data/db/upgrade_migrations/20160611094616_upgrade_v0_5_to_v0_6.rb +6 -3
  122. data/db/upgrade_migrations/20160723012349_upgrade_v0_6_to_v0_7.rb +4 -1
  123. data/db/upgrade_migrations/20161019150201_upgrade_v0_7_to_v0_8.rb +4 -1
  124. data/db/upgrade_migrations/20161113161801_upgrade_v0_8_to_v0_9.rb +11 -8
  125. data/db/upgrade_migrations/20170125033319_upgrade_v0_9_to_v0_10.rb +12 -6
  126. data/db/upgrade_migrations/20170312131417_upgrade_thredded_v0_10_to_v0_11.rb +6 -3
  127. data/db/upgrade_migrations/20170420163138_upgrade_thredded_v0_11_to_v0_12.rb +4 -1
  128. data/lib/generators/thredded/install/install_generator.rb +1 -0
  129. data/lib/generators/thredded/install/templates/initializer.rb +1 -0
  130. data/lib/tasks/thredded_tasks.rake +1 -0
  131. data/lib/thredded.rb +7 -0
  132. data/lib/thredded/base_migration.rb +14 -0
  133. data/lib/thredded/collection_to_strings_with_cache_renderer.rb +1 -0
  134. data/lib/thredded/content_formatter.rb +7 -6
  135. data/lib/thredded/database_seeder.rb +1 -0
  136. data/lib/thredded/db_tools.rb +9 -8
  137. data/lib/thredded/email_transformer.rb +1 -0
  138. data/lib/thredded/email_transformer/onebox.rb +1 -0
  139. data/lib/thredded/engine.rb +3 -2
  140. data/lib/thredded/errors.rb +1 -0
  141. data/lib/thredded/formatting_demo_content.rb +1 -0
  142. data/lib/thredded/html_pipeline/at_mention_filter.rb +3 -2
  143. data/lib/thredded/html_pipeline/autolink_filter.rb +1 -0
  144. data/lib/thredded/html_pipeline/kramdown_filter.rb +2 -1
  145. data/lib/thredded/html_pipeline/onebox_filter.rb +2 -1
  146. data/lib/thredded/html_pipeline/wrap_iframes_filter.rb +1 -0
  147. data/lib/thredded/version.rb +2 -1
  148. data/lib/thredded/view_hooks/config.rb +1 -0
  149. data/lib/thredded/view_hooks/renderer.rb +1 -0
  150. metadata +5 -7
  151. data/db/upgrade_migrations/20160410111522_upgrade_v0_2_to_v0_3.rb +0 -63
  152. data/db/upgrade_migrations/20160429222452_upgrade_v0_3_to_v0_4.rb +0 -13
  153. data/db/upgrade_migrations/20160501151908_upgrade_v0_4_to_v0_5.rb +0 -56
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # Previews for the PrivateTopicMailer
4
5
  class PrivateTopicMailerPreview < BaseMailerPreview
@@ -9,7 +10,7 @@ module Thredded
9
10
  post
10
11
  ]),
11
12
  post,
12
- %w(glebm@test.com joel@test.com)
13
+ %w[glebm@test.com joel@test.com]
13
14
  )
14
15
  end
15
16
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class BaseMailer < Thredded.parent_mailer.constantize
4
5
  helper ::Thredded::UrlsHelper
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PostMailer < Thredded::BaseMailer
4
5
  def post_notification(post_id, emails)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PrivateTopicMailer < Thredded::BaseMailer
4
5
  def message_notification(private_topic_id, post_id, emails)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # Moderation state of a piece of content, such as a Topic or a Post.
4
5
  # Requires an integer moderation_state column, a user_id column, and a user_detail association on the including class.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'set'
3
4
  module Thredded
4
5
  # Excludes pagination routes in addition to the given list of reserved words.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # Defines a moderation_state enum
4
5
  # Requires an integer moderation_state column on the including class.
@@ -6,7 +7,7 @@ module Thredded
6
7
  extend ActiveSupport::Concern
7
8
 
8
9
  included do
9
- enum moderation_state: %i(pending_moderation approved blocked)
10
+ enum moderation_state: %i[pending_moderation approved blocked]
10
11
  validates :moderation_state, presence: true
11
12
  end
12
13
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module NotifierPreference
4
5
  extend ActiveSupport::Concern
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # @abstract Classes that include this module are expected to implement {#readers}.
4
5
  # @!method readers
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class SearchParser
4
5
  def initialize(query)
5
6
  @query = query
6
- @keywords = %w(in by order)
7
+ @keywords = %w[in by order]
7
8
  end
8
9
 
9
10
  def parse
@@ -20,7 +21,7 @@ module Thredded
20
21
  keyword_scan = @query.scan(regex)
21
22
  @query = @query.gsub(regex, '')
22
23
 
23
- next unless keyword_scan.present?
24
+ next if keyword_scan.blank?
24
25
  keyword_scan.each do |term|
25
26
  found_terms_hash[keyword] ||= []
26
27
  found_terms_hash[keyword] << term.delete(' ').split(':')[1]
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module TopicCommon
4
5
  extend ActiveSupport::Concern
@@ -6,7 +7,7 @@ module Thredded
6
7
  paginates_per 50 if respond_to?(:paginates_per)
7
8
 
8
9
  belongs_to :last_user,
9
- class_name: Thredded.user_class,
10
+ class_name: Thredded.user_class_name,
10
11
  foreign_key: 'last_user_id'
11
12
 
12
13
  scope :order_recently_posted_first, -> { order(last_post_at: :desc, id: :desc) }
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class TopicsSearch
4
5
  def initialize(query, scope)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserTopicReadStateCommon
4
5
  extend ActiveSupport::Concern
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class Category < ActiveRecord::Base
4
5
  extend FriendlyId
5
6
  belongs_to :messageboard
6
7
  has_many :topic_categories
7
8
  has_many :topics, through: :topic_categories
8
- friendly_id :name, use: [:history, :scoped], scope: :messageboard
9
+ friendly_id :name, use: %i[history scoped], scope: :messageboard
9
10
 
10
11
  validates :name, presence: true
11
12
  validates :messageboard_id, presence: true
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class Messageboard < ActiveRecord::Base
4
5
  extend FriendlyId
5
6
  friendly_id :slug_candidates,
6
- use: [:slugged, :reserved],
7
+ use: %i[slugged reserved],
7
8
  # Avoid route conflicts
8
9
  reserved_words: ::Thredded::FriendlyIdReservedWordsAndPagination.new(
9
- %w(
10
+ %w[
10
11
  admin
11
12
  autocomplete-users
12
13
  messageboards
@@ -15,7 +16,7 @@ module Thredded
15
16
  private-posts
16
17
  private-topics
17
18
  theme-preview
18
- )
19
+ ]
19
20
  )
20
21
 
21
22
  validates :name, uniqueness: true, length: { maximum: 60 }, presence: true
@@ -45,7 +46,7 @@ module Thredded
45
46
  through: :messageboard_users,
46
47
  source: :user_detail
47
48
  has_many :recently_active_users,
48
- class_name: Thredded.user_class,
49
+ class_name: Thredded.user_class_name,
49
50
  through: :recently_active_user_details,
50
51
  source: :user
51
52
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class MessageboardGroup < ActiveRecord::Base
4
5
  has_many :messageboards,
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class MessageboardNotificationsForFollowedTopics < ActiveRecord::Base
4
5
  belongs_to :user_preference,
@@ -6,7 +7,7 @@ module Thredded
6
7
  foreign_key: :user_id,
7
8
  inverse_of: :messageboard_notifications_for_followed_topics
8
9
  belongs_to :user,
9
- class_name: Thredded.user_class,
10
+ class_name: Thredded.user_class_name,
10
11
  inverse_of: :thredded_user_messageboard_preferences
11
12
  belongs_to :messageboard
12
13
  scope :for_messageboard, ->(messageboard) { where(messageboard_id: messageboard.id) }
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  # The state of a user with regards to a messageboard, such as the last time the user was active (visited)
4
5
  # the messageboard.
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class NotificationsForFollowedTopics < ActiveRecord::Base
4
5
  belongs_to :user,
5
- class_name: Thredded.user_class,
6
+ class_name: Thredded.user_class_name,
6
7
  inverse_of: :thredded_notifications_for_followed_topics
7
8
  belongs_to :messageboard # or is global
8
9
  belongs_to :user_preference,
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class NotificationsForPrivateTopics < ActiveRecord::Base
4
5
  belongs_to :user,
5
- class_name: Thredded.user_class,
6
+ class_name: Thredded.user_class_name,
6
7
  inverse_of: :thredded_notifications_for_private_topics
7
8
  belongs_to :user_preference,
8
9
  primary_key: :user_id,
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class NullUser
4
5
  include ::Thredded::UserPermissions::Read::All
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class NullUserTopicReadState
4
5
  def page
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class Post < ActiveRecord::Base
4
5
  include Thredded::PostCommon
5
6
  include Thredded::ContentModerationState
6
7
 
7
8
  belongs_to :user,
8
- class_name: Thredded.user_class,
9
+ class_name: Thredded.user_class_name,
9
10
  inverse_of: :thredded_posts
10
11
  belongs_to :messageboard,
11
12
  counter_cache: true
@@ -29,10 +30,10 @@ module Thredded
29
30
 
30
31
  validates :messageboard_id, presence: true
31
32
 
32
- after_commit :update_parent_last_user_and_time_from_last_post, on: [:create, :destroy]
33
+ after_commit :update_parent_last_user_and_time_from_last_post, on: %i[create destroy]
33
34
  after_commit :update_parent_last_user_and_time_from_last_post_if_moderation_state_changed, on: :update
34
35
 
35
- after_commit :auto_follow_and_notify, on: [:create, :update]
36
+ after_commit :auto_follow_and_notify, on: %i[create update]
36
37
 
37
38
  # @param [Integer] per_page
38
39
  # @param [Thredded.user_class] user
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PostModerationRecord < ActiveRecord::Base
4
5
  include Thredded::ModerationState
@@ -13,8 +14,8 @@ module Thredded
13
14
  belongs_to :messageboard, inverse_of: :post_moderation_records
14
15
  validates :messageboard_id, presence: true
15
16
  belongs_to :post, inverse_of: :moderation_records
16
- belongs_to :post_user, class_name: Thredded.user_class, inverse_of: :thredded_post_moderation_records
17
- belongs_to :moderator, class_name: Thredded.user_class, inverse_of: :thredded_post_moderation_records
17
+ belongs_to :post_user, class_name: Thredded.user_class_name, inverse_of: :thredded_post_moderation_records
18
+ belongs_to :moderator, class_name: Thredded.user_class_name, inverse_of: :thredded_post_moderation_records
18
19
 
19
20
  validates_each :moderation_state do |record, attr, value|
20
21
  if record.previous_moderation_state == value
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PrivatePost < ActiveRecord::Base
4
5
  include Thredded::PostCommon
5
6
 
6
7
  belongs_to :user,
7
- class_name: Thredded.user_class,
8
+ class_name: Thredded.user_class_name,
8
9
  inverse_of: :thredded_private_posts
9
10
  belongs_to :postable,
10
11
  class_name: 'Thredded::PrivateTopic',
@@ -15,7 +16,7 @@ module Thredded
15
16
  primary_key: :user_id,
16
17
  foreign_key: :user_id
17
18
 
18
- after_commit :update_parent_last_user_and_timestamp, on: [:create, :destroy]
19
+ after_commit :update_parent_last_user_and_timestamp, on: %i[create destroy]
19
20
  after_commit :notify_users, on: [:create]
20
21
 
21
22
  # @param [Integer] per_page
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PrivateTopic < ActiveRecord::Base
4
5
  include Thredded::TopicCommon
@@ -7,12 +8,12 @@ module Thredded
7
8
 
8
9
  extend FriendlyId
9
10
  friendly_id :slug_candidates,
10
- use: [:history, :reserved],
11
+ use: %i[history reserved],
11
12
  # Avoid route conflicts
12
- reserved_words: ::Thredded::FriendlyIdReservedWordsAndPagination.new(%w(new))
13
+ reserved_words: ::Thredded::FriendlyIdReservedWordsAndPagination.new(%w[new])
13
14
 
14
15
  belongs_to :user,
15
- class_name: Thredded.user_class,
16
+ class_name: Thredded.user_class_name,
16
17
  inverse_of: :thredded_private_topics
17
18
  belongs_to :user_detail,
18
19
  primary_key: :user_id,
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class PrivateUser < ActiveRecord::Base
4
5
  belongs_to :private_topic, inverse_of: :private_users
5
- belongs_to :user, class_name: Thredded.user_class, inverse_of: :thredded_private_users
6
+ belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_private_users
6
7
  end
7
8
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class Stats
4
5
  include ActionView::Helpers::NumberHelper
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class Topic < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
4
5
  include Thredded::TopicCommon
@@ -22,12 +23,12 @@ module Thredded
22
23
 
23
24
  extend FriendlyId
24
25
  friendly_id :slug_candidates,
25
- use: %i(history reserved),
26
+ use: %i[history reserved],
26
27
  # Avoid route conflicts
27
- reserved_words: ::Thredded::FriendlyIdReservedWordsAndPagination.new(%w(topics))
28
+ reserved_words: ::Thredded::FriendlyIdReservedWordsAndPagination.new(%w[topics])
28
29
 
29
30
  belongs_to :user,
30
- class_name: Thredded.user_class,
31
+ class_name: Thredded.user_class_name,
31
32
  inverse_of: :thredded_topics
32
33
 
33
34
  belongs_to :messageboard,
@@ -67,14 +68,14 @@ module Thredded
67
68
  inverse_of: :topic,
68
69
  dependent: :destroy
69
70
  has_many :followers,
70
- class_name: Thredded.user_class,
71
+ class_name: Thredded.user_class_name,
71
72
  source: :user,
72
73
  through: :user_follows
73
74
 
74
75
  delegate :name, to: :messageboard, prefix: true
75
76
 
76
77
  after_commit :update_messageboard_last_topic, on: :update, if: -> { previous_changes.include?('moderation_state') }
77
- after_update :update_last_user_and_time_from_last_post!, if: -> { previous_changes.include?('moderation_state') }
78
+ after_commit :update_last_user_and_time_from_last_post!, if: -> { previous_changes.include?('moderation_state') }
78
79
 
79
80
  after_commit :handle_messageboard_change_after_commit,
80
81
  on: :update,
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class TopicCategory < ActiveRecord::Base
4
5
  belongs_to :category
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class UserDetail < ActiveRecord::Base
4
5
  include Thredded::ModerationState
5
6
 
6
- belongs_to :user, class_name: Thredded.user_class, inverse_of: :thredded_user_detail
7
+ belongs_to :user, class_name: Thredded.user_class_name, inverse_of: :thredded_user_detail
7
8
  validates :user_id, presence: true, uniqueness: true
8
9
 
9
10
  has_many :topics, class_name: 'Thredded::Topic', foreign_key: :user_id, primary_key: :user_id
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  module UserExtender
4
5
  extend ActiveSupport::Concern
@@ -14,7 +15,7 @@ module Thredded
14
15
  opt.has_many :thredded_posts, class_name: 'Thredded::Post'
15
16
  opt.has_many :thredded_topics, class_name: 'Thredded::Topic'
16
17
  opt.has_many :thredded_private_posts, class_name: 'Thredded::PrivatePost'
17
- opt.has_many :thredded_private_topics, class_name: 'Thredded::PrivateTopic'
18
+ opt.has_many :thredded_started_private_topics, class_name: 'Thredded::PrivateTopic'
18
19
  end
19
20
 
20
21
  with_options dependent: :nullify, foreign_key: 'last_user_id', inverse_of: :last_user do |opt|
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Thredded
3
4
  class UserMessageboardPreference < ActiveRecord::Base
4
5
  belongs_to :user_preference,
@@ -6,7 +7,7 @@ module Thredded
6
7
  foreign_key: :user_id,
7
8
  inverse_of: :messageboard_preferences
8
9
  belongs_to :user,
9
- class_name: Thredded.user_class,
10
+ class_name: Thredded.user_class_name,
10
11
  inverse_of: :thredded_user_messageboard_preferences
11
12
  belongs_to :messageboard
12
13