DEV: Prefer `public_send` over `send`.
This commit is contained in:
parent
9be70a22cd
commit
152238b4cf
|
@ -108,7 +108,7 @@ class Admin::BadgesController < Admin::AdminController
|
|||
params.permit(*allowed)
|
||||
|
||||
allowed.each do |key|
|
||||
badge.send("#{key}=" , params[key]) if params[key]
|
||||
badge.public_send("#{key}=" , params[key]) if params[key]
|
||||
end
|
||||
|
||||
# Badge query contract checks
|
||||
|
|
|
@ -113,7 +113,11 @@ class Admin::EmailController < Admin::AdminController
|
|||
params.require(:username)
|
||||
params.require(:email)
|
||||
user = User.find_by_username(params[:username])
|
||||
message, skip_reason = UserNotifications.send(:digest, user, since: params[:last_seen_at])
|
||||
|
||||
message, skip_reason = UserNotifications.public_send(:digest, user,
|
||||
since: params[:last_seen_at]
|
||||
)
|
||||
|
||||
if message
|
||||
message.to = params[:email]
|
||||
begin
|
||||
|
|
|
@ -16,7 +16,7 @@ class Admin::EmbeddingController < Admin::AdminController
|
|||
end
|
||||
|
||||
Embedding.settings.each do |s|
|
||||
@embedding.send("#{s}=", params[:embedding][s])
|
||||
@embedding.public_send("#{s}=", params[:embedding][s])
|
||||
end
|
||||
|
||||
if @embedding.save
|
||||
|
|
|
@ -157,7 +157,7 @@ class Admin::ThemesController < Admin::AdminController
|
|||
|
||||
[:name, :color_scheme_id, :user_selectable].each do |field|
|
||||
if theme_params.key?(field)
|
||||
@theme.send("#{field}=", theme_params[field])
|
||||
@theme.public_send("#{field}=", theme_params[field])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class Admin::UserFieldsController < Admin::AdminController
|
|||
|
||||
Admin::UserFieldsController.columns.each do |col|
|
||||
unless field_params[col].nil?
|
||||
field.send("#{col}=", field_params[col])
|
||||
field.public_send("#{col}=", field_params[col])
|
||||
end
|
||||
end
|
||||
update_options(field)
|
||||
|
|
|
@ -254,7 +254,7 @@ class Admin::UsersController < Admin::AdminController
|
|||
level = params[:level].to_i
|
||||
|
||||
if @user.manual_locked_trust_level.nil?
|
||||
if [0, 1, 2].include?(level) && Promotion.send("tl#{level + 1}_met?", @user)
|
||||
if [0, 1, 2].include?(level) && Promotion.public_send("tl#{level + 1}_met?", @user)
|
||||
@user.manual_locked_trust_level = level
|
||||
@user.save
|
||||
elsif level == 3 && Promotion.tl3_lost?(@user)
|
||||
|
|
|
@ -628,10 +628,10 @@ class ApplicationController < ActionController::Base
|
|||
error_obj = nil
|
||||
if opts[:additional_errors]
|
||||
error_target = opts[:additional_errors].find do |o|
|
||||
target = obj.send(o)
|
||||
target = obj.public_send(o)
|
||||
target && target.errors.present?
|
||||
end
|
||||
error_obj = obj.send(error_target) if error_target
|
||||
error_obj = obj.public_send(error_target) if error_target
|
||||
end
|
||||
render_json_error(error_obj || obj)
|
||||
end
|
||||
|
|
|
@ -240,9 +240,9 @@ class CategoriesController < ApplicationController
|
|||
draft = Draft.get(current_user, draft_key, draft_sequence) if current_user
|
||||
|
||||
%w{category topic}.each do |type|
|
||||
result.send(:"#{type}_list").draft = draft
|
||||
result.send(:"#{type}_list").draft_key = draft_key
|
||||
result.send(:"#{type}_list").draft_sequence = draft_sequence
|
||||
result.public_send(:"#{type}_list").draft = draft
|
||||
result.public_send(:"#{type}_list").draft_key = draft_key
|
||||
result.public_send(:"#{type}_list").draft_sequence = draft_sequence
|
||||
end
|
||||
|
||||
render_serialized(result, CategoryAndTopicListsSerializer, root: false)
|
||||
|
|
|
@ -117,20 +117,20 @@ class ListController < ApplicationController
|
|||
|
||||
define_method("category_#{filter}") do
|
||||
canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}"
|
||||
self.send(filter, category: @category.id)
|
||||
self.public_send(filter, category: @category.id)
|
||||
end
|
||||
|
||||
define_method("category_none_#{filter}") do
|
||||
self.send(filter, category: @category.id, no_subcategories: true)
|
||||
self.public_send(filter, category: @category.id, no_subcategories: true)
|
||||
end
|
||||
|
||||
define_method("parent_category_category_#{filter}") do
|
||||
canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}"
|
||||
self.send(filter, category: @category.id)
|
||||
self.public_send(filter, category: @category.id)
|
||||
end
|
||||
|
||||
define_method("parent_category_category_none_#{filter}") do
|
||||
self.send(filter, category: @category.id)
|
||||
self.public_send(filter, category: @category.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -142,7 +142,7 @@ class ListController < ApplicationController
|
|||
if view_method == 'top'
|
||||
top(category: @category.id)
|
||||
else
|
||||
self.send(view_method)
|
||||
self.public_send(view_method)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -237,7 +237,10 @@ class ListController < ApplicationController
|
|||
@link = "#{Discourse.base_url}/u/#{target_user.username}/activity/topics"
|
||||
@atom_link = "#{Discourse.base_url}/u/#{target_user.username}/activity/topics.rss"
|
||||
@description = I18n.t("rss_description.user_topics", username: target_user.username)
|
||||
@topic_list = TopicQuery.new(nil, order: 'created').send("list_topics_by", target_user)
|
||||
|
||||
@topic_list = TopicQuery
|
||||
.new(nil, order: 'created')
|
||||
.public_send("list_topics_by", target_user)
|
||||
|
||||
render 'list', formats: [:rss]
|
||||
end
|
||||
|
@ -285,15 +288,18 @@ class ListController < ApplicationController
|
|||
end
|
||||
|
||||
define_method("category_top_#{period}") do
|
||||
self.send("top_#{period}", category: @category.id)
|
||||
self.public_send("top_#{period}", category: @category.id)
|
||||
end
|
||||
|
||||
define_method("category_none_top_#{period}") do
|
||||
self.send("top_#{period}", category: @category.id, no_subcategories: true)
|
||||
self.public_send("top_#{period}",
|
||||
category: @category.id,
|
||||
no_subcategories: true
|
||||
)
|
||||
end
|
||||
|
||||
define_method("parent_category_category_top_#{period}") do
|
||||
self.send("top_#{period}", category: @category.id)
|
||||
self.public_send("top_#{period}", category: @category.id)
|
||||
end
|
||||
|
||||
# rss feed
|
||||
|
@ -398,7 +404,7 @@ class ListController < ApplicationController
|
|||
end
|
||||
|
||||
def generate_list_for(action, target_user, opts)
|
||||
TopicQuery.new(current_user, opts).send("list_#{action}", target_user)
|
||||
TopicQuery.new(current_user, opts).public_send("list_#{action}", target_user)
|
||||
end
|
||||
|
||||
def construct_url_with(action, opts, url_prefix = nil)
|
||||
|
|
|
@ -200,7 +200,10 @@ class PostsController < ApplicationController
|
|||
|
||||
post.image_sizes = params[:image_sizes] if params[:image_sizes].present?
|
||||
|
||||
if !guardian.send("can_edit?", post) && post.user_id == current_user.id && post.edit_time_limit_expired?
|
||||
if !guardian.public_send("can_edit?", post) &&
|
||||
post.user_id == current_user.id &&
|
||||
post.edit_time_limit_expired?
|
||||
|
||||
return render_json_error(I18n.t('too_late_to_edit'))
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class StaticController < ApplicationController
|
|||
@page.gsub!(/[^a-z0-9\_\-]/, '')
|
||||
|
||||
if map.has_key?(@page)
|
||||
@topic = Topic.find_by_id(SiteSetting.send(map[@page][:topic_id]))
|
||||
@topic = Topic.find_by_id(SiteSetting.get(map[@page][:topic_id]))
|
||||
raise Discourse::NotFound unless @topic
|
||||
title_prefix = if I18n.exists?("js.#{@page}")
|
||||
I18n.t("js.#{@page}")
|
||||
|
|
|
@ -1036,7 +1036,7 @@ class UsersController < ApplicationController
|
|||
result = {}
|
||||
|
||||
%W{number_of_deleted_posts number_of_flagged_posts number_of_flags_given number_of_suspensions warnings_received_count}.each do |info|
|
||||
result[info] = @user.send(info)
|
||||
result[info] = @user.public_send(info)
|
||||
end
|
||||
|
||||
render json: result
|
||||
|
|
|
@ -10,8 +10,14 @@ module Jobs
|
|||
return unless user.is_singular_admin?
|
||||
|
||||
# let's enable bootstrap mode settings
|
||||
SiteSetting.set_and_log('default_trust_level', TrustLevel[1]) if SiteSetting.get('default_trust_level') == TrustLevel[0]
|
||||
SiteSetting.set_and_log('default_email_digest_frequency', 1440) if SiteSetting.get('default_email_digest_frequency') == 10080
|
||||
if SiteSetting.default_trust_level == TrustLevel[0]
|
||||
SiteSetting.set_and_log('default_trust_level', TrustLevel[1])
|
||||
end
|
||||
|
||||
if SiteSetting.default_email_digest_frequency == 10080
|
||||
SiteSetting.set_and_log('default_email_digest_frequency', 1440)
|
||||
end
|
||||
|
||||
SiteSetting.set_and_log('bootstrap_mode_enabled', true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -170,7 +170,7 @@ module Jobs
|
|||
end
|
||||
|
||||
message = EmailLog.unique_email_per_post(post, user) do
|
||||
UserNotifications.send(type, user, email_args)
|
||||
UserNotifications.public_send(type, user, email_args)
|
||||
end
|
||||
|
||||
# Update the to address if we have a custom one
|
||||
|
|
|
@ -7,8 +7,14 @@ module Jobs
|
|||
total_users = User.human_users.count
|
||||
|
||||
if SiteSetting.bootstrap_mode_min_users == 0 || total_users > SiteSetting.bootstrap_mode_min_users
|
||||
SiteSetting.set_and_log('default_trust_level', TrustLevel[0]) if SiteSetting.get('default_trust_level') == TrustLevel[1]
|
||||
SiteSetting.set_and_log('default_email_digest_frequency', 10080) if SiteSetting.get('default_email_digest_frequency') == 1440
|
||||
if SiteSetting.default_trust_level == TrustLevel[1]
|
||||
SiteSetting.set_and_log('default_trust_level', TrustLevel[0])
|
||||
end
|
||||
|
||||
if SiteSetting.default_email_digest_frequency == 1440
|
||||
SiteSetting.set_and_log('default_email_digest_frequency', 10080)
|
||||
end
|
||||
|
||||
SiteSetting.set_and_log('bootstrap_mode_enabled', false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ module Roleable
|
|||
end
|
||||
|
||||
def set_permission(permission_name, value)
|
||||
self.send("#{permission_name}=", value)
|
||||
self.public_send("#{permission_name}=", value)
|
||||
save_and_refresh_staff_groups!
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,10 @@ class Embedding < OpenStruct
|
|||
def self.find
|
||||
embedding_args = { id: 'default' }
|
||||
|
||||
Embedding.settings.each { |s| embedding_args[s] = SiteSetting.send(s) }
|
||||
Embedding.settings.each do |s|
|
||||
embedding_args[s] = SiteSetting.public_send(s)
|
||||
end
|
||||
|
||||
Embedding.new(embedding_args)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -111,7 +111,7 @@ class GlobalSetting
|
|||
replica_host
|
||||
replica_port
|
||||
}.each do |s|
|
||||
if val = self.send("db_#{s}")
|
||||
if val = self.public_send("db_#{s}")
|
||||
hash[s] = val
|
||||
end
|
||||
end
|
||||
|
|
|
@ -321,10 +321,12 @@ class OptimizedImage < ActiveRecord::Base
|
|||
|
||||
def self.optimize(operation, from, to, dimensions, opts = {})
|
||||
method_name = "#{operation}_instructions"
|
||||
|
||||
if !!opts[:allow_animation] && (from =~ /\.GIF$/i)
|
||||
method_name += "_animated"
|
||||
end
|
||||
instructions = self.send(method_name.to_sym, from, to, dimensions, opts)
|
||||
|
||||
instructions = self.public_send(method_name.to_sym, from, to, dimensions, opts)
|
||||
convert_with(instructions, to, opts)
|
||||
end
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ class Post < ActiveRecord::Base
|
|||
raw_links
|
||||
has_oneboxes?}.each do |attr|
|
||||
define_method(attr) do
|
||||
post_analyzer.send(attr)
|
||||
post_analyzer.public_send(attr)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -240,14 +240,14 @@ class Report
|
|||
def self.basic_report_about(report, subject_class, report_method, *args)
|
||||
report.data = []
|
||||
|
||||
subject_class.send(report_method, *args).each do |date, count|
|
||||
subject_class.public_send(report_method, *args).each do |date, count|
|
||||
report.data << { x: date, y: count }
|
||||
end
|
||||
end
|
||||
|
||||
def self.add_prev_data(report, subject_class, report_method, *args)
|
||||
if report.modes.include?(:chart) && report.facets.include?(:prev_period)
|
||||
prev_data = subject_class.send(report_method, *args)
|
||||
prev_data = subject_class.public_send(report_method, *args)
|
||||
report.prev_data = prev_data.map { |k, v| { x: k, y: v } }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ class TopTopic < ActiveRecord::Base
|
|||
|
||||
def self.update_counts_and_compute_scores_for(period)
|
||||
sort_orders.each do |sort|
|
||||
TopTopic.send("update_#{sort}_count_for", period)
|
||||
TopTopic.public_send("update_#{sort}_count_for", period)
|
||||
end
|
||||
compute_top_score_for(period)
|
||||
end
|
||||
|
|
|
@ -351,7 +351,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
def self.unstage(params)
|
||||
if user = User.where(staged: true).with_email(params[:email].strip.downcase).first
|
||||
params.each { |k, v| user.send("#{k}=", v) }
|
||||
params.each { |k, v| user.public_send("#{k}=", v) }
|
||||
user.active = false
|
||||
user.unstage
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class UsernameValidator
|
|||
#
|
||||
# Example: UsernameValidator.perform_validation(user, 'name')
|
||||
def self.perform_validation(object, field_name)
|
||||
validator = UsernameValidator.new(object.send(field_name))
|
||||
validator = UsernameValidator.new(object.public_send(field_name))
|
||||
unless validator.valid_format?
|
||||
validator.errors.each { |e| object.errors.add(field_name.to_sym, e) }
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ class AdminUserListSerializer < BasicUserSerializer
|
|||
[:days_visited, :posts_read_count, :topics_entered, :post_count].each do |sym|
|
||||
attributes sym
|
||||
define_method sym do
|
||||
object.user_stat.send(sym)
|
||||
object.user_stat.public_send(sym)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -54,10 +54,12 @@ class CategoryDetailedSerializer < BasicCategorySerializer
|
|||
end
|
||||
|
||||
def count_with_subcategories(method)
|
||||
count = object.send(method) || 0
|
||||
count = object.public_send(method) || 0
|
||||
|
||||
object.subcategories.each do |category|
|
||||
count += (category.send(method) || 0)
|
||||
count += (category.public_send(method) || 0)
|
||||
end
|
||||
|
||||
count
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class EmbeddableHostSerializer < ApplicationSerializer
|
|||
attributes *TO_SERIALIZE
|
||||
|
||||
TO_SERIALIZE.each do |attr|
|
||||
define_method(attr) { object.send(attr) }
|
||||
define_method(attr) { object.public_send(attr) }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,6 +9,6 @@ class EmbeddingSerializer < ApplicationSerializer
|
|||
end
|
||||
|
||||
def read_attribute_for_serialization(attr)
|
||||
object.respond_to?(attr) ? object.send(attr) : send(attr)
|
||||
object.respond_to?(attr) ? object.public_send(attr) : public_send(attr)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -201,7 +201,9 @@ class PostRevisionSerializer < ApplicationSerializer
|
|||
|
||||
# Retrieve any `tracked_topic_fields`
|
||||
PostRevisor.tracked_topic_fields.each_key do |field|
|
||||
latest_modifications[field.to_s] = [topic.send(field)] if topic.respond_to?(field)
|
||||
if topic.respond_to?(field)
|
||||
latest_modifications[field.to_s] = [topic.public_send(field)]
|
||||
end
|
||||
end
|
||||
|
||||
latest_modifications["featured_link"] = [post.topic.featured_link] if SiteSetting.topic_featured_link_enabled
|
||||
|
|
|
@ -14,7 +14,7 @@ class PostSerializer < BasicPostSerializer
|
|||
]
|
||||
|
||||
INSTANCE_VARS.each do |v|
|
||||
self.send(:attr_accessor, v)
|
||||
self.public_send(:attr_accessor, v)
|
||||
end
|
||||
|
||||
attributes :post_number,
|
||||
|
@ -80,9 +80,10 @@ class PostSerializer < BasicPostSerializer
|
|||
|
||||
def initialize(object, opts)
|
||||
super(object, opts)
|
||||
|
||||
PostSerializer::INSTANCE_VARS.each do |name|
|
||||
if opts.include? name
|
||||
self.send("#{name}=", opts[name])
|
||||
self.public_send("#{name}=", opts[name])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -242,7 +243,7 @@ class PostSerializer < BasicPostSerializer
|
|||
PostActionType.types.except(:bookmark).each do |sym, id|
|
||||
count_col = "#{sym}_count".to_sym
|
||||
|
||||
count = object.send(count_col) if object.respond_to?(count_col)
|
||||
count = object.public_send(count_col) if object.respond_to?(count_col)
|
||||
summary = { id: id, count: count }
|
||||
summary[:hidden] = true if sym == :vote
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@ class TopListSerializer < ApplicationSerializer
|
|||
attribute period
|
||||
|
||||
define_method(period) do
|
||||
TopicListSerializer.new(object.send(period), scope: scope).as_json if object.send(period)
|
||||
if object.public_send(period)
|
||||
TopicListSerializer.new(object.public_send(period), scope: scope).as_json
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -126,7 +126,7 @@ class NotificationEmailer
|
|||
email_user = EmailUser.new(notification)
|
||||
email_method = Notification.types[notification.notification_type]
|
||||
|
||||
email_user.send(email_method) if email_user.respond_to? email_method
|
||||
email_user.public_send(email_method) if email_user.respond_to? email_method
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -16,7 +16,11 @@ class StaffActionLogger
|
|||
|
||||
def log_user_deletion(deleted_user, opts = {})
|
||||
raise Discourse::InvalidParameters.new(:deleted_user) unless deleted_user && deleted_user.is_a?(User)
|
||||
details = USER_FIELDS.map { |x| "#{x}: #{deleted_user.send(x)}" }.join("\n")
|
||||
|
||||
details = USER_FIELDS.map do |x|
|
||||
"#{x}: #{deleted_user.public_send(x)}"
|
||||
end.join("\n")
|
||||
|
||||
UserHistory.create!(params(opts).merge(
|
||||
action: UserHistory.actions[:delete_user],
|
||||
ip_address: deleted_user.ip_address.to_s,
|
||||
|
@ -268,7 +272,11 @@ class StaffActionLogger
|
|||
|
||||
def log_badge_creation(badge)
|
||||
raise Discourse::InvalidParameters.new(:badge) unless badge
|
||||
details = BADGE_FIELDS.map { |f| [f, badge.send(f)] }.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
|
||||
|
||||
details = BADGE_FIELDS.map do |f|
|
||||
[f, badge.public_send(f)]
|
||||
end.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
|
||||
|
||||
UserHistory.create!(params.merge(
|
||||
action: UserHistory.actions[:create_badge],
|
||||
details: details.join("\n")
|
||||
|
@ -287,7 +295,11 @@ class StaffActionLogger
|
|||
|
||||
def log_badge_deletion(badge)
|
||||
raise Discourse::InvalidParameters.new(:badge) unless badge
|
||||
details = BADGE_FIELDS.map { |f| [f, badge.send(f)] }.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
|
||||
|
||||
details = BADGE_FIELDS.map do |f|
|
||||
[f, badge.public_send(f)]
|
||||
end.select { |f, v| v.present? }.map { |f, v| "#{f}: #{v}" }
|
||||
|
||||
UserHistory.create!(params.merge(
|
||||
action: UserHistory.actions[:delete_badge],
|
||||
details: details.join("\n")
|
||||
|
|
|
@ -32,7 +32,7 @@ TopicStatusUpdater = Struct.new(:topic, :user) do
|
|||
rc = Topic.where(:id => topic.id, status.name => !status.enabled)
|
||||
.update_all(status.name => status.enabled?)
|
||||
|
||||
topic.send("#{status.name}=", status.enabled?)
|
||||
topic.public_send("#{status.name}=", status.enabled?)
|
||||
result = false if rc == 0
|
||||
end
|
||||
|
||||
|
|
|
@ -113,11 +113,11 @@ class UserUpdater
|
|||
if attributes.key?(attribute)
|
||||
save_options = true
|
||||
|
||||
if [true, false].include?(user.user_option.send(attribute))
|
||||
if [true, false].include?(user.user_option.public_send(attribute))
|
||||
val = attributes[attribute].to_s == 'true'
|
||||
user.user_option.send("#{attribute}=", val)
|
||||
user.user_option.public_send("#{attribute}=", val)
|
||||
else
|
||||
user.user_option.send("#{attribute}=", attributes[attribute])
|
||||
user.user_option.public_send("#{attribute}=", attributes[attribute])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)
|
||||
ActiveRecord::Base.public_send(:include, ActiveModel::ForbiddenAttributesProtection)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# fix any bust caches post initial migration
|
||||
ActiveRecord::Base.send(:subclasses).each { |m| m.reset_column_information }
|
||||
ActiveRecord::Base.public_send(:subclasses).each { |m| m.reset_column_information }
|
||||
SiteSetting.refresh!
|
||||
|
|
|
@ -18,11 +18,11 @@ class CustomRenderer < AbstractController::Base
|
|||
end
|
||||
|
||||
def cookies
|
||||
@parent.send(:cookies)
|
||||
@parent.public_send(:cookies)
|
||||
end
|
||||
|
||||
def session
|
||||
@parent.send(:session)
|
||||
@parent.public_send(:session)
|
||||
end
|
||||
|
||||
def initialize(parent)
|
||||
|
|
|
@ -95,7 +95,9 @@ class DbHelper
|
|||
SQL
|
||||
|
||||
if rows.size > 0
|
||||
found["#{r.table_name}.#{r.column_name}"] = rows.map { |row| row.send(r.column_name) }
|
||||
found["#{r.table_name}.#{r.column_name}"] = rows.map do |row|
|
||||
row.public_send(r.column_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ module DiscourseHub
|
|||
|
||||
def self.singular_action(action, rel_url, params = {})
|
||||
connect_opts = connect_opts(params)
|
||||
JSON.parse(Excon.send(action,
|
||||
|
||||
JSON.parse(Excon.public_send(action,
|
||||
"#{hub_base_url}#{rel_url}",
|
||||
{
|
||||
headers: { 'Referer' => referer, 'Accept' => accepts.join(', ') },
|
||||
|
@ -53,7 +54,7 @@ module DiscourseHub
|
|||
def self.collection_action(action, rel_url, params = {})
|
||||
connect_opts = connect_opts(params)
|
||||
|
||||
response = Excon.send(action,
|
||||
response = Excon.public_send(action,
|
||||
"#{hub_base_url}#{rel_url}",
|
||||
{
|
||||
body: JSON[params],
|
||||
|
|
|
@ -20,7 +20,7 @@ class DiscoursePlugin
|
|||
original_class = mixin.to_s.demodulize.sub("Mixin", "")
|
||||
dependency_file_name = original_class.underscore
|
||||
require_dependency(dependency_file_name)
|
||||
original_class.constantize.send(:include, mixin)
|
||||
original_class.constantize.public_send(:include, mixin)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ class DiscourseRedis
|
|||
# prefix the key with the namespace
|
||||
def method_missing(meth, *args, &block)
|
||||
if @redis.respond_to?(meth)
|
||||
DiscourseRedis.ignore_readonly { @redis.send(meth, *args, &block) }
|
||||
DiscourseRedis.ignore_readonly { @redis.public_send(meth, *args, &block) }
|
||||
else
|
||||
super
|
||||
end
|
||||
|
@ -201,7 +201,7 @@ class DiscourseRedis
|
|||
:zremrangebyscore, :zrevrange, :zrevrangebyscore, :zrevrank, :zrangebyscore ].each do |m|
|
||||
define_method m do |*args|
|
||||
args[0] = "#{namespace}:#{args[0]}" if @namespace
|
||||
DiscourseRedis.ignore_readonly { @redis.send(m, *args) }
|
||||
DiscourseRedis.ignore_readonly { @redis.public_send(m, *args) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -107,8 +107,9 @@ module Email
|
|||
|
||||
styled = Email::Styles.new(html_override, @opts)
|
||||
styled.format_basic
|
||||
|
||||
if style = @opts[:style]
|
||||
styled.send("format_#{style}")
|
||||
styled.public_send("format_#{style}")
|
||||
end
|
||||
|
||||
Mail::Part.new do
|
||||
|
|
|
@ -345,7 +345,7 @@ module Email
|
|||
# use the first html extracter that matches
|
||||
if html_extracter = HTML_EXTRACTERS.select { |_, r| html[r] }.min_by { |_, r| html =~ r }
|
||||
doc = Nokogiri::HTML.fragment(html)
|
||||
self.send(:"extract_from_#{html_extracter[0]}", doc)
|
||||
self.public_send(:"extract_from_#{html_extracter[0]}", doc)
|
||||
else
|
||||
markdown = HtmlToMarkdown.new(html, keep_img_tags: true, keep_cid_imgs: true).to_markdown
|
||||
markdown = trim_discourse_markers(markdown)
|
||||
|
@ -1176,7 +1176,7 @@ module Email
|
|||
end
|
||||
|
||||
def send_subscription_mail(action, user)
|
||||
message = SubscriptionMailer.send(action, user)
|
||||
message = SubscriptionMailer.public_send(action, user)
|
||||
Email::Sender.new(message, :subscription).send
|
||||
end
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@ class FeedItemAccessor
|
|||
private
|
||||
|
||||
def element(element_name)
|
||||
rss_item.respond_to?(element_name) ? rss_item.send(element_name) : nil
|
||||
rss_item.respond_to?(element_name) ? rss_item.public_send(element_name) : nil
|
||||
end
|
||||
|
||||
def try_attribute_or_self(element, attribute_name)
|
||||
element.respond_to?(attribute_name) ? element.send(attribute_name) : element
|
||||
element.respond_to?(attribute_name) ? element.public_send(attribute_name) : element
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ class ActiveRecord::Base
|
|||
Discourse.deprecate("exec_sql should not be used anymore, please use DB.exec or DB.query instead!")
|
||||
|
||||
conn = ActiveRecord::Base.connection
|
||||
sql = ActiveRecord::Base.send(:sanitize_sql_array, args)
|
||||
sql = ActiveRecord::Base.public_send(:sanitize_sql_array, args)
|
||||
conn.raw_connection.async_exec(sql)
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module FreedomPatches
|
|||
SQL
|
||||
|
||||
hostname = `hostname` rescue ""
|
||||
sql = ActiveRecord::Base.send(:sanitize_sql_array, [sql, {
|
||||
sql = ActiveRecord::Base.public_send(:sanitize_sql_array, [sql, {
|
||||
version: version || "",
|
||||
duration: (time.real * 1000).to_i,
|
||||
hostname: hostname,
|
||||
|
|
|
@ -26,7 +26,7 @@ module ImportExport
|
|||
data = []
|
||||
|
||||
categories.each do |cat|
|
||||
data << CATEGORY_ATTRS.inject({}) { |h, a| h[a] = cat.send(a); h }
|
||||
data << CATEGORY_ATTRS.inject({}) { |h, a| h[a] = cat.public_send(a); h }
|
||||
end
|
||||
|
||||
data
|
||||
|
@ -53,7 +53,7 @@ module ImportExport
|
|||
return [] if group_names.empty?
|
||||
|
||||
Group.where(name: group_names).find_each do |group|
|
||||
attrs = GROUP_ATTRS.inject({}) { |h, a| h[a] = group.send(a); h }
|
||||
attrs = GROUP_ATTRS.inject({}) { |h, a| h[a] = group.public_send(a); h }
|
||||
attrs[:user_ids] = group.users.pluck(:id)
|
||||
groups << attrs
|
||||
end
|
||||
|
@ -93,11 +93,18 @@ module ImportExport
|
|||
@topics.each do |topic|
|
||||
puts topic.title
|
||||
|
||||
topic_data = TOPIC_ATTRS.inject({}) { |h, a| h[a] = topic.send(a); h; }
|
||||
topic_data = TOPIC_ATTRS.inject({}) do |h, a|
|
||||
h[a] = topic.public_send(a)
|
||||
h
|
||||
end
|
||||
|
||||
topic_data[:posts] = []
|
||||
|
||||
topic.ordered_posts.find_each do |post|
|
||||
attributes = POST_ATTRS.inject({}) { |h, a| h[a] = post.send(a); h; }
|
||||
attributes = POST_ATTRS.inject({}) do |h, a|
|
||||
h[a] = post.public_send(a)
|
||||
h
|
||||
end
|
||||
|
||||
attributes[:raw] = attributes[:raw].gsub(
|
||||
'src="/uploads',
|
||||
|
@ -139,7 +146,12 @@ module ImportExport
|
|||
|
||||
users.find_each do |u|
|
||||
next if u.id == Discourse::SYSTEM_USER_ID
|
||||
x = USER_ATTRS.inject({}) { |h, a| h[a] = u.send(a); h; }
|
||||
|
||||
x = USER_ATTRS.inject({}) do |h, a|
|
||||
h[a] = u.public_send(a)
|
||||
h
|
||||
end
|
||||
|
||||
x.merge(bio_raw: u.user_profile.bio_raw,
|
||||
website: u.user_profile.website,
|
||||
location: u.user_profile.location)
|
||||
|
|
|
@ -19,7 +19,7 @@ class MiniSqlMultisiteConnection < MiniSql::Postgres::Connection
|
|||
class ParamEncoder
|
||||
def encode(*sql_array)
|
||||
# use active record to avoid any discrepencies
|
||||
ActiveRecord::Base.send(:sanitize_sql_array, sql_array)
|
||||
ActiveRecord::Base.public_send(:sanitize_sql_array, sql_array)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -95,11 +95,11 @@ class Plugin::Instance
|
|||
|
||||
if define_include_method
|
||||
# Don't include serialized methods if the plugin is disabled
|
||||
klass.send(:define_method, "include_#{attr}?") { plugin.enabled? }
|
||||
klass.public_send(:define_method, "include_#{attr}?") { plugin.enabled? }
|
||||
end
|
||||
end
|
||||
|
||||
klass.send(:define_method, attr, &block)
|
||||
klass.public_send(:define_method, attr, &block)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -170,10 +170,10 @@ class Plugin::Instance
|
|||
reloadable_patch do |plugin|
|
||||
klass = class_name.to_s.classify.constantize rescue class_name.to_s.constantize
|
||||
hidden_method_name = :"#{attr}_without_enable_check"
|
||||
klass.send(:define_method, hidden_method_name, &block)
|
||||
klass.public_send(:define_method, hidden_method_name, &block)
|
||||
|
||||
klass.send(:define_method, attr) do |*args|
|
||||
send(hidden_method_name, *args) if plugin.enabled?
|
||||
klass.public_send(:define_method, attr) do |*args|
|
||||
public_send(hidden_method_name, *args) if plugin.enabled?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -184,10 +184,10 @@ class Plugin::Instance
|
|||
klass = klass_name.to_s.classify.constantize rescue klass_name.to_s.constantize
|
||||
|
||||
hidden_method_name = :"#{attr}_without_enable_check"
|
||||
klass.send(:define_singleton_method, hidden_method_name, &block)
|
||||
klass.public_send(:define_singleton_method, hidden_method_name, &block)
|
||||
|
||||
klass.send(:define_singleton_method, attr) do |*args|
|
||||
send(hidden_method_name, *args) if plugin.enabled?
|
||||
klass.public_send(:define_singleton_method, attr) do |*args|
|
||||
public_send(hidden_method_name, *args) if plugin.enabled?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -200,10 +200,10 @@ class Plugin::Instance
|
|||
method_name = "#{plugin.name}_#{klass.name}_#{callback}#{@idx}".underscore
|
||||
@idx += 1
|
||||
hidden_method_name = :"#{method_name}_without_enable_check"
|
||||
klass.send(:define_method, hidden_method_name, &block)
|
||||
klass.public_send(:define_method, hidden_method_name, &block)
|
||||
|
||||
klass.send(callback, options) do |*args|
|
||||
send(hidden_method_name, *args) if plugin.enabled?
|
||||
klass.public_send(callback, options) do |*args|
|
||||
public_send(hidden_method_name, *args) if plugin.enabled?
|
||||
end
|
||||
|
||||
hidden_method_name
|
||||
|
@ -243,7 +243,7 @@ class Plugin::Instance
|
|||
# Add validation method but check that the plugin is enabled
|
||||
def validate(klass, name, &block)
|
||||
klass = klass.to_s.classify.constantize
|
||||
klass.send(:define_method, name, &block)
|
||||
klass.public_send(:define_method, name, &block)
|
||||
|
||||
plugin = self
|
||||
klass.validate(name, if: -> { plugin.enabled? })
|
||||
|
@ -609,11 +609,11 @@ class Plugin::Instance
|
|||
end
|
||||
|
||||
def extend_list_method(klass, method, new_attributes)
|
||||
current_list = klass.send(method)
|
||||
current_list = klass.public_send(method)
|
||||
current_list.concat(new_attributes)
|
||||
|
||||
reloadable_patch do
|
||||
klass.send(:define_singleton_method, method) { current_list }
|
||||
klass.public_send(:define_singleton_method, method) { current_list }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class Plugin::Metadata
|
|||
attribute = attribute.strip.gsub(/ /, '_').to_sym
|
||||
|
||||
if FIELDS.include?(attribute)
|
||||
self.send("#{attribute}=", description.strip)
|
||||
self.public_send("#{attribute}=", description.strip)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ private
|
|||
|
||||
if post_action
|
||||
post_action.recover!
|
||||
action_attrs.each { |attr, val| post_action.send("#{attr}=", val) }
|
||||
action_attrs.each { |attr, val| post_action.public_send("#{attr}=", val) }
|
||||
post_action.save
|
||||
PostActionNotifier.post_action_created(post_action)
|
||||
else
|
||||
|
|
|
@ -465,7 +465,7 @@ class PostCreator
|
|||
|
||||
# Attributes we pass through to the post instance if present
|
||||
[:post_type, :no_bump, :cooking_options, :image_sizes, :acting_user, :invalidate_oneboxes, :cook_method, :via_email, :raw_email, :action_code].each do |a|
|
||||
post.send("#{a}=", @opts[a]) if @opts[a].present?
|
||||
post.public_send("#{a}=", @opts[a]) if @opts[a].present?
|
||||
end
|
||||
|
||||
post.extract_quoted_post_numbers
|
||||
|
|
|
@ -226,7 +226,9 @@ class PostRevisor
|
|||
|
||||
def post_changed?
|
||||
POST_TRACKED_FIELDS.each do |field|
|
||||
return true if @fields.has_key?(field) && @fields[field] != @post.send(field)
|
||||
if @fields.has_key?(field) && @fields[field] != @post.public_send(field)
|
||||
return true
|
||||
end
|
||||
end
|
||||
advance_draft_sequence
|
||||
false
|
||||
|
@ -362,7 +364,7 @@ class PostRevisor
|
|||
end
|
||||
|
||||
POST_TRACKED_FIELDS.each do |field|
|
||||
@post.send("#{field}=", @fields[field]) if @fields.has_key?(field)
|
||||
@post.public_send("#{field}=", @fields[field]) if @fields.has_key?(field)
|
||||
end
|
||||
|
||||
@post.last_editor_id = @editor.id
|
||||
|
|
|
@ -47,7 +47,7 @@ class Promotion
|
|||
if new_level < old_level && @user.manual_locked_trust_level.nil?
|
||||
next_up = new_level + 1
|
||||
key = "tl#{next_up}_met?"
|
||||
if self.class.respond_to?(key) && self.class.send(key, @user)
|
||||
if self.class.respond_to?(key) && self.class.public_send(key, @user)
|
||||
raise Discourse::InvalidAccess.new, I18n.t('trust_levels.change_failed_explanation',
|
||||
user_name: @user.name,
|
||||
new_trust_level: new_level,
|
||||
|
|
|
@ -159,7 +159,11 @@ module SeedData
|
|||
end
|
||||
|
||||
def find_category(site_setting_name)
|
||||
<<<<<<< HEAD
|
||||
category_id = SiteSetting.get(site_setting_name)
|
||||
=======
|
||||
category_id = SiteSetting.public_send(site_setting_name)
|
||||
>>>>>>> DEV: Prefer `public_send` over `send`.
|
||||
Category.find_by(id: category_id) if category_id > 0
|
||||
end
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class SingleSignOn
|
|||
if BOOLS.include? k
|
||||
val = ["true", "false"].include?(val) ? val == "true" : nil
|
||||
end
|
||||
sso.send("#{k}=", val)
|
||||
sso.public_send("#{k}=", val)
|
||||
end
|
||||
|
||||
decoded_hash.each do |k, v|
|
||||
|
|
|
@ -62,7 +62,7 @@ class SqlBuilder
|
|||
|
||||
sql = to_sql
|
||||
if @klass
|
||||
@klass.find_by_sql(ActiveRecord::Base.send(:sanitize_sql_array, [sql, @args]))
|
||||
@klass.find_by_sql(ActiveRecord::Base.public_send(:sanitize_sql_array, [sql, @args]))
|
||||
else
|
||||
if @args == {}
|
||||
ActiveRecord::Base.exec_sql(sql)
|
||||
|
|
|
@ -92,7 +92,7 @@ class TopicCreator
|
|||
else "track!"
|
||||
end
|
||||
|
||||
topic.notifier.send(action, gu.user_id)
|
||||
topic.notifier.public_send(action, gu.user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1033,6 +1033,6 @@ class TopicQuery
|
|||
private
|
||||
|
||||
def sanitize_sql_array(input)
|
||||
ActiveRecord::Base.send(:sanitize_sql_array, input.join(','))
|
||||
ActiveRecord::Base.public_send(:sanitize_sql_array, input.join(','))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -125,6 +125,7 @@ class Validators::UploadValidator < ActiveModel::Validator
|
|||
else
|
||||
SiteSetting.get("max_#{type}_size_kb")
|
||||
end
|
||||
|
||||
max_size_bytes = max_size_kb.kilobytes
|
||||
|
||||
if upload.filesize > max_size_bytes
|
||||
|
|
|
@ -48,7 +48,13 @@ module DiscourseNarrativeBot
|
|||
|
||||
begin
|
||||
old_data = @data.dup
|
||||
new_post = (@skip && @state != :end) ? skip_tutorial(next_state) : self.send(action)
|
||||
|
||||
new_post =
|
||||
if (@skip && @state != :end)
|
||||
skip_tutorial(next_state)
|
||||
else
|
||||
self.public_send(action)
|
||||
end
|
||||
|
||||
if new_post
|
||||
old_state = old_data[:state]
|
||||
|
|
|
@ -532,7 +532,10 @@ module DiscourseNarrativeBot
|
|||
end
|
||||
|
||||
def url_helpers(url, opts = {})
|
||||
Rails.application.routes.url_helpers.send(url, opts.merge(host: Discourse.base_url))
|
||||
Rails.application.routes.url_helpers.public_send(
|
||||
url,
|
||||
opts.merge(host: Discourse.base_url)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,7 +77,7 @@ def top(cols, aggregator, count, aggregator_formatter = nil)
|
|||
|
||||
rows.each do |row|
|
||||
cols.length.times do |i|
|
||||
print row[i].to_s.send(col_just[i], col_widths[i])
|
||||
print row[i].to_s.public_send(col_just[i], col_widths[i])
|
||||
print " "
|
||||
end
|
||||
puts
|
||||
|
|
|
@ -57,8 +57,9 @@ module DiscoursePoll
|
|||
|
||||
# update poll
|
||||
POLL_ATTRIBUTES.each do |attr|
|
||||
old_poll.send("#{attr}=", poll.send(attr))
|
||||
old_poll.public_send("#{attr}=", poll.public_send(attr))
|
||||
end
|
||||
|
||||
old_poll.save!
|
||||
|
||||
# keep track of anonymous votes
|
||||
|
@ -102,7 +103,7 @@ module DiscoursePoll
|
|||
def self.is_different?(old_poll, new_poll, new_options)
|
||||
# an attribute was changed?
|
||||
POLL_ATTRIBUTES.each do |attr|
|
||||
return true if old_poll.send(attr) != new_poll.send(attr)
|
||||
return true if old_poll.public_send(attr) != new_poll.public_send(attr)
|
||||
end
|
||||
|
||||
# an option was changed?
|
||||
|
|
|
@ -11,7 +11,7 @@ module ImportScripts
|
|||
|
||||
def initialize(cols)
|
||||
cols.each_with_index do |col, idx|
|
||||
self.class.send(:define_method, col.downcase.gsub(/[\W]/, '_').squeeze('_')) do
|
||||
self.class.public_send(:define_method, col.downcase.gsub(/[\W]/, '_').squeeze('_')) do
|
||||
@row[idx]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ class ImportScripts::Bespoke < ImportScripts::Base
|
|||
|
||||
def initialize(cols)
|
||||
cols.each_with_index do |col, idx|
|
||||
self.class.send(:define_method, col) do
|
||||
self.class.public_send(:define_method, col) do
|
||||
@row[idx]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
|||
|
||||
def initialize(cols)
|
||||
cols.each_with_index do |col, idx|
|
||||
self.class.send(:define_method, col) do
|
||||
self.class.public_send(:define_method, col) do
|
||||
@row[idx]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,7 +48,7 @@ class Mapping
|
|||
def initialize(lines)
|
||||
|
||||
FIELDS.each do |field|
|
||||
self.send("#{field}=", 0)
|
||||
self.public_send("#{field}=", 0)
|
||||
end
|
||||
|
||||
parse_first_line(lines.shift)
|
||||
|
@ -72,7 +72,7 @@ class Mapping
|
|||
field = parts[0].downcase.sub(':', '')
|
||||
if respond_to? "#{field}="
|
||||
value = Float(parts[1]).to_i
|
||||
self.send("#{field}=", value)
|
||||
self.public_send("#{field}=", value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ def consume_mapping(map_lines, totals)
|
|||
m = Mapping.new(map_lines)
|
||||
|
||||
Mapping::FIELDS.each do |field|
|
||||
totals[field] += m.send(field)
|
||||
totals[field] += m.public_send(field)
|
||||
end
|
||||
return m
|
||||
end
|
||||
|
|
|
@ -16,18 +16,19 @@ describe Jobs::ReindexSearch do
|
|||
model = Fabricate(m.to_sym)
|
||||
SiteSetting.default_locale = locale
|
||||
subject.execute({})
|
||||
expect(model.send("#{m}_search_data").locale).to eq locale
|
||||
expect(model.public_send("#{m}_search_data").locale).to eq locale
|
||||
end
|
||||
|
||||
it "should rebuild `#{m}` when INDEX_VERSION changed" do
|
||||
model = Fabricate(m.to_sym)
|
||||
# so that search data can be reindexed
|
||||
search_data = model.send("#{m}_search_data")
|
||||
search_data = model.public_send("#{m}_search_data")
|
||||
search_data.update!(version: 0)
|
||||
model.reload
|
||||
|
||||
subject.execute({})
|
||||
expect(model.send("#{m}_search_data").version).to eq SearchIndexer::INDEX_VERSION
|
||||
expect(model.public_send("#{m}_search_data").version)
|
||||
.to eq(SearchIndexer::INDEX_VERSION)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -641,10 +641,13 @@ describe UserNotifications do
|
|||
|
||||
def expects_build_with(condition)
|
||||
UserNotifications.any_instance.expects(:build_email).with(user.email, condition)
|
||||
mailer = UserNotifications.send(mail_type, user,
|
||||
notification_type: Notification.types[notification.notification_type],
|
||||
notification_data_hash: notification.data_hash,
|
||||
post: notification.post)
|
||||
mailer = UserNotifications.public_send(
|
||||
mail_type, user,
|
||||
notification_type: Notification.types[notification.notification_type],
|
||||
notification_data_hash: notification.data_hash,
|
||||
post: notification.post
|
||||
)
|
||||
|
||||
mailer.message
|
||||
end
|
||||
|
||||
|
@ -668,7 +671,8 @@ describe UserNotifications do
|
|||
context "private_email" do
|
||||
it "doesn't support reply by email" do
|
||||
SiteSetting.private_email = true
|
||||
mailer = UserNotifications.send(
|
||||
|
||||
mailer = UserNotifications.public_send(
|
||||
mail_type,
|
||||
user,
|
||||
notification_type: Notification.types[notification.notification_type],
|
||||
|
|
|
@ -11,7 +11,7 @@ def create_notification(user_id, resp_code, matcher)
|
|||
data: { message: 'tada' }.to_json
|
||||
}
|
||||
expect(response.status).to eq(resp_code)
|
||||
expect(Notification.count).send(matcher, eq(notification_count))
|
||||
expect(Notification.count).public_send(matcher, eq(notification_count))
|
||||
end
|
||||
|
||||
def update_notification(topic_id, resp_code, matcher)
|
||||
|
@ -19,7 +19,7 @@ def update_notification(topic_id, resp_code, matcher)
|
|||
put "/notifications/#{notification.id}.json", params: { topic_id: topic_id }
|
||||
expect(response.status).to eq(resp_code)
|
||||
notification.reload
|
||||
expect(notification.topic_id).send(matcher, eq(topic_id))
|
||||
expect(notification.topic_id).public_send(matcher, eq(topic_id))
|
||||
end
|
||||
|
||||
def delete_notification(resp_code, matcher)
|
||||
|
@ -27,7 +27,7 @@ def delete_notification(resp_code, matcher)
|
|||
notification_count = Notification.count
|
||||
delete "/notifications/#{notification.id}.json"
|
||||
expect(response.status).to eq(resp_code)
|
||||
expect(Notification.count).send(matcher, eq(notification_count))
|
||||
expect(Notification.count).public_send(matcher, eq(notification_count))
|
||||
end
|
||||
|
||||
describe NotificationsController do
|
||||
|
|
|
@ -78,7 +78,7 @@ describe TopicStatusUpdater do
|
|||
topic = Fabricate(:topic, status_name => false)
|
||||
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, true)
|
||||
expect(updated).to eq(true)
|
||||
expect(topic.send("#{status_name}?")).to eq(true)
|
||||
expect(topic.public_send("#{status_name}?")).to eq(true)
|
||||
|
||||
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, true)
|
||||
expect(updated).to eq(false)
|
||||
|
@ -86,7 +86,7 @@ describe TopicStatusUpdater do
|
|||
|
||||
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, false)
|
||||
expect(updated).to eq(true)
|
||||
expect(topic.send("#{status_name}?")).to eq(false)
|
||||
expect(topic.public_send("#{status_name}?")).to eq(false)
|
||||
|
||||
updated = TopicStatusUpdater.new(topic, admin).update!(status_name, false)
|
||||
expect(updated).to eq(false)
|
||||
|
|
|
@ -462,7 +462,7 @@ describe UserMerger do
|
|||
|
||||
posts.each do |type, post|
|
||||
post.reload
|
||||
expect(post.send("#{type}_count")).to eq(1)
|
||||
expect(post.public_send("#{type}_count")).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue