Skip to content
Snippets Groups Projects
Commit 579550dd authored by Kerri Miller's avatar Kerri Miller :red_circle:
Browse files

Remove unused helper methods

This module was added in
!129392, but the 2
public methods it contains are unused, and confirmed with the original
author to be targets for removal. Testing has shown that the private
methods contained herein are still in use, and thus should remain in
place for now.
parent 95ae933a
No related branches found
No related tags found
1 merge request!135022Remove unused methods in ViteHelper module
# frozen_string_literal: true
module ViteHelper
def universal_javascript_include_tag(*args)
if vite_enabled
vite_javascript_tag(*args)
else
javascript_include_tag(*args)
end
end
def universal_asset_path(*args)
if vite_enabled
vite_asset_path(*args)
else
asset_path(*args)
end
end
private
def vite_enabled
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ViteHelper, feature_category: :tooling do
let(:source) { 'foo.js' }
let(:vite_source) { 'vite/foo.js' }
let(:vite_tag) { '<tag src="vite/foo"></tag>' }
let(:webpack_source) { 'webpack/foo.js' }
let(:webpack_tag) { '<tag src="webpack/foo"></tag>' }
context 'when vite enabled' do
before do
stub_rails_env('development')
stub_feature_flags(vite: true)
allow(helper).to receive(:vite_javascript_tag).and_return(vite_tag)
allow(helper).to receive(:vite_asset_path).and_return(vite_source)
allow(helper).to receive(:vite_stylesheet_tag).and_return(vite_tag)
allow(helper).to receive(:vite_asset_url).and_return(vite_source)
allow(helper).to receive(:vite_running).and_return(true)
end
describe '#universal_javascript_include_tag' do
it 'returns vite javascript tag' do
expect(helper.universal_javascript_include_tag(source)).to eq(vite_tag)
end
end
describe '#universal_asset_path' do
it 'returns vite asset path' do
expect(helper.universal_asset_path(source)).to eq(vite_source)
end
end
end
context 'when vite disabled' do
before do
stub_feature_flags(vite: false)
allow(helper).to receive(:javascript_include_tag).and_return(webpack_tag)
allow(helper).to receive(:asset_path).and_return(webpack_source)
allow(helper).to receive(:stylesheet_link_tag).and_return(webpack_tag)
allow(helper).to receive(:path_to_stylesheet).and_return(webpack_source)
end
describe '#universal_javascript_include_tag' do
it 'returns webpack javascript tag' do
expect(helper.universal_javascript_include_tag(source)).to eq(webpack_tag)
end
end
describe '#universal_asset_path' do
it 'returns ActionView asset path' do
expect(helper.universal_asset_path(source)).to eq(webpack_source)
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment