Follow Zeitwerk conventions in names with acronyms
We were getting a few errors when trying out Zeitwerk: ``` expected file lib/sms_api.rb to define constant SmsApi expected file app/components/layout/common_html_attributes_component.rb to define constant Layout::CommonHtmlAttributesComponent ``` In these cases, we aren't using an inflection because we also define the `Verification::SmsController` and a few migrations containing `Html` in their class name, and none of them would work if we defined the inflection. We were also getting an error regarding classes containing WYSIWYG in its name: ``` NameError: uninitialized constant WYSIWYGSanitizer Did you mean? WysiwygSanitizer ``` In this case, adding the acronym is easier, since we never use "Wysiwyg" in the code but we use "WYSIWYG" in many places.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
class Layout::CommonHTMLAttributesComponent < ApplicationComponent
|
class Layout::CommonHtmlAttributesComponent < ApplicationComponent
|
||||||
use_helpers :rtl?
|
use_helpers :rtl?
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ module LayoutsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def common_html_attributes
|
def common_html_attributes
|
||||||
render Layout::CommonHTMLAttributesComponent.new
|
render Layout::CommonHtmlAttributesComponent.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
require "open-uri"
|
require "open-uri"
|
||||||
class SMSApi
|
class SmsApi
|
||||||
attr_accessor :client
|
attr_accessor :client
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class Verification::Sms
|
|||||||
end
|
end
|
||||||
|
|
||||||
def send_sms
|
def send_sms
|
||||||
SMSApi.new.sms_deliver(user.unconfirmed_phone, user.sms_confirmation_code)
|
SmsApi.new.sms_deliver(user.unconfirmed_phone, user.sms_confirmation_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
def verified?
|
def verified?
|
||||||
|
|||||||
@@ -18,5 +18,6 @@
|
|||||||
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||||
inflect.plural(/^(\d+)$/i, '\1')
|
inflect.plural(/^(\d+)$/i, '\1')
|
||||||
inflect.acronym "SDG"
|
inflect.acronym "SDG"
|
||||||
|
inflect.acronym "WYSIWYG"
|
||||||
inflect.irregular "organización", "organizaciones"
|
inflect.irregular "organización", "organizaciones"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe Layout::CommonHTMLAttributesComponent do
|
describe Layout::CommonHtmlAttributesComponent do
|
||||||
let(:component) { Layout::CommonHTMLAttributesComponent.new }
|
let(:component) { Layout::CommonHtmlAttributesComponent.new }
|
||||||
|
|
||||||
context "with multitenancy disabled" do
|
context "with multitenancy disabled" do
|
||||||
before { allow(Rails.application.config).to receive(:multitenancy).and_return(false) }
|
before { allow(Rails.application.config).to receive(:multitenancy).and_return(false) }
|
||||||
|
|||||||
Reference in New Issue
Block a user