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
12c34661
Commit
12c34661
authored
Jun 19, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2017-06-15
parents
358327f4
84f2887a
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
180 additions
and
59 deletions
+180
-59
app/models/ee/project.rb
app/models/ee/project.rb
+7
-8
app/models/license.rb
app/models/license.rb
+4
-0
app/views/admin/audit_logs/index.html.haml
app/views/admin/audit_logs/index.html.haml
+1
-1
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+1
-1
app/workers/historical_data_worker.rb
app/workers/historical_data_worker.rb
+2
-0
changelogs/unreleased-ee/2565-namespace-service-desk.yml
changelogs/unreleased-ee/2565-namespace-service-desk.yml
+4
-0
lib/ee/gitlab/ldap/sync/group.rb
lib/ee/gitlab/ldap/sync/group.rb
+1
-1
lib/ee/gitlab/service_desk.rb
lib/ee/gitlab/service_desk.rb
+7
-4
lib/gitlab/email/handler/ee/service_desk_handler.rb
lib/gitlab/email/handler/ee/service_desk_handler.rb
+3
-1
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+1
-1
spec/controllers/projects/service_desk_controller_spec.rb
spec/controllers/projects/service_desk_controller_spec.rb
+5
-5
spec/factories/licenses.rb
spec/factories/licenses.rb
+10
-0
spec/features/admin/admin_audit_logs_spec.rb
spec/features/admin/admin_audit_logs_spec.rb
+4
-0
spec/features/projects/settings/ee/service_desk_setting_spec.rb
...eatures/projects/settings/ee/service_desk_setting_spec.rb
+2
-2
spec/lib/ee/gitlab/ldap/sync/group_spec.rb
spec/lib/ee/gitlab/ldap/sync/group_spec.rb
+9
-0
spec/lib/ee/gitlab/service_desk_spec.rb
spec/lib/ee/gitlab/service_desk_spec.rb
+3
-3
spec/lib/gitlab/email/handler/ee/service_desk_handler_spec.rb
.../lib/gitlab/email/handler/ee/service_desk_handler_spec.rb
+9
-15
spec/lib/gitlab/email/handler_spec.rb
spec/lib/gitlab/email/handler_spec.rb
+8
-8
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+8
-5
spec/models/ee/project_spec.rb
spec/models/ee/project_spec.rb
+39
-2
spec/services/ee/notification_service_spec.rb
spec/services/ee/notification_service_spec.rb
+1
-2
spec/workers/historical_data_worker_spec.rb
spec/workers/historical_data_worker_spec.rb
+51
-0
No files found.
app/models/ee/project.rb
View file @
12c34661
...
@@ -55,8 +55,13 @@ module EE
...
@@ -55,8 +55,13 @@ module EE
end
end
end
end
def
service_desk_enabled
::
EE
::
Gitlab
::
ServiceDesk
.
enabled?
(
project:
self
)
&&
super
end
alias_method
:service_desk_enabled?
,
:
service_desk_enabled
def
service_desk_address
def
service_desk_address
return
nil
unless
service_desk_
available
?
return
nil
unless
service_desk_
enabled
?
config
=
::
Gitlab
.
config
.
incoming_email
config
=
::
Gitlab
.
config
.
incoming_email
wildcard
=
::
Gitlab
::
IncomingEmail
::
WILDCARD_PLACEHOLDER
wildcard
=
::
Gitlab
::
IncomingEmail
::
WILDCARD_PLACEHOLDER
...
@@ -80,7 +85,7 @@ module EE
...
@@ -80,7 +85,7 @@ module EE
private
private
def
licensed_feature_available?
(
feature
)
def
licensed_feature_available?
(
feature
)
globally_available
=
License
.
current
&
.
feature_available?
(
feature
)
globally_available
=
License
.
feature_available?
(
feature
)
if
current_application_settings
.
should_check_namespace_plan?
if
current_application_settings
.
should_check_namespace_plan?
globally_available
&&
globally_available
&&
...
@@ -93,11 +98,5 @@ module EE
...
@@ -93,11 +98,5 @@ module EE
def
destroy_mirror_data
def
destroy_mirror_data
mirror_data
.
destroy
mirror_data
.
destroy
end
end
def
service_desk_available?
return
@service_desk_available
if
defined?
(
@service_desk_available
)
@service_desk_available
=
EE
::
Gitlab
::
ServiceDesk
.
enabled?
&&
service_desk_enabled?
end
end
end
end
end
app/models/license.rb
View file @
12c34661
...
@@ -203,6 +203,10 @@ class License < ActiveRecord::Base
...
@@ -203,6 +203,10 @@ class License < ActiveRecord::Base
restricted_attr
(
:trueup_to
)].
all?
(
&
:present?
)
restricted_attr
(
:trueup_to
)].
all?
(
&
:present?
)
end
end
def
trial?
restricted_attr
(
:trial
)
end
private
private
def
restricted_attr
(
name
,
default
=
nil
)
def
restricted_attr
(
name
,
default
=
nil
)
...
...
app/views/admin/audit_logs/index.html.haml
View file @
12c34661
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
placeholder:
admin_namespace_dropdown_label
(
'Search groups'
),
idAttribute:
'id'
,
data:
{
order_by:
'last_activity_at'
,
idattribute:
'id'
,
all_available:
true
}
})
placeholder:
admin_namespace_dropdown_label
(
'Search groups'
),
idAttribute:
'id'
,
data:
{
order_by:
'last_activity_at'
,
idattribute:
'id'
,
all_available:
true
}
})
-
if
@events
.
present?
-
if
@events
.
present?
%table
.table
%table
#events-table
.table
%thead
%thead
%tr
%tr
%th
Author
%th
Author
...
...
app/views/projects/edit.html.haml
View file @
12c34661
...
@@ -130,7 +130,7 @@
...
@@ -130,7 +130,7 @@
=
render
'merge_request_settings'
,
form:
f
=
render
'merge_request_settings'
,
form:
f
-
if
EE
::
Gitlab
::
ServiceDesk
.
enabled?
-
if
EE
::
Gitlab
::
ServiceDesk
.
enabled?
(
project:
@project
)
%hr
%hr
%fieldset
.js-service-desk-setting-wrapper.features.append-bottom-default
%fieldset
.js-service-desk-setting-wrapper.features.append-bottom-default
%h5
.prepend-top-0
%h5
.prepend-top-0
...
...
app/workers/historical_data_worker.rb
View file @
12c34661
...
@@ -4,6 +4,8 @@ class HistoricalDataWorker
...
@@ -4,6 +4,8 @@ class HistoricalDataWorker
def
perform
def
perform
return
if
Gitlab
::
Geo
.
secondary?
return
if
Gitlab
::
Geo
.
secondary?
return
if
License
.
current
.
nil?
||
License
.
current
&
.
trial?
HistoricalData
.
track!
HistoricalData
.
track!
end
end
end
end
changelogs/unreleased-ee/2565-namespace-service-desk.yml
0 → 100644
View file @
12c34661
---
title
:
'
Add
namespace
license
checks
for
Service
Desk
(EEP)'
merge_request
:
2109
author
:
lib/ee/gitlab/ldap/sync/group.rb
View file @
12c34661
...
@@ -145,7 +145,7 @@ module EE
...
@@ -145,7 +145,7 @@ module EE
elsif
group
.
last_owner?
(
user
)
elsif
group
.
last_owner?
(
user
)
warn_cannot_remove_last_owner
(
user
,
group
)
warn_cannot_remove_last_owner
(
user
,
group
)
else
else
group
.
users
.
de
lete
(
user
)
group
.
users
.
de
stroy
(
user
)
end
end
end
end
end
end
...
...
lib/ee/gitlab/service_desk.rb
View file @
12c34661
module
EE
module
EE
module
Gitlab
module
Gitlab
module
ServiceDesk
module
ServiceDesk
def
self
.
enabled?
# Check whether a project or GitLab instance can support the Service Desk
::
License
.
current
&
.
feature_available?
(
:service_desk
)
&&
# feature. Use `project.service_desk_enabled?` to check whether it is
::
Gitlab
::
IncomingEmail
.
enabled?
&&
# enabled for a particular project.
::
Gitlab
::
IncomingEmail
.
supports_wildcard?
def
self
.
enabled?
(
project:
nil
)
return
unless
::
Gitlab
::
IncomingEmail
.
enabled?
&&
::
Gitlab
::
IncomingEmail
.
supports_wildcard?
(
project
||
::
License
).
feature_available?
(
:service_desk
)
end
end
end
end
end
end
...
...
lib/gitlab/email/handler/ee/service_desk_handler.rb
View file @
12c34661
...
@@ -31,9 +31,11 @@ module Gitlab
...
@@ -31,9 +31,11 @@ module Gitlab
def
project
def
project
return
@project
if
instance_variable_defined?
(
:@project
)
return
@project
if
instance_variable_defined?
(
:@project
)
@
project
=
found_
project
=
Project
.
where
(
service_desk_enabled:
true
)
Project
.
where
(
service_desk_enabled:
true
)
.
find_by_full_path
(
service_desk_key
)
.
find_by_full_path
(
service_desk_key
)
@project
=
found_project
&
.
service_desk_enabled?
?
found_project
:
nil
end
end
def
create_issue!
def
create_issue!
...
...
lib/gitlab/usage_data.rb
View file @
12c34661
...
@@ -55,7 +55,7 @@ module Gitlab
...
@@ -55,7 +55,7 @@ module Gitlab
end
end
def
service_desk_counts
def
service_desk_counts
return
{}
unless
::
License
.
current
&
.
feature_available?
(
:service_desk
)
return
{}
unless
::
License
.
feature_available?
(
:service_desk
)
projects_with_service_desk
=
Project
.
where
(
service_desk_enabled:
true
)
projects_with_service_desk
=
Project
.
where
(
service_desk_enabled:
true
)
...
...
spec/controllers/projects/service_desk_controller_spec.rb
View file @
12c34661
require
'spec_helper'
require
'spec_helper'
describe
Projects
::
ServiceDeskController
do
describe
Projects
::
ServiceDeskController
do
let
(
:project
)
{
create
(
:project_empty_repo
,
:private
)
}
let
(
:project
)
{
create
(
:project_empty_repo
,
:private
,
service_desk_enabled:
true
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
allow
(
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
project
.
update
(
service_desk_enabled:
true
)
project
.
add_master
(
user
)
project
.
add_master
(
user
)
sign_in
(
user
)
sign_in
(
user
)
end
end
...
@@ -41,7 +41,7 @@ describe Projects::ServiceDeskController do
...
@@ -41,7 +41,7 @@ describe Projects::ServiceDeskController do
describe
'PUT service desk properties'
do
describe
'PUT service desk properties'
do
it
'toggles services desk incoming email'
do
it
'toggles services desk incoming email'
do
project
.
update
(
service_desk_enabled:
false
)
project
.
update
!
(
service_desk_enabled:
false
)
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
service_desk_enabled:
true
,
format: :json
put
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
service_desk_enabled:
true
,
format: :json
...
...
spec/factories/licenses.rb
View file @
12c34661
...
@@ -15,9 +15,19 @@ FactoryGirl.define do
...
@@ -15,9 +15,19 @@ FactoryGirl.define do
end
end
notify_users_at
{
|
l
|
l
.
expires_at
}
notify_users_at
{
|
l
|
l
.
expires_at
}
notify_admins_at
{
|
l
|
l
.
expires_at
}
notify_admins_at
{
|
l
|
l
.
expires_at
}
trait
:trial
do
restrictions
do
{
trial:
true
}
end
end
end
end
factory
:license
do
factory
:license
do
data
{
build
(
:gitlab_license
).
export
}
data
{
build
(
:gitlab_license
).
export
}
end
end
factory
:trial_license
,
class:
License
do
data
{
build
(
:gitlab_license
,
:trial
).
export
}
end
end
end
spec/features/admin/admin_audit_logs_spec.rb
View file @
12c34661
...
@@ -51,6 +51,8 @@ describe 'Admin::AuditLogs', feature: true, js: true do
...
@@ -51,6 +51,8 @@ describe 'Admin::AuditLogs', feature: true, js: true do
wait_for_requests
wait_for_requests
find
(
'.select2-results'
).
click
find
(
'.select2-results'
).
click
find
(
'#events-table td'
,
match: :first
)
expect
(
page
).
to
have_content
(
'Added user access as Owner'
)
expect
(
page
).
to
have_content
(
'Added user access as Owner'
)
end
end
end
end
...
@@ -73,6 +75,8 @@ describe 'Admin::AuditLogs', feature: true, js: true do
...
@@ -73,6 +75,8 @@ describe 'Admin::AuditLogs', feature: true, js: true do
wait_for_requests
wait_for_requests
find
(
'.select2-results'
).
click
find
(
'.select2-results'
).
click
find
(
'#events-table td'
,
match: :first
)
expect
(
page
).
to
have_content
(
'Removed user access'
)
expect
(
page
).
to
have_content
(
'Removed user access'
)
end
end
end
end
...
...
spec/features/projects/settings/ee/service_desk_setting_spec.rb
View file @
12c34661
...
@@ -7,8 +7,8 @@ describe 'Service Desk Setting', js: true, feature: true do
...
@@ -7,8 +7,8 @@ describe 'Service Desk Setting', js: true, feature: true do
before
do
before
do
project
.
add_master
(
user
)
project
.
add_master
(
user
)
login_as
(
user
)
login_as
(
user
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
::
EE
::
Gitlab
::
ServiceDesk
).
to
receive
(
:enabled?
).
with
(
project:
project
).
and_return
(
true
)
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
...
...
spec/lib/ee/gitlab/ldap/sync/group_spec.rb
View file @
12c34661
...
@@ -235,6 +235,15 @@ describe EE::Gitlab::LDAP::Sync::Group, lib: true do
...
@@ -235,6 +235,15 @@ describe EE::Gitlab::LDAP::Sync::Group, lib: true do
expect
(
group
.
members
.
find_by
(
user_id:
user
.
id
).
access_level
)
expect
(
group
.
members
.
find_by
(
user_id:
user
.
id
).
access_level
)
.
to
eq
(
::
Gitlab
::
Access
::
OWNER
)
.
to
eq
(
::
Gitlab
::
Access
::
OWNER
)
end
end
it
'updates projects authorizations'
do
project
=
create
(
:empty_project
,
namespace:
group
)
group
.
add_user
(
user
,
Gitlab
::
Access
::
MASTER
)
sync_group
.
update_permissions
expect
(
project
.
authorized_users
.
find_by
(
id:
user
.
id
)).
to
be_nil
end
end
end
context
'when the user is the last owner'
do
context
'when the user is the last owner'
do
...
...
spec/lib/ee/gitlab/service_desk_spec.rb
View file @
12c34661
...
@@ -2,8 +2,8 @@ require 'spec_helper'
...
@@ -2,8 +2,8 @@ require 'spec_helper'
describe
EE
::
Gitlab
::
ServiceDesk
,
lib:
true
do
describe
EE
::
Gitlab
::
ServiceDesk
,
lib:
true
do
before
do
before
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
end
end
...
@@ -14,7 +14,7 @@ describe EE::Gitlab::ServiceDesk, lib: true do
...
@@ -14,7 +14,7 @@ describe EE::Gitlab::ServiceDesk, lib: true do
context
'when license does not support service desk'
do
context
'when license does not support service desk'
do
before
do
before
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
false
}
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
false
}
end
end
it
{
is_expected
.
to
be_falsy
}
it
{
is_expected
.
to
be_falsy
}
...
...
spec/lib/gitlab/email/handler/ee/service_desk_handler_spec.rb
View file @
12c34661
...
@@ -10,19 +10,16 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
...
@@ -10,19 +10,16 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
let
(
:email_raw
)
{
fixture_file
(
'emails/service_desk.eml'
)
}
let
(
:email_raw
)
{
fixture_file
(
'emails/service_desk.eml'
)
}
let
(
:namespace
)
{
create
(
:namespace
,
name:
"email"
)
}
let
(
:namespace
)
{
create
(
:namespace
,
name:
"email"
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
namespace
,
path:
"test"
)
}
context
'when service desk is enabled'
do
context
'service desk is enabled for the project'
do
before
do
let
(
:project
)
{
create
(
:empty_project
,
:public
,
namespace:
namespace
,
path:
'test'
,
service_desk_enabled:
true
)
}
project
.
update
(
service_desk_enabled:
true
)
before
do
allow
(
Notify
).
to
receive
(
:service_desk_thank_you_email
)
allow
(
Notify
).
to
receive
(
:service_desk_thank_you_email
)
.
with
(
kind_of
(
Integer
)).
and_return
(
double
(
deliver_later!:
true
))
.
with
(
kind_of
(
Integer
)).
and_return
(
double
(
deliver_later!:
true
))
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
::
EE
::
Gitlab
::
ServiceDesk
).
to
receive
(
:enabled?
).
and_return
(
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
::
EE
::
Gitlab
::
ServiceDesk
).
to
receive
(
:enabled?
).
with
(
project:
project
).
and_return
(
true
)
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
end
end
it
'sends thank you the email and creates issue'
do
it
'sends thank you the email and creates issue'
do
...
@@ -56,8 +53,7 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
...
@@ -56,8 +53,7 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
context
'when license does not support service desk'
do
context
'when license does not support service desk'
do
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
::
EE
::
Gitlab
::
ServiceDesk
).
to
receive
(
:enabled?
).
and_return
(
false
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
false
}
end
end
it
'does not create an issue or send email'
do
it
'does not create an issue or send email'
do
...
@@ -88,16 +84,14 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
...
@@ -88,16 +84,14 @@ describe Gitlab::Email::Handler::EE::ServiceDeskHandler do
end
end
end
end
context
'when service desk is not enabled'
do
context
'service desk is disabled for the project'
do
before
do
let
(
:project
)
{
create
(
:empty_project
,
:public
,
namespace:
namespace
,
path:
'test'
)
}
project
.
update_attributes
(
service_desk_enabled:
false
)
end
it
'bounces the email'
do
it
'bounces the email'
do
expect
{
receiver
.
execute
}.
to
raise_error
(
Gitlab
::
Email
::
ProcessingError
)
expect
{
receiver
.
execute
}.
to
raise_error
(
Gitlab
::
Email
::
ProcessingError
)
end
end
it
'doesn\'t create an issue'
do
it
"doesn't create an issue"
do
expect
{
receiver
.
execute
rescue
nil
}.
not_to
change
{
Issue
.
count
}
expect
{
receiver
.
execute
rescue
nil
}.
not_to
change
{
Issue
.
count
}
end
end
end
end
...
...
spec/lib/gitlab/email/handler_spec.rb
View file @
12c34661
...
@@ -13,15 +13,15 @@ describe Gitlab::Email::Handler, lib: true do
...
@@ -13,15 +13,15 @@ describe Gitlab::Email::Handler, lib: true do
context
'a Service Desk email'
do
context
'a Service Desk email'
do
it
'uses the Service Desk handler when Service Desk is enabled'
do
it
'uses the Service Desk handler when Service Desk is enabled'
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
true
)
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
true
)
expect
(
handler_for
(
'emails/service_desk.eml'
,
'some/project'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
EE
::
ServiceDeskHandler
)
expect
(
handler_for
(
'emails/service_desk.eml'
,
'some/project'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
EE
::
ServiceDeskHandler
)
end
end
it
'uses no handler when Service Desk is disabled'
do
it
'uses no handler when Service Desk is disabled'
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
false
)
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
false
)
expect
(
handler_for
(
'emails/service_desk.eml'
,
'some/project'
)).
to
be_nil
expect
(
handler_for
(
'emails/service_desk.eml'
,
'some/project'
)).
to
be_nil
end
end
...
@@ -31,15 +31,15 @@ describe Gitlab::Email::Handler, lib: true do
...
@@ -31,15 +31,15 @@ describe Gitlab::Email::Handler, lib: true do
let!
(
:user
)
{
create
(
:user
,
email:
'jake@adventuretime.ooo'
,
incoming_email_token:
'auth_token'
)
}
let!
(
:user
)
{
create
(
:user
,
email:
'jake@adventuretime.ooo'
,
incoming_email_token:
'auth_token'
)
}
it
'uses the create issue handler when Service Desk is enabled'
do
it
'uses the create issue handler when Service Desk is enabled'
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
true
)
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
true
)
expect
(
handler_for
(
'emails/valid_new_issue.eml'
,
'some/project+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
CreateIssueHandler
)
expect
(
handler_for
(
'emails/valid_new_issue.eml'
,
'some/project+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
CreateIssueHandler
)
end
end
it
'uses the create issue handler when Service Desk is disabled'
do
it
'uses the create issue handler when Service Desk is disabled'
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
false
)
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
false
)
expect
(
handler_for
(
'emails/valid_new_issue.eml'
,
'some/project+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
CreateIssueHandler
)
expect
(
handler_for
(
'emails/valid_new_issue.eml'
,
'some/project+auth_token'
)).
to
be_instance_of
(
Gitlab
::
Email
::
Handler
::
CreateIssueHandler
)
end
end
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
12c34661
...
@@ -94,12 +94,13 @@ describe Gitlab::UsageData do
...
@@ -94,12 +94,13 @@ describe Gitlab::UsageData do
describe
'.service_desk_counts'
do
describe
'.service_desk_counts'
do
subject
{
described_class
.
service_desk_counts
}
subject
{
described_class
.
service_desk_counts
}
let!
(
:project3
)
{
create
(
:empty_project
,
service_desk_enabled:
true
)
}
before
do
let!
(
:project4
)
{
create
(
:empty_project
,
service_desk_enabled:
true
)
}
Project
.
update_all
(
service_desk_enabled:
true
)
end
context
'when Service Desk is disabled'
do
context
'when Service Desk is disabled'
do
it
'returns an empty hash'
do
it
'returns an empty hash'
do
allow
_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
false
)
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
false
)
expect
(
subject
).
to
eq
({})
expect
(
subject
).
to
eq
({})
end
end
...
@@ -115,8 +116,10 @@ describe Gitlab::UsageData do
...
@@ -115,8 +116,10 @@ describe Gitlab::UsageData do
context
'when Service Desk is enabled'
do
context
'when Service Desk is enabled'
do
it
'gathers Service Desk data'
do
it
'gathers Service Desk data'
do
create_list
(
:issue
,
3
,
confidential:
true
,
author:
User
.
support_bot
,
project:
[
project3
,
project4
].
sample
)
create_list
(
:issue
,
3
,
confidential:
true
,
author:
User
.
support_bot
,
project:
project
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
true
)
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
).
and_return
(
true
)
allow
(
::
EE
::
Gitlab
::
ServiceDesk
).
to
receive
(
:enabled?
).
with
(
anything
).
and_return
(
true
)
expect
(
subject
).
to
eq
(
service_desk_enabled_projects:
2
,
expect
(
subject
).
to
eq
(
service_desk_enabled_projects:
2
,
service_desk_issues:
3
)
service_desk_issues:
3
)
...
...
spec/models/ee/project_spec.rb
View file @
12c34661
...
@@ -211,12 +211,49 @@ describe Project, models: true do
...
@@ -211,12 +211,49 @@ describe Project, models: true do
end
end
end
end
describe
'#service_desk_enabled?'
do
let!
(
:license
)
{
create
(
:license
,
data:
build
(
:gitlab_license
,
restrictions:
{
plan:
License
::
PREMIUM_PLAN
}).
export
)
}
let
(
:namespace
)
{
create
(
:namespace
)
}
subject
(
:project
)
{
build
(
:empty_project
,
:private
,
namespace:
namespace
,
service_desk_enabled:
true
)
}
before
do
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
).
and_return
(
true
)
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
).
and_return
(
true
)
end
it
'is enabled'
do
expect
(
project
.
service_desk_enabled?
).
to
be_truthy
expect
(
project
.
service_desk_enabled
).
to
be_truthy
end
context
'namespace plans active'
do
before
do
stub_application_setting
(
check_namespace_plan:
true
)
end
it
'is disabled'
do
expect
(
project
.
service_desk_enabled?
).
to
be_falsy
expect
(
project
.
service_desk_enabled
).
to
be_falsy
end
context
'Service Desk available in namespace plan'
do
let
(
:namespace
)
{
create
(
:namespace
,
plan:
Namespace
::
SILVER_PLAN
)
}
it
'is enabled'
do
expect
(
project
.
service_desk_enabled?
).
to
be_truthy
expect
(
project
.
service_desk_enabled
).
to
be_truthy
end
end
end
end
describe
'#service_desk_address'
do
describe
'#service_desk_address'
do
let
(
:project
)
{
create
(
:empty_project
,
service_desk_enabled:
true
)
}
let
(
:project
)
{
create
(
:empty_project
,
service_desk_enabled:
true
)
}
before
do
before
do
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
::
EE
::
Gitlab
::
ServiceDesk
).
to
receive
(
:enabled?
).
and_return
(
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
Gitlab
.
config
.
incoming_email
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
incoming_email
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
incoming_email
).
to
receive
(
:address
).
and_return
(
"test+%{key}@mail.com"
)
allow
(
Gitlab
.
config
.
incoming_email
).
to
receive
(
:address
).
and_return
(
"test+%{key}@mail.com"
)
end
end
...
...
spec/services/ee/notification_service_spec.rb
View file @
12c34661
...
@@ -7,8 +7,7 @@ describe EE::NotificationService do
...
@@ -7,8 +7,7 @@ describe EE::NotificationService do
allow
(
Notify
).
to
receive
(
:service_desk_new_note_email
)
allow
(
Notify
).
to
receive
(
:service_desk_new_note_email
)
.
with
(
kind_of
(
Integer
),
kind_of
(
Integer
)).
and_return
(
double
(
deliver_later:
true
))
.
with
(
kind_of
(
Integer
),
kind_of
(
Integer
)).
and_return
(
double
(
deliver_later:
true
))
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
::
EE
::
Gitlab
::
ServiceDesk
).
to
receive
(
:enabled?
).
and_return
(
true
)
allow_any_instance_of
(
License
).
to
receive
(
:feature_available?
).
with
(
:service_desk
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
end
end
...
...
spec/workers/historical_data_worker_spec.rb
0 → 100644
View file @
12c34661
require
'spec_helper'
describe
HistoricalDataWorker
do
subject
{
described_class
.
new
}
describe
'#perform'
do
context
'with a trial license'
do
before
do
FactoryGirl
.
create
(
:trial_license
)
end
it
'does not track historical data'
do
expect
(
HistoricalData
).
not_to
receive
(
:track!
)
subject
.
perform
end
end
context
'with a non trial license'
do
before
do
FactoryGirl
.
create
(
:license
)
end
it
'tracks historical data'
do
expect
(
HistoricalData
).
to
receive
(
:track!
)
subject
.
perform
end
end
context
'with a Geo secondary node'
do
it
'does not track historical data'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
).
and_return
(
true
)
expect
(
HistoricalData
).
not_to
receive
(
:track!
)
subject
.
perform
end
end
context
'when there is not a license key'
do
it
'does not track historical data'
do
License
.
destroy_all
expect
(
HistoricalData
).
not_to
receive
(
:track!
)
subject
.
perform
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