instance_helper_spec.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe InstanceHelper do
  4. describe 'site_title' do
  5. it 'Uses the Setting.site_title value when it exists' do
  6. Setting.site_title = 'New site title'
  7. expect(helper.site_title).to eq 'New site title'
  8. end
  9. end
  10. describe 'site_hostname' do
  11. around do |example|
  12. before = Rails.configuration.x.local_domain
  13. example.run
  14. Rails.configuration.x.local_domain = before
  15. end
  16. it 'returns the local domain value' do
  17. Rails.configuration.x.local_domain = 'example.com'
  18. expect(helper.site_hostname).to eq 'example.com'
  19. end
  20. end
  21. describe 'favicon' do
  22. context 'when an icon exists' do
  23. let!(:favicon) { Fabricate(:site_upload, var: 'favicon') }
  24. let!(:app_icon) { Fabricate(:site_upload, var: 'app_icon') }
  25. it 'returns the URL of the icon' do
  26. expect(helper.favicon_path).to eq(favicon.file.url('48'))
  27. expect(helper.app_icon_path).to eq(app_icon.file.url('48'))
  28. end
  29. it 'returns the URL of the icon with size parameter' do
  30. expect(helper.favicon_path(16)).to eq(favicon.file.url('16'))
  31. expect(helper.app_icon_path(16)).to eq(app_icon.file.url('16'))
  32. end
  33. end
  34. context 'when an icon does not exist' do
  35. it 'returns nil' do
  36. expect(helper.favicon_path).to be_nil
  37. expect(helper.app_icon_path).to be_nil
  38. end
  39. it 'returns nil with size parameter' do
  40. expect(helper.favicon_path(16)).to be_nil
  41. expect(helper.app_icon_path(16)).to be_nil
  42. end
  43. end
  44. end
  45. end