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
3a1ffbf6
Commit
3a1ffbf6
authored
Apr 25, 2018
by
blackst0ne
Committed by
Rémy Coutable
Apr 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the `admin/license.feature` spinach test with an rspec analog
parent
60039b36
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
174 additions
and
216 deletions
+174
-216
ee/changelogs/unreleased/blackst0ne-replace-spinach-admin-license-feature.yml
...ased/blackst0ne-replace-spinach-admin-license-feature.yml
+5
-0
ee/spec/features/admin/admin_license_spec.rb
ee/spec/features/admin/admin_license_spec.rb
+0
-91
ee/spec/features/admin/licenses/admin_uploads_license_spec.rb
...pec/features/admin/licenses/admin_uploads_license_spec.rb
+67
-0
ee/spec/features/admin/licenses/admin_views_license_spec.rb
ee/spec/features/admin/licenses/admin_views_license_spec.rb
+102
-0
features/admin/license.feature
features/admin/license.feature
+0
-39
features/steps/admin/license.rb
features/steps/admin/license.rb
+0
-86
No files found.
ee/changelogs/unreleased/blackst0ne-replace-spinach-admin-license-feature.yml
0 → 100644
View file @
3a1ffbf6
---
title
:
'
Replace
the
`admin/license.feature`
spinach
test
with
an
rspec
analog'
merge_request
:
5477
author
:
"
@blackst0ne"
type
:
other
ee/spec/features/admin/admin_license_spec.rb
deleted
100644 → 0
View file @
60039b36
require
'spec_helper'
feature
"License Admin"
do
before
do
sign_in
(
create
(
:admin
))
end
describe
'#show'
do
it
'shows a valid license'
do
visit
admin_license_path
expect
(
page
).
to
have_content
(
'Your license is valid'
)
page
.
within
'.license-panel'
do
expect
(
page
).
to
have_content
(
'Unlimited'
)
end
end
describe
'limited users'
do
let!
(
:license
)
{
create
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
active_user_count:
2000
}).
export
)
}
it
'shows panel counts'
do
visit
admin_license_path
page
.
within
'.license-panel'
do
expect
(
page
).
to
have_content
(
'2,000'
)
end
end
end
context
'with a trial license'
do
let!
(
:license
)
{
create
(
:license
,
trial:
true
)
}
it
'shows expiration duration with license type'
do
visit
admin_license_path
page
.
within
'.js-license-info-panel'
do
expect
(
page
).
to
have_content
(
'Expires: Free trial will expire in'
)
end
end
end
context
'with a regular license'
do
let!
(
:license
)
{
create
(
:license
)
}
it
'shows only expiration duration'
do
visit
admin_license_path
page
.
within
'.js-license-info-panel'
do
expect
(
page
).
not_to
have_content
(
'Expires: Free trial will expire in'
)
end
end
end
context
'with an expired trial license'
do
let!
(
:license
)
{
create
(
:license
,
trial:
true
,
expired:
true
)
}
it
'does not mention blocking of changes'
do
visit
admin_license_path
page
.
within
'.gitlab-ee-license-banner'
do
expect
(
page
).
to
have_content
(
'Your trial license expired on'
)
expect
(
page
).
not_to
have_content
(
'Pushing code and creation of issues and merge requests has been disabled'
)
end
end
end
context
'when license key is provided in the query string'
do
let
(
:license
)
{
build
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
active_user_count:
2000
}).
export
)
}
before
do
License
.
destroy_all
end
it
'shows the modal to install the license'
do
visit
admin_license_path
(
trial_key:
license
.
data
)
page
.
within
'#modal-upload-trial-license'
do
expect
(
page
).
to
have_content
(
'Your trial license was issued'
)
expect
(
page
).
to
have_button
(
'Install license'
)
end
end
it
'can install the license'
do
visit
admin_license_path
(
trial_key:
license
.
data
)
click_button
'Install license'
expect
(
page
).
to
have_content
(
'The license was successfully uploaded and is now active'
)
end
end
end
end
ee/spec/features/admin/licenses/admin_uploads_license_spec.rb
0 → 100644
View file @
3a1ffbf6
require
"spec_helper"
describe
"Admin uploads license"
do
set
(
:admin
)
{
create
(
:admin
)
}
before
do
sign_in
(
admin
)
end
context
"when license key is provided in the query string"
do
set
(
:license
)
{
build
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
active_user_count:
2000
}).
export
)
}
before
do
License
.
destroy_all
visit
(
admin_license_path
(
trial_key:
license
.
data
))
end
it
"installs license"
do
page
.
within
(
"#modal-upload-trial-license"
)
do
expect
(
page
).
to
have_content
(
"Your trial license was issued"
).
and
have_button
(
"Install license"
)
end
click_button
(
"Install license"
)
expect
(
page
).
to
have_content
(
"The license was successfully uploaded and is now active"
)
end
end
context
"uploading license"
do
before
do
visit
(
new_admin_license_path
)
File
.
write
(
path
,
license
.
export
)
end
context
"when license is valid"
do
set
(
:license
)
{
build
(
:gitlab_license
)
}
set
(
:path
)
{
Rails
.
root
.
join
(
"tmp/valid_license.gitlab-license"
)
}
it
"uploads license"
do
attach_and_upload
(
path
)
expect
(
page
).
to
have_content
(
"The license was successfully uploaded and is now active."
)
.
and
have_content
(
license
.
licensee
.
values
.
first
)
end
end
context
"when license is invalid"
do
set
(
:license
)
{
build
(
:gitlab_license
,
expires_at:
Date
.
yesterday
)
}
set
(
:path
)
{
Rails
.
root
.
join
(
"tmp/invalid_license.gitlab-license"
)
}
it
"doesn't upload license"
do
attach_and_upload
(
path
)
expect
(
page
).
to
have_content
(
"This license has already expired."
)
end
end
end
private
def
attach_and_upload
(
path
)
attach_file
(
"license_data_file"
,
path
)
click_button
(
"Upload license"
)
end
end
ee/spec/features/admin/licenses/admin_views_license_spec.rb
0 → 100644
View file @
3a1ffbf6
require
"spec_helper"
describe
"Admin views license"
do
set
(
:admin
)
{
create
(
:admin
)
}
before
do
sign_in
(
admin
)
end
context
"when license is valid"
do
before
do
visit
(
admin_license_path
)
end
it
"shows license"
do
expect
(
page
).
to
have_content
(
"Your license is valid"
)
page
.
within
(
".license-panel"
)
do
expect
(
page
).
to
have_content
(
"Unlimited"
)
end
end
end
context
"when license is trial"
do
set
(
:license
)
{
create
(
:license
,
trial:
true
)
}
before
do
visit
(
admin_license_path
)
end
it
"shows expiration duration with license type"
do
page
.
within
(
".js-license-info-panel"
)
do
expect
(
page
).
to
have_content
(
"Expires: Free trial will expire in"
)
end
end
context
"when license is expired"
do
set
(
:license
)
{
create
(
:license
,
trial:
true
,
expired:
true
)
}
it
"does not mention blocking of changes"
do
page
.
within
(
".gitlab-ee-license-banner"
)
do
expect
(
page
).
to
have_content
(
"Your trial license expired on"
)
.
and
have_no_content
(
"Pushing code and creation of issues and merge requests has been disabled"
)
end
end
end
end
context
"when license is regular"
do
set
(
:license
)
{
create
(
:license
)
}
before
do
visit
(
admin_license_path
)
end
it
"shows only expiration duration"
do
expect
(
page
).
to
have_content
(
license
.
licensee
.
values
.
first
)
page
.
within
(
".js-license-info-panel"
)
do
expect
(
page
).
not_to
have_content
(
"Expires: Free trial will expire in"
)
end
end
context
"when license expired"
do
set
(
:license
)
{
build
(
:license
,
data:
build
(
:gitlab_license
,
expires_at:
Date
.
yesterday
).
export
).
save
(
validate:
false
)
}
it
{
expect
(
page
).
to
have_content
(
"Your license expired"
)
}
context
"when license blocks changes"
do
set
(
:license
)
{
build
(
:license
,
data:
build
(
:gitlab_license
,
expires_at:
Date
.
yesterday
,
block_changes_at:
Date
.
today
).
export
).
save
(
validate:
false
)
}
it
{
expect
(
page
).
to
have_content
"Pushing code and creation of issues and merge requests has been disabled."
}
end
end
context
"when viewing license history"
do
set
(
:license
)
{
create
(
:license
)
}
it
"shows licensee"
do
license_history
=
page
.
find
(
"#license_history"
)
License
.
previous
.
each
do
|
license
|
expect
(
license_history
).
to
have_content
(
license
.
licensee
.
values
.
first
)
end
end
end
end
context
"with limited users"
do
set
(
:license
)
{
create
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
active_user_count:
2000
}).
export
)
}
before
do
visit
(
admin_license_path
)
end
it
"shows panel counts"
do
page
.
within
(
".license-panel"
)
do
expect
(
page
).
to
have_content
(
"2,000"
)
end
end
end
end
features/admin/license.feature
deleted
100644 → 0
View file @
60039b36
@admin
Feature
:
Admin license
Background
:
Given
I sign in as an admin
Scenario
:
Viewing current license
Given
there is a license
And
I visit admin license page
Then
I should see to whom the license is licensed
Scenario
:
Viewing expired license
Given
there is a license
And
the current license is expired
And
I visit admin license page
Then
I should see a warning telling me the license has expired
Scenario
:
Viewing license that blocks changes
Given
there is a license
And
the current license is expired
And
the current license blocks changes
And
I visit admin license page
Then
I should see a warning telling me code pushes have been disabled
Scenario
:
Viewing license history
Given
there is a license
And
there are multiple licenses
And
I visit admin license page
Then
I should see to whom the licenses were licensed
Scenario
:
Uploading valid license
Given
I visit admin upload license page
And
I upload a valid license
Then
I should see a notice telling me the license was uploaded
And
I should see to whom the license is licensed
Scenario
:
Uploading invalid license
Given
I visit admin upload license page
Then
I upload an invalid license
Then
I should see a warning telling me it's invalid
features/steps/admin/license.rb
deleted
100644 → 0
View file @
60039b36
class
Spinach::Features::AdminLicense
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedPaths
step
'I should see to whom the license is licensed'
do
expect
(
page
).
to
have_content
(
license
.
licensee
.
values
.
first
)
end
step
'there is a license'
do
create
(
:license
)
end
step
'there is no license'
do
License
.
destroy_all
end
step
'I should be redirected to the license upload page'
do
expect
(
current_path
).
to
eq
(
new_admin_license_path
)
end
step
'the current license is expired'
do
build
(
:license
,
data:
build
(
:gitlab_license
,
expires_at:
Date
.
yesterday
).
export
).
save
(
validate:
false
)
end
step
'I should see a warning telling me the license has expired'
do
expect
(
page
).
to
have_content
"Your license expired"
end
step
'the current license blocks changes'
do
build
(
:license
,
data:
build
(
:gitlab_license
,
expires_at:
Date
.
yesterday
,
block_changes_at:
Date
.
today
).
export
).
save
(
validate:
false
)
end
step
'I should see a warning telling me code pushes have been disabled'
do
expect
(
page
).
to
have_content
"Pushing code and creation of issues and merge requests has been disabled."
end
step
'there are multiple licenses'
do
create
(
:license
)
create
(
:license
)
end
step
'I should see to whom the licenses were licensed'
do
license_history
=
page
.
find
(
"#license_history"
)
License
.
previous
.
each
do
|
license
|
expect
(
license_history
).
to
have_content
(
license
.
licensee
.
values
.
first
)
end
end
step
'I visit admin upload license page'
do
visit
new_admin_license_path
end
step
'I upload a valid license'
do
path
=
Rails
.
root
.
join
(
"tmp/valid_license.gitlab-license"
)
license
=
build
(
:gitlab_license
)
File
.
write
(
path
,
license
.
export
)
attach_file
'license_data_file'
,
path
click_button
"Upload license"
end
step
'I should see a notice telling me the license was uploaded'
do
expect
(
page
).
to
have_content
"The license was successfully uploaded and is now active."
end
step
'I upload an invalid license'
do
path
=
Rails
.
root
.
join
(
"tmp/invalid_license.gitlab-license"
)
license
=
build
(
:gitlab_license
,
expires_at:
Date
.
yesterday
)
File
.
write
(
path
,
license
.
export
)
attach_file
'license_data_file'
,
path
click_button
"Upload license"
end
step
"I should see a warning telling me it's invalid"
do
expect
(
page
).
to
have_content
"This license has already expired."
end
def
license
License
.
reset_current
License
.
current
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