Commit 2e332607 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'issue_695' into 'master'

Use RequestStore to cache the contents of the current License

Fixes #695 

See merge request !566
parents fa84c23a 2c07734e
......@@ -14,21 +14,27 @@ class License < ActiveRecord::Base
class << self
def current
return @current if @current
license = self.last
return unless license && license.valid?
@current = license
if RequestStore.active?
RequestStore.fetch(:current_license) { load_license }
else
load_license
end
end
def reset_current
@current = nil
RequestStore.delete(:current_license)
end
def block_changes?
!current || current.block_changes?
end
def load_license
license = self.last
return unless license && license.valid?
license
end
end
def data_filename
......
......@@ -9,7 +9,8 @@ Feature: Admin license
Then I should see to whom the license is licensed
Scenario: Viewing license when there is none
Given I visit admin license page
Given There is no license
And I visit admin license page
Then I should see a warning telling me there is no license
And I should be redirected to the license upload page
......
......@@ -10,6 +10,10 @@ class Spinach::Features::AdminLicense < Spinach::FeatureSteps
create(:license)
end
step 'there is no license' do
License.destroy_all
end
step 'I should see a warning telling me there is no license' do
expect(page).to have_content "No GitLab Enterprise Edition license has been provided yet."
end
......
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.strategy = :truncation, { except: ['licenses'] }
Spinach.hooks.before_scenario do
DatabaseCleaner.start
......
......@@ -8,7 +8,7 @@ RSpec.configure do |config|
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.strategy = :truncation, { except: ['licenses'] }
end
config.before(:each) do
......
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