You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RoutingHelper, type: :helper do
  4. describe '.full_asset_url' do
  5. around do |example|
  6. use_s3 = Rails.configuration.x.use_s3
  7. example.run
  8. Rails.configuration.x.use_s3 = use_s3
  9. end
  10. shared_examples 'returns full path URL' do
  11. it 'with host' do
  12. url = helper.full_asset_url('https://example.com/avatars/000/000/002/original/icon.png')
  13. expect(url).to eq 'https://example.com/avatars/000/000/002/original/icon.png'
  14. end
  15. it 'without host' do
  16. url = helper.full_asset_url('/avatars/original/missing.png', skip_pipeline: true)
  17. expect(url).to eq 'http://test.host/avatars/original/missing.png'
  18. end
  19. end
  20. context 'Do not use S3' do
  21. before do
  22. Rails.configuration.x.use_s3 = false
  23. end
  24. it_behaves_like 'returns full path URL'
  25. end
  26. context 'Use S3' do
  27. before do
  28. Rails.configuration.x.use_s3 = true
  29. end
  30. it_behaves_like 'returns full path URL'
  31. end
  32. end
  33. end