Commit 7e9dafcd authored by Sean McGivern's avatar Sean McGivern

Merge branch 'gracefully_handle_new_license_error' into 'master'

Prevent 500 error when entering/uploading a license

See merge request !1016
parents e2d2922e 11c454e6
......@@ -17,11 +17,11 @@ class Admin::LicensesController < Admin::ApplicationController
end
def create
unless params[:license]
flash.now[:alert] = "No license was selected."
unless params[:license][:data].present? || params[:license][:data_file].present?
flash[:alert] = 'Please enter or upload a license.'
@license = License.new
render :new
redirect_to new_admin_license_path
return
end
......
---
title: Prevent 500 error when uploading/entering a blank license
merge_request: 1016
author:
require 'spec_helper'
describe Admin::LicensesController do
let(:admin) { create(:admin) }
before { sign_in(admin) }
describe 'Upload license' do
it 'redirects back when no license is entered/uploaded' do
post :create, license: { data: '' }
expect(response).to redirect_to new_admin_license_path
expect(flash[:alert]).to include 'Please enter or upload a license.'
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment