rubocop: Style/OpenStructUse in gems
Change-Id: I1a2cdcf5e760a484d9b681abbc5806838fc4ac4b Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/356133 Reviewed-by: Aaron Ogata <aogata@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
77a2f8c841
commit
ce5bb18812
|
@ -740,6 +740,7 @@ module CanvasSanitize # :nodoc:
|
|||
SANITIZE[:protocols].freeze
|
||||
SANITIZE.freeze
|
||||
|
||||
Config = Struct.new(:sanitizer, :fields, :allow_comments)
|
||||
module ClassMethods
|
||||
def sanitize_field(*args)
|
||||
# Calls this as many times as a field is configured. Will this play
|
||||
|
@ -747,7 +748,7 @@ module CanvasSanitize # :nodoc:
|
|||
include CanvasSanitize::InstanceMethods
|
||||
extend CanvasSanitize::SingletonMethods
|
||||
|
||||
@config = OpenStruct.new
|
||||
@config = Config.new
|
||||
@config.sanitizer = []
|
||||
@config.fields = []
|
||||
@config.allow_comments = true
|
||||
|
|
|
@ -217,7 +217,8 @@ describe CanvasSecurity do
|
|||
it "falls back to Vault for the encryption key if not defined in the config file" do
|
||||
config = "test:\n another_key: true"
|
||||
expect(File).to receive(:read).with(Rails.root.join("config/security.yml").to_s).and_return(config)
|
||||
expect(Rails).to receive(:application).and_return(OpenStruct.new({ credentials: OpenStruct.new({ security_encryption_key: "secret" }) }))
|
||||
credentials = double(security_encryption_key: "secret")
|
||||
expect(Rails).to receive(:application).and_return(instance_double("Rails::Application", credentials:))
|
||||
expect(CanvasSecurity.config).to eq("encryption_key" => "secret", "another_key" => true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ describe LiveEvents::AsyncWorker do
|
|||
describe "push" do
|
||||
it "executes stuff pushed on the queue" do
|
||||
results_double = double
|
||||
results = OpenStruct.new(records: results_double)
|
||||
results = Aws::Kinesis::Types::PutRecordsOutput.new(records: results_double)
|
||||
expect(results_double).to receive(:each_with_index).and_return([])
|
||||
allow(stream_client).to receive(:put_records).and_return(results)
|
||||
|
||||
|
@ -76,7 +76,7 @@ describe LiveEvents::AsyncWorker do
|
|||
|
||||
it "batches write" do
|
||||
results_double = double
|
||||
results = OpenStruct.new(records: results_double)
|
||||
results = Aws::Kinesis::Types::PutRecordsOutput.new(records: results_double)
|
||||
expect(results_double).to receive(:each_with_index).and_return([])
|
||||
allow(stream_client).to receive(:put_records).once.and_return(results)
|
||||
@worker.start!
|
||||
|
@ -88,7 +88,7 @@ describe LiveEvents::AsyncWorker do
|
|||
|
||||
it "times batch write" do
|
||||
results_double = double
|
||||
results = OpenStruct.new(records: results_double)
|
||||
results = Aws::Kinesis::Types::PutRecordsOutput.new(records: results_double)
|
||||
allow(results_double).to receive(:each_with_index).and_return([])
|
||||
allow(stream_client).to receive(:put_records).once.and_return(results)
|
||||
|
||||
|
@ -141,9 +141,11 @@ describe LiveEvents::AsyncWorker do
|
|||
end
|
||||
|
||||
it "writes errors to logger" do
|
||||
results = OpenStruct.new(records: [
|
||||
OpenStruct.new(error_code: "failure", error_message: "failure message")
|
||||
])
|
||||
results = Aws::Kinesis::Types::PutRecordsOutput.new(
|
||||
records: [
|
||||
Aws::Kinesis::Types::PutRecordsResultEntry.new(error_code: "failure", error_message: "failure message")
|
||||
]
|
||||
)
|
||||
allow(stream_client).to receive(:put_records).once.and_return(results)
|
||||
expect(statsd_double).to receive(:time).and_yield
|
||||
expect(statsd_double).to receive(:increment).with("live_events.events.send_errors", any_args)
|
||||
|
|
|
@ -19,8 +19,26 @@
|
|||
|
||||
module AcademicBenchmark::OutcomeData
|
||||
class Base
|
||||
Options = Struct.new(:authority,
|
||||
:publication,
|
||||
:partner_id,
|
||||
:partner_key,
|
||||
:converter_class,
|
||||
:document,
|
||||
:import_immediately,
|
||||
:migration_type,
|
||||
:archive_file,
|
||||
:no_archive_file,
|
||||
:skip_import_notification,
|
||||
:skip_job_progress,
|
||||
:content_migration,
|
||||
:content_migration_id,
|
||||
:user_id,
|
||||
:migration_options,
|
||||
keyword_init: true)
|
||||
|
||||
def initialize(options = {})
|
||||
@options = OpenStruct.new(options)
|
||||
@options = Options.new(**options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue