FIX: importing a theme via file was broken

This commit is contained in:
Arpit Jalan
2017-05-08 11:57:09 +05:30
parent cfb30bca80
commit e89d0a6b20
3 changed files with 22 additions and 1 deletions

View File

@ -11,6 +11,26 @@ describe Admin::ThemesController do
@user = log_in(:admin)
end
context '.import' do
let(:theme_file) do
ActionDispatch::Http::UploadedFile.new({
filename: 'sam-s-simple-theme.dcstyle.json',
tempfile: file_from_fixtures("sam-s-simple-theme.dcstyle.json", "json")
})
end
it 'imports a theme' do
xhr :post, :import, theme: theme_file
expect(response).to be_success
json = ::JSON.parse(response.body)
expect(json["theme"]["name"]).to eq("Sam's Simple Theme")
expect(json["theme"]["theme_fields"].length).to eq(2)
expect(UserHistory.where(action: UserHistory.actions[:change_theme]).count).to eq(1)
end
end
context ' .index' do
it 'correctly returns themes' do