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
acfd70f0
Commit
acfd70f0
authored
Aug 23, 2017
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Specs + Fixed Tests
parent
f95109d0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
5 deletions
+89
-5
app/controllers/groups/analytics_controller.rb
app/controllers/groups/analytics_controller.rb
+5
-1
app/controllers/projects/audit_events_controller.rb
app/controllers/projects/audit_events_controller.rb
+7
-0
app/helpers/license_helper.rb
app/helpers/license_helper.rb
+2
-2
spec/controllers/groups/analytics_controller_spec.rb
spec/controllers/groups/analytics_controller_spec.rb
+18
-0
spec/ee/spec/views/layouts/nav/_group.html.haml_spec.rb
spec/ee/spec/views/layouts/nav/_group.html.haml_spec.rb
+17
-0
spec/features/projects/audit_events_spec.rb
spec/features/projects/audit_events_spec.rb
+38
-0
spec/features/promotion_spec.rb
spec/features/promotion_spec.rb
+2
-2
No files found.
app/controllers/groups/analytics_controller.rb
View file @
acfd70f0
...
@@ -2,7 +2,7 @@ class Groups::AnalyticsController < Groups::ApplicationController
...
@@ -2,7 +2,7 @@ class Groups::AnalyticsController < Groups::ApplicationController
include
LicenseHelper
include
LicenseHelper
before_action
:group
before_action
:group
before_action
:check_contribution_analytics_available!
&&
!
LicenseHelper
.
show_promotions?
before_action
:check_contribution_analytics_available!
layout
'group'
layout
'group'
...
@@ -32,4 +32,8 @@ class Groups::AnalyticsController < Groups::ApplicationController
...
@@ -32,4 +32,8 @@ class Groups::AnalyticsController < Groups::ApplicationController
def
user_ids
def
user_ids
@user_ids
||=
@users
.
map
(
&
:id
)
@user_ids
||=
@users
.
map
(
&
:id
)
end
end
def
check_contribution_analytics_available!
render_404
unless
(
@group
.
feature_available?
(
:contribution_analytics
)
||
LicenseHelper
.
show_promotions?
(
current_user
))
end
end
end
app/controllers/projects/audit_events_controller.rb
View file @
acfd70f0
class
Projects::AuditEventsController
<
Projects
::
ApplicationController
class
Projects::AuditEventsController
<
Projects
::
ApplicationController
include
LicenseHelper
before_action
:authorize_admin_project!
before_action
:authorize_admin_project!
before_action
:check_audit_events_available!
layout
'project_settings'
layout
'project_settings'
def
index
def
index
@events
=
project
.
audit_events
.
page
(
params
[
:page
])
@events
=
project
.
audit_events
.
page
(
params
[
:page
])
end
end
def
check_audit_events_available!
render_404
unless
(
@project
.
feature_available?
(
:audit_events
)
||
LicenseHelper
.
show_promotions?
(
current_user
))
end
end
end
app/helpers/license_helper.rb
View file @
acfd70f0
...
@@ -75,8 +75,8 @@ module LicenseHelper
...
@@ -75,8 +75,8 @@ module LicenseHelper
end
end
end
end
def
show_promotions?
def
show_promotions?
(
selected_user
=
current_user
)
if
current
_user
if
selected
_user
if
current_application_settings
.
should_check_namespace_plan?
if
current_application_settings
.
should_check_namespace_plan?
true
true
else
else
...
...
spec/controllers/groups/analytics_controller_spec.rb
View file @
acfd70f0
...
@@ -38,6 +38,24 @@ describe Groups::AnalyticsController do
...
@@ -38,6 +38,24 @@ describe Groups::AnalyticsController do
create_push_event
(
user3
,
project
)
create_push_event
(
user3
,
project
)
end
end
it
'returns 404 when feature is not available and we dont show promotions'
do
stub_licensed_features
(
contribution_analytics:
false
)
get
:show
,
group_id:
group
.
path
expect
(
response
).
to
have_http_status
(
404
)
end
it
'returns page when feature is not available and we show promotions'
do
stub_licensed_features
(
contribution_analytics:
false
)
let!
(
:license
)
{
nil
}
get
:show
,
group_id:
group
.
path
expect
(
response
).
to
have_http_status
(
200
)
end
it
'sets instance variables properly'
do
it
'sets instance variables properly'
do
get
:show
,
group_id:
group
.
path
get
:show
,
group_id:
group
.
path
...
...
spec/ee/spec/views/layouts/nav/_group.html.haml_spec.rb
View file @
acfd70f0
...
@@ -6,6 +6,23 @@ describe 'layouts/nav/_group' do
...
@@ -6,6 +6,23 @@ describe 'layouts/nav/_group' do
end
end
describe
'contribution analytics tab'
do
describe
'contribution analytics tab'
do
it
'is not visible when there is no valid license and we dont show promotions'
do
stub_licensed_features
(
contribution_analytics:
false
)
render
expect
(
rendered
).
not_to
have_text
'Contribution Analytics'
end
it
'is visible when there is no valid license but we show promotions'
do
stub_licensed_features
(
contribution_analytics:
false
)
let!
(
:license
)
{
nil
}
render
expect
(
rendered
).
to
have_text
'Contribution Analytics'
end
it
'is visible'
do
it
'is visible'
do
stub_licensed_features
(
contribution_analytics:
true
)
stub_licensed_features
(
contribution_analytics:
true
)
...
...
spec/features/projects/audit_events_spec.rb
View file @
acfd70f0
...
@@ -10,6 +10,44 @@ feature 'Projects > Audit Events', :js do
...
@@ -10,6 +10,44 @@ feature 'Projects > Audit Events', :js do
sign_in
(
user
)
sign_in
(
user
)
end
end
context
'unlicensed'
do
before
do
stub_licensed_features
(
audit_events:
false
)
end
it
'returns 404'
do
visit
project_audit_events_path
(
project
)
expect
(
page
.
status_code
).
to
eq
(
404
)
end
it
'does not have Audit Events button in head nav bar'
do
visit
edit_project_path
(
project
)
expect
(
page
).
not_to
have_link
(
'Audit Events'
)
end
end
context
'unlicensed but we show promotions'
do
before
do
stub_licensed_features
(
audit_events:
false
)
let!
(
:license
)
{
nil
}
end
it
'returns 404'
do
visit
project_audit_events_path
(
project
)
expect
(
page
.
status_code
).
to
eq
(
200
)
end
it
'does not have Audit Events button in head nav bar'
do
visit
edit_project_path
(
project
)
expect
(
page
).
to
have_link
(
'Audit Events'
)
end
end
it
'has Audit Events button in head nav bar'
do
it
'has Audit Events button in head nav bar'
do
visit
edit_project_path
(
project
)
visit
edit_project_path
(
project
)
...
...
spec/features/promotion_spec.rb
View file @
acfd70f0
...
@@ -25,7 +25,7 @@ describe 'Promotions', js: true do
...
@@ -25,7 +25,7 @@ describe 'Promotions', js: true do
describe
'for project features in general on premise'
do
describe
'for project features in general on premise'
do
context
'no license installed'
do
context
'no license installed'
do
before
do
before
do
License
.
destroy_all
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
stub_application_setting
(
check_namespace_plan:
false
)
stub_application_setting
(
check_namespace_plan:
false
)
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
end
end
...
@@ -183,7 +183,7 @@ describe 'Promotions', js: true do
...
@@ -183,7 +183,7 @@ describe 'Promotions', js: true do
it
'should appear in milestone page'
do
it
'should appear in milestone page'
do
visit
project_milestone_path
(
project
,
milestone
)
visit
project_milestone_path
(
project
,
milestone
)
expect
(
find
(
'#promote_burndown_charts'
)).
to
have_content
'Improve milestone with Burndown Charts.'
expect
(
find
(
'#promote_burndown_charts'
)).
to
have_content
'Improve milestone
s
with Burndown Charts.'
end
end
it
'does not show when cookie is set'
do
it
'does not show when cookie is set'
do
...
...
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