Skip to content

Commit

Permalink
Merge branch 'master' into bootsnap
Browse files Browse the repository at this point in the history
  • Loading branch information
orien committed Feb 11, 2024
2 parents d386aa2 + 429bffc commit e0e1b8a
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 20 deletions.
7 changes: 4 additions & 3 deletions app/models/concerns/attr_encrypted_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ def self.included(base)
base.extend ClassMethods
end

def as_json(except: [], **options)
except += [
def as_json(options = {})
options[:except] ||= []
options[:except] += [
:encryption_key_sha,
*self.class.encrypted_attributes.keys.flat_map do |column|
[column, :"encrypted_#{column}_iv", :"encrypted_#{column}"]
end
]
super(except: except, **options)
super(options)
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/models/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def csv_line
]
end

def as_json(methods: [])
hash = super(methods: [:status, :url, :production, :commit] + methods)
def as_json(options = {})
hash = super({methods: [:status, :url, :production, :commit] + options.fetch(:methods, [])})
hash["summary"] = summary_for_timeline
hash
end
Expand Down
4 changes: 2 additions & 2 deletions plugins/datadog/test/models/datadog_deploy_event_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let(:deploy) { deploys(:succeeded_test) }

describe '.deliver' do
def deliver(*args)
DatadogDeployEvent.deliver(deploy, *args)
def deliver(**args)
DatadogDeployEvent.deliver(deploy, **args)
end

def expected_body(overrides = {})
Expand Down
4 changes: 2 additions & 2 deletions plugins/datadog/test/models/datadog_monitor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def assert_datadog_timeout(&block)
end

it "shows Alert when groups are alerting" do
assert_datadog alerting_groups do
assert_datadog(**alerting_groups) do
monitor.state(groups).must_equal "Alert"
end
end
Expand Down Expand Up @@ -110,7 +110,7 @@ def assert_datadog_timeout(&block)
it "produces no extra sql queries" do
stage = stages(:test_production) # preload
assert_sql_queries 1 do # group-stage and groups
assert_datadog alerting_groups do
assert_datadog(**alerting_groups) do
monitor.state(stage.deploy_groups)
end
end
Expand Down
3 changes: 2 additions & 1 deletion plugins/env/app/models/environment_variable_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def variable_names
environment_variables.sort_by(&:id).map(&:name).uniq
end

def as_json(methods: [], **options)
def as_json(options = {})
methods = options.delete(:methods) || []
super({methods: [:variable_names] + methods}.merge(options))
end

Expand Down
2 changes: 1 addition & 1 deletion test/controllers/integrations/travis_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe Integrations::TravisController do
extend IntegrationsControllerTestHelper

def post(_action, options)
def post(_action, **options)
options[:params][:payload] = options[:params][:payload].to_json
super
end
Expand Down
4 changes: 2 additions & 2 deletions test/lib/samson/form_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ def fake_erb_rendering

# NOTE: ideally don't use a plugin model, but we need something with accepts_nested_attributes_for
describe '#fields_for_many' do
def render(*args)
def render(*args, **kwargs)
project.rollbar_dashboards_settings.build # TODO: this does not get rendered
builder.fields_for_many(*args) do |p|
builder.fields_for_many(*args, **kwargs) do |p|
p.text_field :base_url, placeholder: 'thing!'
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/lib/samson/secrets/vault_client_wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
it 'calls Vault::Client initialize with other arguments' do
client_args = {versioned_kv: true, use_ssl: true, timeout: 543, ssl_timeout: 345}

client = Samson::Secrets::VaultClientWrapper.new(client_args)
client = Samson::Secrets::VaultClientWrapper.new(**client_args)

client.instance_variable_get(:@ssl_verify).must_equal true
client.instance_variable_get(:@timeout).must_equal 543
Expand Down
2 changes: 1 addition & 1 deletion test/models/image_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

def call(options = {})
defaults = {tag_as_latest: false, dockerfile: 'Dockerfile', tag: 'tag', cache_from: 'cache'}
ImageBuilder.build_image("foo", build, executor, defaults.merge(options))
ImageBuilder.build_image("foo", build, executor, **defaults.merge(options))
end

it "builds and pushes" do
Expand Down
6 changes: 3 additions & 3 deletions test/presenters/user_csv_presenter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

def csv_completeness_test(options = {}, expected = {})
meta_rows = 3
UserCsvPresenter.to_csv(options).split("\n").size.must_equal expected + meta_rows
UserCsvPresenter.to_csv(options).split("\n")[-2].split(",")[-1].to_i.must_equal expected
UserCsvPresenter.to_csv(**options).split("\n").size.must_equal expected + meta_rows
UserCsvPresenter.to_csv(**options).split("\n")[-2].split(",")[-1].to_i.must_equal expected
end

# on updating #csv_line this test helper may need to be updated
# This tests the optimized logic against the non-optimized logic.
def csv_accuracy_test(options = {})
actual = CSV.parse(UserCsvPresenter.to_csv(options))
actual = CSV.parse(UserCsvPresenter.to_csv(**options))
actual.shift
actual.pop(2)
actual.each do |csv_row|
Expand Down
4 changes: 2 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def warden

# catch warden throw ... which would normally go into warden middleware and then be an unauthorized response
prepend(Module.new do
def process(*args)
catch(:warden) { return super }
def process(...)
catch(:warden) { return super(...) }
response.status = :unauthorized
response.body = ":warden caught in test_helper.rb"
response
Expand Down

0 comments on commit e0e1b8a

Please sign in to comment.