mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 23:38:29 +08:00
DEV: Replace custom Onebox blank implementation with ActiveSupport (#23827)
We have a custom implementation of #blank? in our Onebox helpers. This is likely a legacy from when Onebox was a standalone gem. This change replaces all usages with respective incarnations of #blank?, #present?, and #presence from ActiveSupport. It changes a bunch of "unless blank" to "if present" as well.
This commit is contained in:
@ -1,19 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Onebox::Helpers do
|
||||
describe ".blank?" do
|
||||
it { expect(described_class.blank?("")).to be(true) }
|
||||
it { expect(described_class.blank?(" ")).to be(true) }
|
||||
it { expect(described_class.blank?("test")).to be(false) }
|
||||
it { expect(described_class.blank?(%w[test testing])).to be(false) }
|
||||
it { expect(described_class.blank?([])).to be(true) }
|
||||
it { expect(described_class.blank?({})).to be(true) }
|
||||
it { expect(described_class.blank?(nil)).to be(true) }
|
||||
it { expect(described_class.blank?(true)).to be(false) }
|
||||
it { expect(described_class.blank?(false)).to be(true) }
|
||||
it { expect(described_class.blank?(a: "test")).to be(false) }
|
||||
end
|
||||
|
||||
describe ".truncate" do
|
||||
let(:test_string) { "Chops off on spaces" }
|
||||
it { expect(described_class.truncate(test_string)).to eq(test_string) }
|
||||
|
Reference in New Issue
Block a user