Commit 95ceae85 authored by Markus Koller's avatar Markus Koller

Merge branch '325156-manual-sync-response' into 'master'

Adjust sync_seat_link action to respond with JSON

See merge request gitlab-org/gitlab!59532
parents df225b39 1a278b5e
......@@ -59,15 +59,15 @@ class Admin::LicensesController < Admin::ApplicationController
end
def sync_seat_link
sync_result = Gitlab::SeatLinkData.new.sync
if sync_result
flash[:notice] = _('Your license was successfully synced.')
else
flash[:error] = _('There was an error when trying to sync your license. Please verify that your instance is using an active license key.')
respond_to do |format|
format.json do
if Gitlab::SeatLinkData.new.sync
render json: { success: true }
else
render json: { success: false }, status: :unprocessable_entity
end
end
end
redirect_to admin_license_path
end
private
......
......@@ -115,22 +115,22 @@ RSpec.describe Admin::LicensesController do
context 'with seat link enabled' do
let(:seat_link_enabled) { true }
it 'redirects with a successful message' do
post :sync_seat_link
it 'returns a success response' do
post :sync_seat_link, format: :json
expect(response).to redirect_to(admin_license_path)
expect(flash[:notice]).to eq('Your license was successfully synced.')
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'success' => true })
end
end
context 'with seat link disabled' do
let(:seat_link_enabled) { false }
it 'redirects with an error message' do
post :sync_seat_link
it 'returns a failure response' do
post :sync_seat_link, format: :json
expect(response).to redirect_to(admin_license_path)
expect(flash[:error]).to match('There was an error when trying to sync your license.')
expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response).to eq({ 'success' => false })
end
end
end
......
......@@ -31959,9 +31959,6 @@ msgstr ""
msgid "There was an error when subscribing to this label."
msgstr ""
msgid "There was an error when trying to sync your license. Please verify that your instance is using an active license key."
msgstr ""
msgid "There was an error when unsubscribing from this label."
msgstr ""
......@@ -36591,9 +36588,6 @@ msgstr ""
msgid "Your license is valid from"
msgstr ""
msgid "Your license was successfully synced."
msgstr ""
msgid "Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your %{code_open}.gitlab-license%{code_close} file."
msgstr ""
......
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