Commit 54881838 authored by Ruben Davila's avatar Ruben Davila

Add custom page when there is no license

parent 867fd30d
class Admin::LicensesController < Admin::ApplicationController
before_action :license, only: [:show, :download, :destroy]
before_action :require_license, only: [:show, :download, :destroy]
before_action :require_license, only: [:download, :destroy]
respond_to :html
def show
if @license.blank?
render :missing
else
@previous_licenses = License.previous
end
end
def download
send_data @license.data, filename: @license.data_filename, disposition: 'attachment'
......
- page_title "License"
%h3.page-title
Your License
= link_to 'Buy License', "#{Gitlab::SUBSCRIPTIONS_URL}/plans", target: '_blank', class: "btn btn-new pull-right"
= link_to 'Upload New License', new_admin_license_path, class: "btn pull-right"
%hr
%h4 You do not have a license.
%p You can start a 30 day free trial for all premium features.
= link_to 'Start free trial', new_trial_url, class: "btn btn-new"
......@@ -15,4 +15,26 @@ describe Admin::LicensesController do
expect(flash[:alert]).to include 'Please enter or upload a license.'
end
end
describe 'GET #show' do
context 'with an existent license' do
it 'renders the license details' do
allow(License).to receive(:current).and_return(create(:license))
get :show
expect(response).to render_template(:show)
end
end
context 'without a license' do
it 'renders missing license page' do
allow(License).to receive(:current).and_return(nil)
get :show
expect(response).to render_template(:missing)
end
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