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
97bfd764
Commit
97bfd764
authored
May 05, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature specs for license upload.
parent
3a6b9ad8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
152 additions
and
14 deletions
+152
-14
app/models/license.rb
app/models/license.rb
+0
-7
app/views/admin/licenses/new.html.haml
app/views/admin/licenses/new.html.haml
+1
-1
app/views/admin/licenses/show.html.haml
app/views/admin/licenses/show.html.haml
+1
-1
features/admin/license.feature
features/admin/license.feature
+44
-0
features/steps/admin/license.rb
features/steps/admin/license.rb
+86
-0
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+4
-0
spec/factories.rb
spec/factories.rb
+13
-0
spec/models/license_spec.rb
spec/models/license_spec.rb
+2
-2
spec/support/test_env.rb
spec/support/test_env.rb
+1
-3
No files found.
app/models/license.rb
View file @
97bfd764
class
License
<
ActiveRecord
::
Base
validates
:data
,
presence:
true
validate
:valid_license
validate
:active_user_count
,
unless: :persisted?
validate
:not_expired
,
unless: :persisted?
...
...
@@ -36,12 +35,6 @@ class License < ActiveRecord::Base
"
#{
clean_company_name
}
.gitlab-license"
end
def
data_file
return
nil
unless
self
.
data
Tempfile
.
new
(
self
.
data_filename
)
{
|
f
|
f
.
write
(
self
.
data
)
}
end
def
data_file
=
(
file
)
self
.
data
=
file
.
read
end
...
...
app/views/admin/licenses/new.html.haml
View file @
97bfd764
...
...
@@ -18,4 +18,4 @@
=
f
.
file_field
:data_file
,
accept:
".gitlab-license,.gitlab_license,.txt"
.form-actions
=
f
.
submit
'Upload'
,
class:
'btn btn-primary'
=
f
.
submit
'Upload
license
'
,
class:
'btn btn-primary'
app/views/admin/licenses/show.html.haml
View file @
97bfd764
...
...
@@ -89,7 +89,7 @@
-
if
@previous_licenses
.
any?
%h4
License History
.panel.panel-default
.panel.panel-default
#license_history
%table
.table
%thead
.panel-heading
%tr
...
...
features/admin/license.feature
0 → 100644
View file @
97bfd764
@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 license when there is none
Given
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
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
0 → 100644
View file @
97bfd764
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
'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
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
"The GitLab Enterprise Edition 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
features/steps/shared/paths.rb
View file @
97bfd764
...
...
@@ -203,6 +203,10 @@ module SharedPaths
visit
admin_git_hooks_path
end
step
'I visit admin license page'
do
visit
admin_license_path
end
# ----------------------------------------
# Generic Project
# ----------------------------------------
...
...
spec/factories.rb
View file @
97bfd764
...
...
@@ -202,4 +202,17 @@ FactoryGirl.define do
provider
'ldapmain'
extern_uid
'my-ldap-id'
end
factory
:gitlab_license
,
class:
"Gitlab::License"
do
issued_at
{
Date
.
today
}
licensee
do
{
"Name"
=>
Faker
::
Name
.
name
}
end
notify_users_at
{
|
l
|
l
.
expires_at
}
notify_admins_at
{
|
l
|
l
.
expires_at
}
end
factory
:license
do
data
{
build
(
:gitlab_license
).
export
}
end
end
spec/models/license_spec.rb
View file @
97bfd764
require
"spec_helper"
describe
License
do
let
(
:gl_license
)
{
Gitlab
::
License
.
new
(
issued_at:
Date
.
today
,
licensee:
{
"Name"
=>
"GitLab Test Env"
}
)
}
let
(
:license
)
{
License
.
new
(
data:
gl_license
.
export
)
}
let
(
:gl_license
)
{
build
(
:gitlab_license
)
}
let
(
:license
)
{
build
(
:license
,
data:
gl_license
.
export
)
}
describe
"Validation"
do
describe
"Valid license"
do
...
...
spec/support/test_env.rb
View file @
97bfd764
...
...
@@ -53,9 +53,7 @@ module TestEnv
def
setup_license
Gitlab
::
License
.
encryption_key
=
OpenSSL
::
PKey
::
RSA
.
generate
(
2048
)
gl_license
=
Gitlab
::
License
.
new
(
issued_at:
Date
.
today
,
licensee:
{
"Name"
=>
"GitLab Test Env"
})
License
.
create
(
data:
gl_license
.
export
)
FactoryGirl
.
create
(
:license
)
end
# Clean /tmp/tests
...
...
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