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