Fix rails4 deprecation warnings
That appear when running topic_spec.rb
This commit is contained in:
parent
def134605d
commit
9ab2471a92
|
@ -1,9 +1,17 @@
|
||||||
class Category < ActiveRecord::Base
|
class Category < ActiveRecord::Base
|
||||||
belongs_to :topic, dependent: :destroy
|
belongs_to :topic, dependent: :destroy
|
||||||
belongs_to :topic_only_relative_url,
|
if rails4?
|
||||||
|
belongs_to :topic_only_relative_url,
|
||||||
|
-> { select "id, title, slug" },
|
||||||
|
class_name: "Topic",
|
||||||
|
foreign_key: "topic_id"
|
||||||
|
else
|
||||||
|
belongs_to :topic_only_relative_url,
|
||||||
select: "id, title, slug",
|
select: "id, title, slug",
|
||||||
class_name: "Topic",
|
class_name: "Topic",
|
||||||
foreign_key: "topic_id"
|
foreign_key: "topic_id"
|
||||||
|
end
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
has_many :topics
|
has_many :topics
|
||||||
|
|
|
@ -212,23 +212,23 @@ class TopicQuery
|
||||||
end
|
end
|
||||||
|
|
||||||
result = result.listable_topics.includes(category: :topic_only_relative_url)
|
result = result.listable_topics.includes(category: :topic_only_relative_url)
|
||||||
result = result.where('categories.name is null or categories.name <> ?', options[:exclude_category]) if options[:exclude_category]
|
result = (rails4? ? result.where('categories.name is null or categories.name <> ?', options[:exclude_category]).references(:categories) : result.where('categories.name is null or categories.name <> ?', options[:exclude_category])) if options[:exclude_category]
|
||||||
result = result.where('categories.name = ?', options[:only_category]) if options[:only_category]
|
result = (rails4? ? result.where('categories.name = ?', options[:only_category]).references(:categories) : result.where('categories.name = ?', options[:only_category])) if options[:only_category]
|
||||||
result = result.limit(options[:per_page]) unless options[:limit] == false
|
result = result.limit(options[:per_page]) unless options[:limit] == false
|
||||||
result = result.visible if options[:visible] || @user.nil? || @user.regular?
|
result = result.visible if options[:visible] || @user.nil? || @user.regular?
|
||||||
result = result.where('topics.id <> ?', options[:except_topic_id]) if options[:except_topic_id]
|
result = (rails4? ? result.where('topics.id <> ?', options[:except_topic_id]).references(:topics) : result.where('topics.id <> ?', options[:except_topic_id])) if options[:except_topic_id]
|
||||||
result = result.offset(options[:page].to_i * options[:per_page]) if options[:page]
|
result = result.offset(options[:page].to_i * options[:per_page]) if options[:page]
|
||||||
|
|
||||||
if options[:topic_ids]
|
if options[:topic_ids]
|
||||||
result = result.where('topics.id in (?)', options[:topic_ids])
|
result = rails4? ? result.where('topics.id in (?)', options[:topic_ids]).references(:topics) : result.where('topics.id in (?)', options[:topic_ids])
|
||||||
end
|
end
|
||||||
|
|
||||||
unless @user && @user.moderator?
|
unless @user && @user.moderator?
|
||||||
category_ids = @user.secure_category_ids if @user
|
category_ids = @user.secure_category_ids if @user
|
||||||
if category_ids.present?
|
if category_ids.present?
|
||||||
result = result.where('categories.read_restricted IS NULL OR categories.read_restricted = ? OR categories.id IN (?)', false, category_ids)
|
result = rails4? ? result.where('categories.read_restricted IS NULL OR categories.read_restricted = ? OR categories.id IN (?)', false, category_ids).references(:categories) : result.where('categories.read_restricted IS NULL OR categories.read_restricted = ? OR categories.id IN (?)', false, category_ids)
|
||||||
else
|
else
|
||||||
result = result.where('categories.read_restricted IS NULL OR categories.read_restricted = ?', false)
|
result = rails4? ? result.where('categories.read_restricted IS NULL OR categories.read_restricted = ?', false).references(:categories) : result.where('categories.read_restricted IS NULL OR categories.read_restricted = ?', false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Trashable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
default_scope where(with_deleted_scope_sql)
|
default_scope { where(with_deleted_scope_sql) }
|
||||||
|
|
||||||
# scope unscoped does not work
|
# scope unscoped does not work
|
||||||
belongs_to :deleted_by, class_name: 'User'
|
belongs_to :deleted_by, class_name: 'User'
|
||||||
|
|
Loading…
Reference in New Issue