Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
787ac5e9
Commit
787ac5e9
authored
Jul 07, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate when trying to generate trial license for a second time
parent
ad9e65ad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
2 deletions
+79
-2
app/controllers/admin/trials_controller.rb
app/controllers/admin/trials_controller.rb
+16
-2
app/models/license.rb
app/models/license.rb
+4
-0
spec/features/admin/admin_trial_spec.rb
spec/features/admin/admin_trial_spec.rb
+59
-0
No files found.
app/controllers/admin/trials_controller.rb
View file @
787ac5e9
...
@@ -40,8 +40,22 @@ class Admin::TrialsController < Admin::ApplicationController
...
@@ -40,8 +40,22 @@ class Admin::TrialsController < Admin::ApplicationController
end
end
def
check_presence_of_license
def
check_presence_of_license
if
License
.
current
&
.
active
?
if
error_message
.
present
?
redirect_to
admin_license_url
,
alert:
'You already have an active license key installed on this server.'
redirect_to
admin_license_url
,
alert:
error_message
.
html_safe
end
end
end
end
private
def
error_message
@message
||=
if
License
.
trial
.
present?
<<~
MSG
You have already used a free trial, if you want to extend it please contact us at
<a href="mailto:sales@gitlab.com">sales@gitlab.com</a>
MSG
elsif
License
.
current
&
.
active?
'You already have an active license key installed on this server.'
end
end
end
end
app/models/license.rb
View file @
787ac5e9
...
@@ -166,6 +166,10 @@ class License < ActiveRecord::Base
...
@@ -166,6 +166,10 @@ class License < ActiveRecord::Base
return
unless
license
&&
license
.
valid?
return
unless
license
&&
license
.
valid?
license
license
end
end
def
trial
all
.
detect
{
|
license
|
license
.
trial?
}
end
end
end
def
data_filename
def
data_filename
...
...
spec/features/admin/admin_trial_spec.rb
0 → 100644
View file @
787ac5e9
require
'spec_helper'
feature
"Creating trial license"
,
feature:
true
do
before
do
gitlab_sign_in
:admin
end
describe
'GET /admin/trials/new'
do
context
'without a previous trial license'
do
let!
(
:license_data
)
{
create
(
:license
,
trial:
true
).
data
}
let
(
:body
)
do
{
'license_key'
=>
license_data
}
end
before
{
License
.
destroy_all
}
it
'allows the creation of the trial license'
do
stub_request
(
:post
,
"
#{
Gitlab
::
SUBSCRIPTIONS_URL
}
/trials"
)
.
to_return
(
body:
JSON
(
body
),
status:
200
,
headers:
{
'Content-Type'
=>
'application/json'
})
visit
new_admin_trials_path
fill_in
:first_name
,
with:
'John'
fill_in
:last_name
,
with:
'Doe'
fill_in
:work_email
,
with:
'john@local.dev'
fill_in
:company_name
,
with:
'GitLab'
fill_in
:phone_number
,
with:
'111-111111'
fill_in
:number_of_developers
,
with:
50
fill_in
:number_of_users
,
with:
100
select
(
'United States'
,
from:
'Country'
)
click_button
'Start your free trial'
expect
(
page
).
to
have_content
(
'Your trial license was successfully activated'
)
end
end
context
'with an active license'
do
it
'does not render the form and shows an error'
do
create
(
:license
)
visit
new_admin_trials_path
expect
(
page
).
to
have_content
(
'You already have an active license key installed on this server'
)
end
end
context
'with a previous expired trial license'
do
it
'does not render the form and shows an error'
do
create
(
:license
,
trial:
true
,
expired:
true
)
visit
new_admin_trials_path
expect
(
page
).
to
have_content
(
'You have already used a free trial'
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment