mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:09:18 +08:00
DEV: Enable Style/SingleLineMethods
and Style/Semicolon
in Rubocop (#6717)
This commit is contained in:
parent
56948896ff
commit
9248ad1905
|
@ -114,3 +114,10 @@ Layout/AlignHash:
|
||||||
|
|
||||||
Bundler/OrderedGems:
|
Bundler/OrderedGems:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/SingleLineMethods:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
|
Style/Semicolon:
|
||||||
|
Enabled: true
|
||||||
|
AllowAsExpressionSeparator: true
|
|
@ -575,7 +575,7 @@ class UserNotifications < ActionMailer::Base
|
||||||
if SiteSetting.private_email?
|
if SiteSetting.private_email?
|
||||||
message = I18n.t('system_messages.contents_hidden')
|
message = I18n.t('system_messages.contents_hidden')
|
||||||
else
|
else
|
||||||
message = email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : "");
|
message = email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : "")
|
||||||
end
|
end
|
||||||
|
|
||||||
first_footer_classes = "hilight"
|
first_footer_classes = "hilight"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_dependency 'enum_site_setting';
|
require_dependency 'enum_site_setting'
|
||||||
|
|
||||||
class BackupLocationSiteSetting < EnumSiteSetting
|
class BackupLocationSiteSetting < EnumSiteSetting
|
||||||
LOCAL ||= "local"
|
LOCAL ||= "local"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class QueuedPost < ActiveRecord::Base
|
class QueuedPost < ActiveRecord::Base
|
||||||
|
|
||||||
class InvalidStateTransition < StandardError; end;
|
class InvalidStateTransition < StandardError; end
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :topic
|
belongs_to :topic
|
||||||
|
|
|
@ -6,7 +6,7 @@ class CreateEmbeddableHosts < ActiveRecord::Migration[4.2]
|
||||||
t.timestamps null: false
|
t.timestamps null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
category_id = 0;
|
category_id = 0
|
||||||
category_row = execute("SELECT c.id FROM categories AS c
|
category_row = execute("SELECT c.id FROM categories AS c
|
||||||
INNER JOIN site_settings AS s ON s.value = c.name
|
INNER JOIN site_settings AS s ON s.value = c.name
|
||||||
WHERE s.name = 'embed_category'")
|
WHERE s.name = 'embed_category'")
|
||||||
|
|
|
@ -5,8 +5,12 @@ module Autospec
|
||||||
class QunitRunner < BaseRunner
|
class QunitRunner < BaseRunner
|
||||||
|
|
||||||
WATCHERS = {}
|
WATCHERS = {}
|
||||||
def self.watch(pattern, &blk); WATCHERS[pattern] = blk; end
|
def self.watch(pattern, &blk)
|
||||||
def watchers; WATCHERS; end
|
WATCHERS[pattern] = blk
|
||||||
|
end
|
||||||
|
def watchers
|
||||||
|
WATCHERS
|
||||||
|
end
|
||||||
|
|
||||||
# Discourse specific
|
# Discourse specific
|
||||||
watch(%r{^app/assets/javascripts/discourse/(.+)\.js.es6$}) { |m| "test/javascripts/#{m[1]}-test.js.es6" }
|
watch(%r{^app/assets/javascripts/discourse/(.+)\.js.es6$}) { |m| "test/javascripts/#{m[1]}-test.js.es6" }
|
||||||
|
@ -14,8 +18,12 @@ module Autospec
|
||||||
watch(%r{^test/javascripts/.+\.js.es6$})
|
watch(%r{^test/javascripts/.+\.js.es6$})
|
||||||
|
|
||||||
RELOADERS = Set.new
|
RELOADERS = Set.new
|
||||||
def self.reload(pattern); RELOADERS << pattern; end
|
def self.reload(pattern)
|
||||||
def reloaders; RELOADERS; end
|
RELOADERS << pattern
|
||||||
|
end
|
||||||
|
def reloaders
|
||||||
|
RELOADERS
|
||||||
|
end
|
||||||
|
|
||||||
# Discourse specific
|
# Discourse specific
|
||||||
reload(%r{^test/javascripts/fixtures/.+_fixtures\.js(\.es6)?$})
|
reload(%r{^test/javascripts/fixtures/.+_fixtures\.js(\.es6)?$})
|
||||||
|
|
|
@ -3,8 +3,12 @@ module Autospec
|
||||||
class RspecRunner < BaseRunner
|
class RspecRunner < BaseRunner
|
||||||
|
|
||||||
WATCHERS = {}
|
WATCHERS = {}
|
||||||
def self.watch(pattern, &blk); WATCHERS[pattern] = blk; end
|
def self.watch(pattern, &blk)
|
||||||
def watchers; WATCHERS; end
|
WATCHERS[pattern] = blk
|
||||||
|
end
|
||||||
|
def watchers
|
||||||
|
WATCHERS
|
||||||
|
end
|
||||||
|
|
||||||
# Discourse specific
|
# Discourse specific
|
||||||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/components/#{m[1]}_spec.rb" }
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/components/#{m[1]}_spec.rb" }
|
||||||
|
@ -30,8 +34,12 @@ module Autospec
|
||||||
watch(%r{^(plugins/.*)/lib/(.*)\.rb}) { |m| "#{m[1]}/spec/lib/#{m[2]}_spec.rb" }
|
watch(%r{^(plugins/.*)/lib/(.*)\.rb}) { |m| "#{m[1]}/spec/lib/#{m[2]}_spec.rb" }
|
||||||
|
|
||||||
RELOADERS = Set.new
|
RELOADERS = Set.new
|
||||||
def self.reload(pattern); RELOADERS << pattern; end
|
def self.reload(pattern)
|
||||||
def reloaders; RELOADERS; end
|
RELOADERS << pattern
|
||||||
|
end
|
||||||
|
def reloaders
|
||||||
|
RELOADERS
|
||||||
|
end
|
||||||
|
|
||||||
# we are using a simple runner at the moment, whole idea of using a reloader is no longer needed
|
# we are using a simple runner at the moment, whole idea of using a reloader is no longer needed
|
||||||
watch("spec/rails_helper.rb")
|
watch("spec/rails_helper.rb")
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Tilt
|
||||||
ctx = MiniRacer::Context.new(timeout: 15000)
|
ctx = MiniRacer::Context.new(timeout: 15000)
|
||||||
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
||||||
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
||||||
ctx.eval("module = {}; exports = {};");
|
ctx.eval("module = {}; exports = {};")
|
||||||
ctx.attach("rails.logger.info", proc { |err| Rails.logger.info(err.to_s) })
|
ctx.attach("rails.logger.info", proc { |err| Rails.logger.info(err.to_s) })
|
||||||
ctx.attach("rails.logger.error", proc { |err| Rails.logger.error(err.to_s) })
|
ctx.attach("rails.logger.error", proc { |err| Rails.logger.error(err.to_s) })
|
||||||
ctx.eval <<JS
|
ctx.eval <<JS
|
||||||
|
|
|
@ -19,17 +19,39 @@ class Guardian
|
||||||
include TagGuardian
|
include TagGuardian
|
||||||
|
|
||||||
class AnonymousUser
|
class AnonymousUser
|
||||||
def blank?; true; end
|
def blank?
|
||||||
def admin?; false; end
|
true
|
||||||
def staff?; false; end
|
end
|
||||||
def moderator?; false; end
|
def admin?
|
||||||
def approved?; false; end
|
false
|
||||||
def staged?; false; end
|
end
|
||||||
def silenced?; false; end
|
def staff?
|
||||||
def secure_category_ids; []; end
|
false
|
||||||
def topic_create_allowed_category_ids; []; end
|
end
|
||||||
def has_trust_level?(level); false; end
|
def moderator?
|
||||||
def email; nil; end
|
false
|
||||||
|
end
|
||||||
|
def approved?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
def staged?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
def silenced?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
def secure_category_ids
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
def topic_create_allowed_category_ids
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
def has_trust_level?(level)
|
||||||
|
false
|
||||||
|
end
|
||||||
|
def email
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :can_see_emails
|
attr_accessor :can_see_emails
|
||||||
|
|
|
@ -3,7 +3,9 @@ require "nokogiri"
|
||||||
class HtmlToMarkdown
|
class HtmlToMarkdown
|
||||||
|
|
||||||
class Block < Struct.new(:name, :head, :body, :opened, :markdown)
|
class Block < Struct.new(:name, :head, :body, :opened, :markdown)
|
||||||
def initialize(name, head = "", body = "", opened = false, markdown = ""); super; end
|
def initialize(name, head = "", body = "", opened = false, markdown = "")
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(html, opts = {})
|
def initialize(html, opts = {})
|
||||||
|
|
|
@ -50,7 +50,9 @@ class Migration::SafeMigrate
|
||||||
super
|
super
|
||||||
rescue => e
|
rescue => e
|
||||||
if e.cause.is_a?(Discourse::InvalidMigration)
|
if e.cause.is_a?(Discourse::InvalidMigration)
|
||||||
def e.cause; nil; end
|
def e.cause
|
||||||
|
nil
|
||||||
|
end
|
||||||
def e.backtrace
|
def e.backtrace
|
||||||
super.reject do |frame|
|
super.reject do |frame|
|
||||||
frame =~ /safe_migrate\.rb/ || frame =~ /schema_migration_details\.rb/
|
frame =~ /safe_migrate\.rb/ || frame =~ /schema_migration_details\.rb/
|
||||||
|
|
|
@ -32,7 +32,7 @@ module Stylesheet
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.compile(stylesheet, filename, options = {})
|
def self.compile(stylesheet, filename, options = {})
|
||||||
source_map_file = options[:source_map_file] || "#{filename.sub(".scss", "")}.css.map";
|
source_map_file = options[:source_map_file] || "#{filename.sub(".scss", "")}.css.map"
|
||||||
|
|
||||||
engine = SassC::Engine.new(stylesheet,
|
engine = SassC::Engine.new(stylesheet,
|
||||||
importer: Importer,
|
importer: Importer,
|
||||||
|
|
|
@ -12,7 +12,7 @@ class AllowUserLocaleEnabledValidator
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_message
|
def error_message
|
||||||
I18n.t("site_settings.errors.user_locale_not_enabled");
|
I18n.t("site_settings.errors.user_locale_not_enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -183,14 +183,28 @@ class BulkImport::Base
|
||||||
@raw_connection.exec("SELECT setval('#{PostAction.sequence_name}', #{@last_post_action_id})") if @last_post_action_id > 0
|
@raw_connection.exec("SELECT setval('#{PostAction.sequence_name}', #{@last_post_action_id})") if @last_post_action_id > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_id_from_imported_id(id); @groups[id.to_s]; end
|
def group_id_from_imported_id(id)
|
||||||
def user_id_from_imported_id(id); @users[id.to_s]; end
|
@groups[id.to_s]
|
||||||
def category_id_from_imported_id(id); @categories[id.to_s]; end
|
end
|
||||||
def topic_id_from_imported_id(id); @topics[id.to_s]; end
|
def user_id_from_imported_id(id)
|
||||||
def post_id_from_imported_id(id); @posts[id.to_s]; end
|
@users[id.to_s]
|
||||||
|
end
|
||||||
|
def category_id_from_imported_id(id)
|
||||||
|
@categories[id.to_s]
|
||||||
|
end
|
||||||
|
def topic_id_from_imported_id(id)
|
||||||
|
@topics[id.to_s]
|
||||||
|
end
|
||||||
|
def post_id_from_imported_id(id)
|
||||||
|
@posts[id.to_s]
|
||||||
|
end
|
||||||
|
|
||||||
def post_number_from_imported_id(id); @post_number_by_post_id[post_id_from_imported_id(id)]; end
|
def post_number_from_imported_id(id)
|
||||||
def topic_id_from_imported_post_id(id); @topic_id_by_post_id[post_id_from_imported_id(id)]; end
|
@post_number_by_post_id[post_id_from_imported_id(id)]
|
||||||
|
end
|
||||||
|
def topic_id_from_imported_post_id(id)
|
||||||
|
@topic_id_by_post_id[post_id_from_imported_id(id)]
|
||||||
|
end
|
||||||
|
|
||||||
GROUP_COLUMNS ||= %i{
|
GROUP_COLUMNS ||= %i{
|
||||||
id name title bio_raw bio_cooked created_at updated_at
|
id name title bio_raw bio_cooked created_at updated_at
|
||||||
|
@ -250,7 +264,9 @@ class BulkImport::Base
|
||||||
topic_id tag_id created_at updated_at
|
topic_id tag_id created_at updated_at
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_groups(rows, &block); create_records(rows, "group", GROUP_COLUMNS, &block); end
|
def create_groups(rows, &block)
|
||||||
|
create_records(rows, "group", GROUP_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
|
||||||
def create_users(rows, &block)
|
def create_users(rows, &block)
|
||||||
@imported_usernames = {}
|
@imported_usernames = {}
|
||||||
|
@ -273,16 +289,36 @@ class BulkImport::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_user_emails(rows, &block) create_records(rows, "user_email", USER_EMAIL_COLUMNS, &block); end
|
def create_user_emails(rows, &block)
|
||||||
def create_user_stats(rows, &block) create_records(rows, "user_stat", USER_STAT_COLUMNS, &block); end
|
create_records(rows, "user_email", USER_EMAIL_COLUMNS, &block)
|
||||||
def create_user_profiles(rows, &block); create_records(rows, "user_profile", USER_PROFILE_COLUMNS, &block); end
|
end
|
||||||
def create_group_users(rows, &block); create_records(rows, "group_user", GROUP_USER_COLUMNS, &block); end
|
def create_user_stats(rows, &block)
|
||||||
def create_categories(rows, &block); create_records(rows, "category", CATEGORY_COLUMNS, &block); end
|
create_records(rows, "user_stat", USER_STAT_COLUMNS, &block)
|
||||||
def create_topics(rows, &block); create_records(rows, "topic", TOPIC_COLUMNS, &block); end
|
end
|
||||||
def create_posts(rows, &block); create_records(rows, "post", POST_COLUMNS, &block); end
|
def create_user_profiles(rows, &block)
|
||||||
def create_post_actions(rows, &block); create_records(rows, "post_action", POST_ACTION_COLUMNS, &block); end
|
create_records(rows, "user_profile", USER_PROFILE_COLUMNS, &block)
|
||||||
def create_topic_allowed_users(rows, &block); create_records(rows, "topic_allowed_user", TOPIC_ALLOWED_USER_COLUMNS, &block); end
|
end
|
||||||
def create_topic_tags(rows, &block); create_records(rows, "topic_tag", TOPIC_TAG_COLUMNS, &block); end
|
def create_group_users(rows, &block)
|
||||||
|
create_records(rows, "group_user", GROUP_USER_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
def create_categories(rows, &block)
|
||||||
|
create_records(rows, "category", CATEGORY_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
def create_topics(rows, &block)
|
||||||
|
create_records(rows, "topic", TOPIC_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
def create_posts(rows, &block)
|
||||||
|
create_records(rows, "post", POST_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
def create_post_actions(rows, &block)
|
||||||
|
create_records(rows, "post_action", POST_ACTION_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
def create_topic_allowed_users(rows, &block)
|
||||||
|
create_records(rows, "topic_allowed_user", TOPIC_ALLOWED_USER_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
def create_topic_tags(rows, &block)
|
||||||
|
create_records(rows, "topic_tag", TOPIC_TAG_COLUMNS, &block)
|
||||||
|
end
|
||||||
|
|
||||||
def process_group(group)
|
def process_group(group)
|
||||||
@groups[group[:imported_id].to_s] = group[:id] = @last_group_id += 1
|
@groups[group[:imported_id].to_s] = group[:id] = @last_group_id += 1
|
||||||
|
@ -339,7 +375,7 @@ class BulkImport::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_user_email(user_email)
|
def process_user_email(user_email)
|
||||||
user_email[:id] = @last_user_email_id += 1;
|
user_email[:id] = @last_user_email_id += 1
|
||||||
user_email[:user_id] = @users[user_email[:imported_user_id].to_s]
|
user_email[:user_id] = @users[user_email[:imported_user_id].to_s]
|
||||||
user_email[:primary] = true
|
user_email[:primary] = true
|
||||||
user_email[:created_at] ||= NOW
|
user_email[:created_at] ||= NOW
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
ctx = MiniRacer::Context.new(timeout: 15000)
|
ctx = MiniRacer::Context.new(timeout: 15000)
|
||||||
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
||||||
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
||||||
ctx.eval("module = {}; exports = {};");
|
ctx.eval("module = {}; exports = {};")
|
||||||
ctx.attach("rails.logger.info", proc { |err| puts(">> #{err.to_s}") })
|
ctx.attach("rails.logger.info", proc { |err| puts(">> #{err.to_s}") })
|
||||||
ctx.attach("rails.logger.error", proc { |err| puts(">> #{err.to_s}") })
|
ctx.attach("rails.logger.error", proc { |err| puts(">> #{err.to_s}") })
|
||||||
ctx.eval <<JS
|
ctx.eval <<JS
|
||||||
|
@ -20,5 +20,5 @@ ctx.eval(js)
|
||||||
if ARGV[0].present?
|
if ARGV[0].present?
|
||||||
source = File.read(ARGV[0])
|
source = File.read(ARGV[0])
|
||||||
js_source = ::JSON.generate(source, quirks_mode: true)
|
js_source = ::JSON.generate(source, quirks_mode: true)
|
||||||
puts ctx.eval("exports.compile(#{js_source})");
|
puts ctx.eval("exports.compile(#{js_source})")
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,7 +65,7 @@ class ImportScripts::Bespoke < ImportScripts::Base
|
||||||
first = true
|
first = true
|
||||||
row = nil
|
row = nil
|
||||||
|
|
||||||
current_row = "";
|
current_row = ""
|
||||||
double_quote_count = 0
|
double_quote_count = 0
|
||||||
|
|
||||||
File.open(filename).each_line do |line|
|
File.open(filename).each_line do |line|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ImportScripts::DrupalQA < ImportScripts::Drupal
|
||||||
GROUP BY n.nid, n.title, n.uid, n.created, f.body_value
|
GROUP BY n.nid, n.title, n.uid, n.created, f.body_value
|
||||||
LIMIT #{batch_size}
|
LIMIT #{batch_size}
|
||||||
OFFSET #{offset}
|
OFFSET #{offset}
|
||||||
", cache_rows: false);
|
", cache_rows: false)
|
||||||
|
|
||||||
break if results.size < 1
|
break if results.size < 1
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
first = true
|
first = true
|
||||||
row = nil
|
row = nil
|
||||||
|
|
||||||
current_row = "";
|
current_row = ""
|
||||||
double_quote_count = 0
|
double_quote_count = 0
|
||||||
|
|
||||||
File.open(filename).each_line do |line|
|
File.open(filename).each_line do |line|
|
||||||
|
|
|
@ -1019,7 +1019,7 @@ SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def html_for_attachments(user_id, files)
|
def html_for_attachments(user_id, files)
|
||||||
html = "";
|
html = ""
|
||||||
|
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
upload, filename = find_upload(user_id, file["attachment_id"], file["file_name"])
|
upload, filename = find_upload(user_id, file["attachment_id"], file["file_name"])
|
||||||
|
|
|
@ -172,7 +172,7 @@ class ImportScripts::Nabble < ImportScripts::Base
|
||||||
txt.gsub! /\<quote author="(.*?)"\>/, '[quote="\1"]'
|
txt.gsub! /\<quote author="(.*?)"\>/, '[quote="\1"]'
|
||||||
txt.gsub! /\<\/quote\>/, '[/quote]'
|
txt.gsub! /\<\/quote\>/, '[/quote]'
|
||||||
txt.gsub!(/\<raw\>(.*?)\<\/raw\>/m) do |match|
|
txt.gsub!(/\<raw\>(.*?)\<\/raw\>/m) do |match|
|
||||||
c = Regexp.last_match[1].indent(4);
|
c = Regexp.last_match[1].indent(4)
|
||||||
"\n#{c}\n"
|
"\n#{c}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,6 @@ module ImportScripts::PhpBB3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class UnsupportedVersionError < RuntimeError;
|
class UnsupportedVersionError < RuntimeError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ HBS
|
||||||
ctx = MiniRacer::Context.new(timeout: 15000)
|
ctx = MiniRacer::Context.new(timeout: 15000)
|
||||||
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
||||||
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
||||||
ctx.eval("module = {}; exports = {};");
|
ctx.eval("module = {}; exports = {};")
|
||||||
ctx.attach("rails.logger.info", proc { |err| puts(err.to_s) })
|
ctx.attach("rails.logger.info", proc { |err| puts(err.to_s) })
|
||||||
ctx.attach("rails.logger.error", proc { |err| puts(err.to_s) })
|
ctx.attach("rails.logger.error", proc { |err| puts(err.to_s) })
|
||||||
ctx.eval <<JS
|
ctx.eval <<JS
|
||||||
|
@ -35,4 +35,4 @@ ctx.eval(source)
|
||||||
|
|
||||||
js_source = ::JSON.generate(template, quirks_mode: true)
|
js_source = ::JSON.generate(template, quirks_mode: true)
|
||||||
|
|
||||||
puts ctx.eval("exports.compile(#{js_source})");
|
puts ctx.eval("exports.compile(#{js_source})")
|
||||||
|
|
|
@ -3,7 +3,9 @@ require 'rails_helper'
|
||||||
describe Auth::ManagedAuthenticator do
|
describe Auth::ManagedAuthenticator do
|
||||||
let(:authenticator) {
|
let(:authenticator) {
|
||||||
Class.new(described_class) do
|
Class.new(described_class) do
|
||||||
def name; "myauth" end
|
def name
|
||||||
|
"myauth"
|
||||||
|
end
|
||||||
end.new
|
end.new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +57,12 @@ describe Auth::ManagedAuthenticator do
|
||||||
|
|
||||||
it 'does not work when disabled' do
|
it 'does not work when disabled' do
|
||||||
authenticator = Class.new(described_class) do
|
authenticator = Class.new(described_class) do
|
||||||
def name; "myauth" end
|
def name
|
||||||
def can_connect_existing_user?; false end
|
"myauth"
|
||||||
|
end
|
||||||
|
def can_connect_existing_user?
|
||||||
|
false
|
||||||
|
end
|
||||||
end.new
|
end.new
|
||||||
result = authenticator.after_authenticate(hash, existing_account: user2)
|
result = authenticator.after_authenticate(hash, existing_account: user2)
|
||||||
expect(result.user.id).to eq(user1.id)
|
expect(result.user.id).to eq(user1.id)
|
||||||
|
@ -81,8 +87,12 @@ describe Auth::ManagedAuthenticator do
|
||||||
|
|
||||||
it 'does not match if match_by_email is false' do
|
it 'does not match if match_by_email is false' do
|
||||||
authenticator = Class.new(described_class) do
|
authenticator = Class.new(described_class) do
|
||||||
def name; "myauth" end
|
def name
|
||||||
def match_by_email; false end
|
"myauth"
|
||||||
|
end
|
||||||
|
def match_by_email
|
||||||
|
false
|
||||||
|
end
|
||||||
end.new
|
end.new
|
||||||
user = Fabricate(:user, email: "awesome@example.com")
|
user = Fabricate(:user, email: "awesome@example.com")
|
||||||
result = authenticator.after_authenticate(hash)
|
result = authenticator.after_authenticate(hash)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require 'rails_helper';
|
require 'rails_helper'
|
||||||
|
|
||||||
require 'guardian'
|
require 'guardian'
|
||||||
require_dependency 'post_destroyer'
|
require_dependency 'post_destroyer'
|
||||||
|
|
|
@ -36,7 +36,9 @@ describe Plugin::Instance do
|
||||||
|
|
||||||
class TroutPlugin < Plugin::Instance
|
class TroutPlugin < Plugin::Instance
|
||||||
attr_accessor :enabled
|
attr_accessor :enabled
|
||||||
def enabled?; @enabled; end
|
def enabled?
|
||||||
|
@enabled
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
|
@ -1118,13 +1118,13 @@ HTML
|
||||||
|
|
||||||
it "supports url bbcode" do
|
it "supports url bbcode" do
|
||||||
cooked = PrettyText.cook "[url]http://sam.com[/url]"
|
cooked = PrettyText.cook "[url]http://sam.com[/url]"
|
||||||
html = '<p><a href="http://sam.com" data-bbcode="true" rel="nofollow noopener">http://sam.com</a></p>';
|
html = '<p><a href="http://sam.com" data-bbcode="true" rel="nofollow noopener">http://sam.com</a></p>'
|
||||||
expect(cooked).to eq(html)
|
expect(cooked).to eq(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports nesting tags in url" do
|
it "supports nesting tags in url" do
|
||||||
cooked = PrettyText.cook("[url=http://sam.com][b]I am sam[/b][/url]")
|
cooked = PrettyText.cook("[url=http://sam.com][b]I am sam[/b][/url]")
|
||||||
html = '<p><a href="http://sam.com" data-bbcode="true" rel="nofollow noopener"><span class="bbcode-b">I am sam</span></a></p>';
|
html = '<p><a href="http://sam.com" data-bbcode="true" rel="nofollow noopener"><span class="bbcode-b">I am sam</span></a></p>'
|
||||||
expect(cooked).to eq(html)
|
expect(cooked).to eq(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,9 @@ describe ContentSecurityPolicy do
|
||||||
it 'can be extended by plugins' do
|
it 'can be extended by plugins' do
|
||||||
plugin = Class.new(Plugin::Instance) do
|
plugin = Class.new(Plugin::Instance) do
|
||||||
attr_accessor :enabled
|
attr_accessor :enabled
|
||||||
def enabled?; @enabled; end
|
def enabled?
|
||||||
|
@enabled
|
||||||
|
end
|
||||||
end.new(nil, "#{Rails.root}/spec/fixtures/plugins/csp_extension/plugin.rb")
|
end.new(nil, "#{Rails.root}/spec/fixtures/plugins/csp_extension/plugin.rb")
|
||||||
|
|
||||||
plugin.activate!
|
plugin.activate!
|
||||||
|
|
|
@ -240,7 +240,7 @@ describe TopicUser do
|
||||||
create_post(
|
create_post(
|
||||||
archetype: Archetype.private_message,
|
archetype: Archetype.private_message,
|
||||||
target_usernames: target_user.username
|
target_usernames: target_user.username
|
||||||
);
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:topic) { post.topic }
|
let(:topic) { post.topic }
|
||||||
|
|
|
@ -184,7 +184,7 @@ describe CategoriesController do
|
||||||
c3 = Fabricate(:category)
|
c3 = Fabricate(:category)
|
||||||
c4 = Fabricate(:category)
|
c4 = Fabricate(:category)
|
||||||
if c3.id < c2.id
|
if c3.id < c2.id
|
||||||
tmp = c3; c2 = c3; c3 = tmp;
|
tmp = c3; c2 = c3; c3 = tmp
|
||||||
end
|
end
|
||||||
c1.position = 8
|
c1.position = 8
|
||||||
c2.position = 6
|
c2.position = 6
|
||||||
|
|
|
@ -470,7 +470,7 @@ describe UsersController do
|
||||||
get "/u/admin-login/#{email_token.token}"
|
get "/u/admin-login/#{email_token.token}"
|
||||||
expect(response).not_to redirect_to('/')
|
expect(response).not_to redirect_to('/')
|
||||||
expect(session[:current_user_id]).not_to eq(admin.id)
|
expect(session[:current_user_id]).not_to eq(admin.id)
|
||||||
expect(response.body).to include(I18n.t('login.second_factor_description'));
|
expect(response.body).to include(I18n.t('login.second_factor_description'))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'invalid 2 factor token' do
|
describe 'invalid 2 factor token' do
|
||||||
|
@ -483,8 +483,8 @@ describe UsersController do
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(response.body).to include(I18n.t('login.second_factor_description'));
|
expect(response.body).to include(I18n.t('login.second_factor_description'))
|
||||||
expect(response.body).to include(I18n.t('login.invalid_second_factor_code'));
|
expect(response.body).to include(I18n.t('login.invalid_second_factor_code'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user