Add tests for Site Settings import/export

- extracted out site settings rake task to a class
- added tests for import and export of site settings
This commit is contained in:
Blake Erickson
2018-03-23 14:55:17 -06:00
parent 58ec4d04c0
commit 9fdf139235
3 changed files with 70 additions and 37 deletions

View File

@ -0,0 +1,25 @@
require 'rails_helper'
describe SiteSettingsTask do
before do
Discourse::Application.load_tasks
end
describe 'export' do
it 'creates a hash of all site settings' do
h = SiteSettingsTask.export_to_hash
expect(h.count).to be > 0
end
end
describe 'import' do
it 'updates site settings' do
yml = "title: Test"
log, counts = SiteSettingsTask.import(yml)
expect(log[0]).to eq "Changed title FROM: Discourse TO: Test"
expect(counts[:updated]).to eq 1
expect(SiteSetting.title).to eq "Test"
end
end
end