* Use fetch.to_i * Rubocop: address feedback of #9430 and use kwargs
This commit is contained in:
parent
7460893159
commit
bbd56875c7
8 changed files with 20 additions and 34 deletions
|
|
@ -1,16 +1,15 @@
|
|||
# rubocop:disable Style/OptionHash
|
||||
module Authentication
|
||||
# These are meant to be called from the specific providers
|
||||
module Paths
|
||||
# Returns the authentication path for the given provider
|
||||
def self.authentication_path(provider_name, params = {})
|
||||
def self.authentication_path(provider_name, **kwargs)
|
||||
Rails.application.routes.url_helpers.public_send(
|
||||
"user_#{provider_name}_omniauth_authorize_path", params
|
||||
"user_#{provider_name}_omniauth_authorize_path", **kwargs
|
||||
)
|
||||
end
|
||||
|
||||
# Returns the sign in URL for the given provider
|
||||
def self.sign_in_path(provider_name, params = {})
|
||||
def self.sign_in_path(provider_name, **kwargs)
|
||||
url_helpers = Rails.application.routes.url_helpers
|
||||
|
||||
callback_url_helper = "user_#{provider_name}_omniauth_callback_path"
|
||||
|
|
@ -18,8 +17,7 @@ module Authentication
|
|||
callback_url: URL.url(url_helpers.public_send(callback_url_helper))
|
||||
}
|
||||
|
||||
authentication_path(provider_name, params.merge(mandatory_params))
|
||||
authentication_path(provider_name, **kwargs.merge(mandatory_params))
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Style/OptionHash
|
||||
|
|
|
|||
|
|
@ -42,14 +42,12 @@ module Authentication
|
|||
SETTINGS_URL
|
||||
end
|
||||
|
||||
# rubocop:disable Style/OptionHash
|
||||
def self.sign_in_path(params = {})
|
||||
def self.sign_in_path(**kwargs)
|
||||
::Authentication::Paths.sign_in_path(
|
||||
provider_name,
|
||||
params,
|
||||
**kwargs,
|
||||
)
|
||||
end
|
||||
# rubocop:enable Style/OptionHash
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
|||
|
|
@ -49,13 +49,11 @@ module Authentication
|
|||
raise SubclassResponsibility
|
||||
end
|
||||
|
||||
# rubocop:disable Style/OptionHash
|
||||
def self.authentication_path(params = {})
|
||||
::Authentication::Paths.authentication_path(provider_name, params)
|
||||
def self.authentication_path(**kwargs)
|
||||
::Authentication::Paths.authentication_path(provider_name, **kwargs)
|
||||
end
|
||||
# rubocop:enable Style/OptionHash
|
||||
|
||||
def self.sign_in_path(_params = {})
|
||||
def self.sign_in_path(**_kwargs)
|
||||
raise SubclassResponsibility
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -47,17 +47,15 @@ module Authentication
|
|||
SETTINGS_URL
|
||||
end
|
||||
|
||||
# rubocop:disable Style/OptionHash
|
||||
def self.sign_in_path(params = {})
|
||||
def self.sign_in_path(**kwargs)
|
||||
# see https://github.com/arunagw/omniauth-twitter#authentication-options
|
||||
mandatory_params = { secure_image_url: true }
|
||||
|
||||
::Authentication::Paths.sign_in_path(
|
||||
provider_name,
|
||||
params.merge(mandatory_params),
|
||||
**kwargs.merge(mandatory_params),
|
||||
)
|
||||
end
|
||||
# rubocop:enable Style/OptionHash
|
||||
|
||||
protected
|
||||
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ default: &default
|
|||
connect_timeout: 2
|
||||
checkout_timeout: 2
|
||||
variables:
|
||||
statement_timeout: <%= ENV['STATEMENT_TIMEOUT'] || 2500 %>
|
||||
statement_timeout: <%= ENV.fetch('STATEMENT_TIMEOUT', 2500).to_i %>
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
url: <%= ENV.fetch('DATABASE_URL', '') %>
|
||||
database: PracticalDeveloper_development
|
||||
variables:
|
||||
statement_timeout: <%= ENV['STATEMENT_TIMEOUT'] || 10_000 %>
|
||||
statement_timeout: <%= ENV.fetch('STATEMENT_TIMEOUT', 10_000).to_i %>
|
||||
|
||||
# The specified database role being used to connect to postgres.
|
||||
# To create additional roles in postgres see `$ createuser --help`.
|
||||
|
|
@ -67,7 +67,7 @@ test:
|
|||
url: <%= ENV['DATABASE_URL_TEST'] || ENV['DATABASE_URL'] || ''%>
|
||||
database: PracticalDeveloper_test<%= ENV['TEST_ENV_NUMBER'] %>
|
||||
variables:
|
||||
statement_timeout: <%= ENV['STATEMENT_TIMEOUT'] || 10_000 %>
|
||||
statement_timeout: <%= ENV.fetch('STATEMENT_TIMEOUT', 10_000).to_i %>
|
||||
|
||||
# As with config/secrets.yml, you never want to store sensitive information,
|
||||
# like your database password, in your source code. If your source code is
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
class NoOpHTTPClient
|
||||
# rubocop:disable Style/OptionHash
|
||||
def self.post(uri, params = {})
|
||||
def self.post(uri, **kwargs)
|
||||
# bonus, you could log or observe posted params here
|
||||
end
|
||||
# rubocop:enable Style/OptionHash
|
||||
end
|
||||
|
||||
def create_normal_notifier
|
||||
|
|
|
|||
|
|
@ -11,17 +11,15 @@ RSpec.describe "CommentsCreate", type: :request do
|
|||
sign_in user
|
||||
end
|
||||
|
||||
# rubocop:disable Style/OptionHash
|
||||
def comment_params(params = {})
|
||||
def comment_params(**kwargs)
|
||||
{
|
||||
comment: {
|
||||
body_markdown: new_body.call,
|
||||
commentable_id: article.id,
|
||||
commentable_type: "Article"
|
||||
}.merge(params)
|
||||
}.merge(kwargs)
|
||||
}
|
||||
end
|
||||
# rubocop:enable Style/OptionHash
|
||||
|
||||
it "creates a comment with proper params" do
|
||||
expect do
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
module Warden
|
||||
module Test
|
||||
module Helpers
|
||||
# rubocop:disable Style/OptionHash
|
||||
# Override Warden Test Helper login and logout methods with on_request
|
||||
# instead of on_next_request in order to prevent the race condition where
|
||||
# we make a request before the user is finished authenticating
|
||||
# https://github.com/wardencommunity/warden/blob/a317fde34a6f804bc24efee4bbbe38c76f4cf71e/lib/warden/test/helpers.rb#L19
|
||||
def login_as(user, opts = {})
|
||||
def login_as(user, **kwargs)
|
||||
Warden::Manager.on_request do |proxy|
|
||||
opts[:event] || :authentication
|
||||
proxy.set_user(user, opts)
|
||||
kwargs[:event] ||= :authentication
|
||||
proxy.set_user(user, **kwargs)
|
||||
end
|
||||
end
|
||||
# rubocop:enable Style/OptionHash
|
||||
|
||||
def logout(*scopes)
|
||||
Warden::Manager.on_request do |proxy|
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue