lib/decidim/cdtb/spam/user_spam_detector.rb in decidim-cdtb-0.1.8 vs lib/decidim/cdtb/spam/user_spam_detector.rb in decidim-cdtb-0.2.1

- old
+ new

@@ -9,11 +9,11 @@ # class UserSpamDetector < ::Decidim::Cdtb::Task # rubocop:disable Style/RedundantRegexpEscape URL_REGEX = %r{(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}| www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.| - (?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})}.freeze + (?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})} # rubocop:enable Style/RedundantRegexpEscape def initialize(organization = nil) @organization = organization progress_bar = { title: "Decidim::User" } @@ -38,10 +38,12 @@ end # rubocop:disable Metrics/AbcSize def do_execution(context) progress_bar = context[:progress_bar] - CSV.open("spam_users.csv", "w") do |csv| + filename= "spam_users.csv" + filepath= Rails.env.test? ? "tmp/#{filename}" : filename + CSV.open(filepath, "w") do |csv| csv_headers = ["ID", "Is suspicious?", "Name", "Email", "Nickname", "Personal URL", "About", "Organization ID", "Organization Name"] csv << csv_headers @users.find_each do |user|