Commit 1f7aefb1 authored by Ruben Davila's avatar Ruben Davila

Fix some broken specs

parent 787ac5e9
......@@ -57,5 +57,4 @@ class Admin::TrialsController < Admin::ApplicationController
'You already have an active license key installed on this server.'
end
end
end
......@@ -20,10 +20,10 @@ module LicenseHelper
is_trial = current_license.trial?
message = ["Your Enterprise Edition #{'trial ' if is_trial}license"]
if current_license.expired?
message << "expired on #{current_license.expires_at}."
message << if current_license.expired?
"expired on #{current_license.expires_at}."
else
message << "will expire in #{pluralize(current_license.remaining_days, 'day')}."
"will expire in #{pluralize(current_license.remaining_days, 'day')}."
end
message << link_to('Buy now!', Gitlab::SUBSCRIPTIONS_PLANS_URL, target: '_blank') if is_trial
......
......@@ -143,7 +143,7 @@ class License < ActiveRecord::Base
end
end
delegate :feature_available?, to: :current, allow_nil: true
delegate :block_changes?, :feature_available?, to: :current, allow_nil: true
def reset_current
RequestStore.delete(:current_license)
......@@ -156,10 +156,6 @@ class License < ActiveRecord::Base
features[feature].to_i > 0
end
def block_changes?
current&.block_changes?
end
def load_license
license = self.last
......
- if current_user.admin? && license_message.present?
- if current_user&.admin? && license_message.present?
.alert.alert-dismissible.gitlab-ee-trial-banner.hidden.js-gitlab-ee-trial-banner{ role: 'alert', 'data-license-expiry' => current_license.expires_at }
%button.close{ type: 'button', 'data-dismiss' => 'alert', 'aria-label' => 'Dismiss banner' }
= icon('times', 'aria-hidden' => 'true')
......
......@@ -23,7 +23,7 @@ class Spinach::Features::AdminLicense < Spinach::FeatureSteps
end
step 'I should see a warning telling me the license has expired' do
expect(page).to have_content "The GitLab Enterprise Edition license expired"
expect(page).to have_content "Your Enterprise Edition license expired"
end
step 'the current license blocks changes' do
......
......@@ -9,11 +9,13 @@ describe Admin::TrialsController do
describe 'POST #create' do
context 'without an active license' do
before { expect_any_instance_of(License).to receive(:active?).and_return(false) }
before do
expect_any_instance_of(License).to receive(:active?).and_return(false)
end
context 'with a successful response from subscription endpoint' do
it 'redirects to the license detail page' do
allow_any_instance_of(Admin::TrialsController).to receive(:save_license).and_return(true)
allow_any_instance_of(described_class).to receive(:save_license).and_return(true)
post :create
......@@ -24,7 +26,7 @@ describe Admin::TrialsController do
context 'with a failing response from subscription endpoint' do
it 'shows an error message' do
allow_any_instance_of(Admin::TrialsController).to receive(:save_license).and_return(false)
allow_any_instance_of(described_class).to receive(:save_license).and_return(false)
post :create
......@@ -35,7 +37,9 @@ describe Admin::TrialsController do
end
context 'with an active license' do
before { expect_any_instance_of(License).to receive(:active?).and_return(true) }
before do
expect_any_instance_of(License).to receive(:active?).and_return(true)
end
it 'does not allow creating a trial license' do
post :create
......
......@@ -12,7 +12,9 @@ feature "Creating trial license", feature: true do
{ 'license_key' => license_data }
end
before { License.destroy_all }
before do
License.destroy_all
end
it 'allows the creation of the trial license' do
stub_request(:post, "#{Gitlab::SUBSCRIPTIONS_URL}/trials")
......@@ -54,6 +56,5 @@ feature "Creating trial license", feature: true do
expect(page).to have_content('You have already used a free trial')
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