discourse/spec/jobs/clean_up_deprecated_url_site_settings_spec.rb
Sam Saffron 9be70a22cd DEV: introduce new API to look up dynamic site setting
This removes all uses of both `send` and `public_send` from consumers of
SiteSetting and instead introduces a `get` helper for dynamic lookup

This leads to much cleaner and safer code long term as we are always explicit
to test that a site setting is really there before sending an arbitrary
string to the class

It also removes a couple of risky stubs from the auth provider test
2019-05-07 11:00:30 +10:00

31 lines
927 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Jobs::CleanUpDeprecatedUrlSiteSettings do
before do
@original_provider = SiteSetting.provider
SiteSetting.provider = SiteSettings::DbProvider.new(SiteSetting)
end
after do
SiteSetting.delete_all
SiteSetting.provider = @original_provider
end
it 'should clean up the old deprecated site settings correctly' do
logo_upload = Fabricate(:upload)
SiteSetting.logo = logo_upload
SiteSetting.set("logo_url", '/test/some/url', warn: false)
SiteSetting.set("logo_small_url", '/test/another/url', warn: false)
expect do
described_class.new.execute({})
end.to change { SiteSetting.logo_url }.from("/test/some/url").to("")
expect(SiteSetting.exists?(name: "logo_url")).to eq(false)
expect(SiteSetting.logo).to eq(logo_upload)
expect(SiteSetting.logo_small_url).to eq('/test/another/url')
end
end