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
2930cf7c
Commit
2930cf7c
authored
Jan 10, 2022
by
Siddharth Asthana
Committed by
Markus Koller
Jan 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor all the specs to use `:integration` rather than `:service`
Changelog: other
parent
96110427
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
192 additions
and
194 deletions
+192
-194
ee/spec/models/ee/integration_spec.rb
ee/spec/models/ee/integration_spec.rb
+4
-4
spec/factories/integrations.rb
spec/factories/integrations.rb
+1
-1
spec/factories/usage_data.rb
spec/factories/usage_data.rb
+10
-10
spec/features/merge_request/user_sees_merge_widget_spec.rb
spec/features/merge_request/user_sees_merge_widget_spec.rb
+1
-1
spec/features/profiles/chat_names_spec.rb
spec/features/profiles/chat_names_spec.rb
+1
-1
spec/graphql/types/projects/service_type_spec.rb
spec/graphql/types/projects/service_type_spec.rb
+1
-1
spec/helpers/auto_devops_helper_spec.rb
spec/helpers/auto_devops_helper_spec.rb
+1
-1
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
+1
-1
spec/lib/gitlab/import_export/project/relation_factory_spec.rb
...lib/gitlab/import_export/project/relation_factory_spec.rb
+1
-1
spec/lib/gitlab/integrations/sti_type_spec.rb
spec/lib/gitlab/integrations/sti_type_spec.rb
+5
-7
spec/models/integration_spec.rb
spec/models/integration_spec.rb
+138
-138
spec/models/project_spec.rb
spec/models/project_spec.rb
+21
-21
spec/services/chat_names/authorize_user_service_spec.rb
spec/services/chat_names/authorize_user_service_spec.rb
+3
-3
spec/services/chat_names/find_user_service_spec.rb
spec/services/chat_names/find_user_service_spec.rb
+1
-1
spec/support/import_export/export_file_helper.rb
spec/support/import_export/export_file_helper.rb
+1
-1
spec/workers/deployments/hooks_worker_spec.rb
spec/workers/deployments/hooks_worker_spec.rb
+2
-2
No files found.
ee/spec/models/ee/integration_spec.rb
View file @
2930cf7c
...
...
@@ -32,14 +32,14 @@ RSpec.describe Integration do
end
describe
'.vulnerability_hooks'
do
it
'includes
service
s where vulnerability_events is true'
do
create
(
:
service
,
active:
true
,
vulnerability_events:
true
)
it
'includes
integration
s where vulnerability_events is true'
do
create
(
:
integration
,
active:
true
,
vulnerability_events:
true
)
expect
(
described_class
.
vulnerability_hooks
.
count
).
to
eq
1
end
it
'excludes
service
s where vulnerability_events is false'
do
create
(
:
service
,
active:
true
,
vulnerability_events:
false
)
it
'excludes
integration
s where vulnerability_events is false'
do
create
(
:
integration
,
active:
true
,
vulnerability_events:
false
)
expect
(
described_class
.
vulnerability_hooks
.
count
).
to
eq
0
end
...
...
spec/factories/integrations.rb
View file @
2930cf7c
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:integration
,
aliases:
[
:service
]
do
factory
:integration
do
project
type
{
'Integration'
}
end
...
...
spec/factories/usage_data.rb
View file @
2930cf7c
...
...
@@ -19,16 +19,16 @@ FactoryBot.define do
create
(
:jira_import_state
,
:finished
,
project:
projects
[
1
],
label:
jira_label
,
imported_issues_count:
3
)
create
(
:jira_import_state
,
:scheduled
,
project:
projects
[
1
],
label:
jira_label
)
create
(
:prometheus_integration
,
project:
projects
[
1
])
create
(
:
service
,
project:
projects
[
1
],
type:
'JenkinsService'
,
active:
true
)
create
(
:
service
,
project:
projects
[
0
],
type:
'SlackSlashCommandsService'
,
active:
true
)
create
(
:
service
,
project:
projects
[
1
],
type:
'SlackService'
,
active:
true
)
create
(
:
service
,
project:
projects
[
2
],
type:
'SlackService'
,
active:
true
)
create
(
:
service
,
project:
projects
[
2
],
type:
'MattermostService'
,
active:
false
)
create
(
:
service
,
group:
group
,
project:
nil
,
type:
'MattermostService'
,
active:
true
)
mattermost_instance
=
create
(
:
service
,
:instance
,
type:
'MattermostService'
,
active:
true
)
create
(
:
service
,
project:
projects
[
1
],
type:
'MattermostService'
,
active:
true
,
inherit_from_id:
mattermost_instance
.
id
)
create
(
:
service
,
group:
group
,
project:
nil
,
type:
'SlackService'
,
active:
true
,
inherit_from_id:
mattermost_instance
.
id
)
create
(
:
service
,
project:
projects
[
2
],
type:
'CustomIssueTrackerService'
,
active:
true
)
create
(
:
integration
,
project:
projects
[
1
],
type:
'JenkinsService'
,
active:
true
)
create
(
:
integration
,
project:
projects
[
0
],
type:
'SlackSlashCommandsService'
,
active:
true
)
create
(
:
integration
,
project:
projects
[
1
],
type:
'SlackService'
,
active:
true
)
create
(
:
integration
,
project:
projects
[
2
],
type:
'SlackService'
,
active:
true
)
create
(
:
integration
,
project:
projects
[
2
],
type:
'MattermostService'
,
active:
false
)
create
(
:
integration
,
group:
group
,
project:
nil
,
type:
'MattermostService'
,
active:
true
)
mattermost_instance
=
create
(
:
integration
,
:instance
,
type:
'MattermostService'
,
active:
true
)
create
(
:
integration
,
project:
projects
[
1
],
type:
'MattermostService'
,
active:
true
,
inherit_from_id:
mattermost_instance
.
id
)
create
(
:
integration
,
group:
group
,
project:
nil
,
type:
'SlackService'
,
active:
true
,
inherit_from_id:
mattermost_instance
.
id
)
create
(
:
integration
,
project:
projects
[
2
],
type:
'CustomIssueTrackerService'
,
active:
true
)
create
(
:project_error_tracking_setting
,
project:
projects
[
0
])
create
(
:project_error_tracking_setting
,
project:
projects
[
1
],
enabled:
false
)
alert_bot_issues
=
create_list
(
:incident
,
2
,
project:
projects
[
0
],
author:
User
.
alert_bot
)
...
...
spec/features/merge_request/user_sees_merge_widget_spec.rb
View file @
2930cf7c
...
...
@@ -96,7 +96,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js do
context
'view merge request with external CI service'
do
before
do
create
(
:
service
,
project:
project
,
create
(
:
integration
,
project:
project
,
active:
true
,
type:
'DroneCiService'
,
category:
'ci'
)
...
...
spec/features/profiles/chat_names_spec.rb
View file @
2930cf7c
...
...
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec
.
describe
'Profile > Chat'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:integration
)
{
create
(
:
service
)
}
let
(
:integration
)
{
create
(
:
integration
)
}
before
do
sign_in
(
user
)
...
...
spec/graphql/types/projects/service_type_spec.rb
View file @
2930cf7c
...
...
@@ -8,7 +8,7 @@ RSpec.describe Types::Projects::ServiceType do
describe
".resolve_type"
do
it
'resolves the corresponding type for objects'
do
expect
(
described_class
.
resolve_type
(
build
(
:jira_integration
),
{})).
to
eq
(
Types
::
Projects
::
Services
::
JiraServiceType
)
expect
(
described_class
.
resolve_type
(
build
(
:
service
),
{})).
to
eq
(
Types
::
Projects
::
Services
::
BaseServiceType
)
expect
(
described_class
.
resolve_type
(
build
(
:
integration
),
{})).
to
eq
(
Types
::
Projects
::
Services
::
BaseServiceType
)
expect
(
described_class
.
resolve_type
(
build
(
:drone_ci_integration
),
{})).
to
eq
(
Types
::
Projects
::
Services
::
BaseServiceType
)
expect
(
described_class
.
resolve_type
(
build
(
:custom_issue_tracker_integration
),
{})).
to
eq
(
Types
::
Projects
::
Services
::
BaseServiceType
)
end
...
...
spec/helpers/auto_devops_helper_spec.rb
View file @
2930cf7c
...
...
@@ -86,7 +86,7 @@ RSpec.describe AutoDevopsHelper do
context
'when another service is enabled'
do
before
do
create
(
:
service
,
project:
project
,
category: :ci
,
active:
true
)
create
(
:
integration
,
project:
project
,
category: :ci
,
active:
true
)
end
it
{
is_expected
.
to
eq
(
false
)
}
...
...
spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
View file @
2930cf7c
...
...
@@ -258,7 +258,7 @@ RSpec.describe Gitlab::ImportExport::FastHashSerializer do
create
(
:resource_label_event
,
label:
group_label
,
merge_request:
merge_request
)
create
(
:event
,
:created
,
target:
milestone
,
project:
project
,
author:
user
)
create
(
:
service
,
project:
project
,
type:
'CustomIssueTrackerService'
,
category:
'issue_tracker'
,
properties:
{
one:
'value'
})
create
(
:
integration
,
project:
project
,
type:
'CustomIssueTrackerService'
,
category:
'issue_tracker'
,
properties:
{
one:
'value'
})
create
(
:project_custom_attribute
,
project:
project
)
create
(
:project_custom_attribute
,
project:
project
)
...
...
spec/lib/gitlab/import_export/project/relation_factory_spec.rb
View file @
2930cf7c
...
...
@@ -88,7 +88,7 @@ RSpec.describe Gitlab::ImportExport::Project::RelationFactory, :use_clean_rails_
end
context
'original service exists'
do
let
(
:service_id
)
{
create
(
:
service
,
project:
project
).
id
}
let
(
:service_id
)
{
create
(
:
integration
,
project:
project
).
id
}
it
'does not have the original service_id'
do
expect
(
created_object
.
service_id
).
not_to
eq
(
service_id
)
...
...
spec/lib/gitlab/integrations/sti_type_spec.rb
View file @
2930cf7c
...
...
@@ -46,11 +46,11 @@ RSpec.describe Gitlab::Integrations::StiType do
SQL
end
let_it_be
(
:
service
)
{
create
(
:service
)
}
let_it_be
(
:
integration
)
{
create
(
:integration
)
}
it
'forms SQL UPDATE statements correctly'
do
sql_statements
=
types
.
map
do
|
type
|
record
=
ActiveRecord
::
QueryRecorder
.
new
{
service
.
update_column
(
:type
,
type
)
}
record
=
ActiveRecord
::
QueryRecorder
.
new
{
integration
.
update_column
(
:type
,
type
)
}
record
.
log
.
first
end
...
...
@@ -65,8 +65,6 @@ RSpec.describe Gitlab::Integrations::StiType do
SQL
end
let
(
:service
)
{
create
(
:service
)
}
it
'forms SQL DELETE statements correctly'
do
sql_statements
=
types
.
map
do
|
type
|
record
=
ActiveRecord
::
QueryRecorder
.
new
{
Integration
.
delete_by
(
type:
type
)
}
...
...
@@ -81,7 +79,7 @@ RSpec.describe Gitlab::Integrations::StiType do
describe
'#deserialize'
do
specify
'it deserializes type correctly'
,
:aggregate_failures
do
types
.
each
do
|
type
|
service
=
create
(
:
service
,
type:
type
)
service
=
create
(
:
integration
,
type:
type
)
expect
(
service
.
type
).
to
eq
(
'AsanaService'
)
end
...
...
@@ -90,7 +88,7 @@ RSpec.describe Gitlab::Integrations::StiType do
describe
'#cast'
do
it
'casts type as model correctly'
,
:aggregate_failures
do
create
(
:
service
,
type:
'AsanaService'
)
create
(
:
integration
,
type:
'AsanaService'
)
types
.
each
do
|
type
|
expect
(
Integration
.
find_by
(
type:
type
)).
to
be_kind_of
(
Integrations
::
Asana
)
...
...
@@ -100,7 +98,7 @@ RSpec.describe Gitlab::Integrations::StiType do
describe
'#changed?'
do
it
'detects changes correctly'
,
:aggregate_failures
do
service
=
create
(
:
service
,
type:
'AsanaService'
)
service
=
create
(
:
integration
,
type:
'AsanaService'
)
types
.
each
do
|
type
|
service
.
type
=
type
...
...
spec/models/integration_spec.rb
View file @
2930cf7c
This diff is collapsed.
Click to expand it.
spec/models/project_spec.rb
View file @
2930cf7c
...
...
@@ -1359,51 +1359,51 @@ RSpec.describe Project, factory_default: :keep do
project
.
reload
.
has_external_issue_tracker
end
it
'is false when external issue tracker
service
is not active'
do
create
(
:
service
,
project:
project
,
category:
'issue_tracker'
,
active:
false
)
it
'is false when external issue tracker
integration
is not active'
do
create
(
:
integration
,
project:
project
,
category:
'issue_tracker'
,
active:
false
)
is_expected
.
to
eq
(
false
)
end
it
'is false when other
service
is active'
do
create
(
:
service
,
project:
project
,
category:
'not_issue_tracker'
,
active:
true
)
it
'is false when other
integration
is active'
do
create
(
:
integration
,
project:
project
,
category:
'not_issue_tracker'
,
active:
true
)
is_expected
.
to
eq
(
false
)
end
context
'when there is an active external issue tracker
service
'
do
let!
(
:
service
)
do
create
(
:
service
,
project:
project
,
type:
'JiraService'
,
category:
'issue_tracker'
,
active:
true
)
context
'when there is an active external issue tracker
integration
'
do
let!
(
:
integration
)
do
create
(
:
integration
,
project:
project
,
type:
'JiraService'
,
category:
'issue_tracker'
,
active:
true
)
end
specify
{
is_expected
.
to
eq
(
true
)
}
it
'becomes false when external issue tracker
service
is destroyed'
do
it
'becomes false when external issue tracker
integration
is destroyed'
do
expect
do
Integration
.
find
(
service
.
id
).
delete
Integration
.
find
(
integration
.
id
).
delete
end
.
to
change
{
subject
}.
to
(
false
)
end
it
'becomes false when external issue tracker
service
becomes inactive'
do
it
'becomes false when external issue tracker
integration
becomes inactive'
do
expect
do
service
.
update_column
(
:active
,
false
)
integration
.
update_column
(
:active
,
false
)
end
.
to
change
{
subject
}.
to
(
false
)
end
context
'when there are two active external issue tracker
service
s'
do
let_it_be
(
:second_
service
)
do
create
(
:
service
,
project:
project
,
type:
'CustomIssueTracker'
,
category:
'issue_tracker'
,
active:
true
)
context
'when there are two active external issue tracker
integration
s'
do
let_it_be
(
:second_
integration
)
do
create
(
:
integration
,
project:
project
,
type:
'CustomIssueTracker'
,
category:
'issue_tracker'
,
active:
true
)
end
it
'does not become false when external issue tracker
service
is destroyed'
do
it
'does not become false when external issue tracker
integration
is destroyed'
do
expect
do
Integration
.
find
(
service
.
id
).
delete
Integration
.
find
(
integration
.
id
).
delete
end
.
not_to
change
{
subject
}
end
it
'does not become false when external issue tracker
service
becomes inactive'
do
it
'does not become false when external issue tracker
integration
becomes inactive'
do
expect
do
service
.
update_column
(
:active
,
false
)
integration
.
update_column
(
:active
,
false
)
end
.
not_to
change
{
subject
}
end
end
...
...
@@ -1455,13 +1455,13 @@ RSpec.describe Project, factory_default: :keep do
specify
{
expect
(
has_external_wiki
).
to
eq
(
true
)
}
it
'becomes false if the external wiki
service
is destroyed'
do
it
'becomes false if the external wiki
integration
is destroyed'
do
expect
do
Integration
.
find
(
integration
.
id
).
delete
end
.
to
change
{
has_external_wiki
}.
to
(
false
)
end
it
'becomes false if the external wiki
service
becomes inactive'
do
it
'becomes false if the external wiki
integration
becomes inactive'
do
expect
do
integration
.
update_column
(
:active
,
false
)
end
.
to
change
{
has_external_wiki
}.
to
(
false
)
...
...
@@ -6836,7 +6836,7 @@ RSpec.describe Project, factory_default: :keep do
describe
'with integrations and chat names'
do
subject
{
create
(
:project
)
}
let
(
:integration
)
{
create
(
:
service
,
project:
subject
)
}
let
(
:integration
)
{
create
(
:
integration
,
project:
subject
)
}
before
do
create_list
(
:chat_name
,
5
,
integration:
integration
)
...
...
spec/services/chat_names/authorize_user_service_spec.rb
View file @
2930cf7c
...
...
@@ -4,10 +4,10 @@ require 'spec_helper'
RSpec
.
describe
ChatNames
::
AuthorizeUserService
do
describe
'#execute'
do
subject
{
described_class
.
new
(
service
,
params
)
}
let
(
:integration
)
{
create
(
:integration
)
}
let
(
:result
)
{
subject
.
execute
}
let
(
:service
)
{
create
(
:service
)
}
subject
{
described_class
.
new
(
integration
,
params
)
}
context
'when all parameters are valid'
do
let
(
:params
)
{
{
team_id:
'T0001'
,
team_domain:
'myteam'
,
user_id:
'U0001'
,
user_name:
'user'
}
}
...
...
spec/services/chat_names/find_user_service_spec.rb
View file @
2930cf7c
...
...
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec
.
describe
ChatNames
::
FindUserService
,
:clean_gitlab_redis_shared_state
do
describe
'#execute'
do
let
(
:integration
)
{
create
(
:
service
)
}
let
(
:integration
)
{
create
(
:
integration
)
}
subject
{
described_class
.
new
(
integration
,
params
).
execute
}
...
...
spec/support/import_export/export_file_helper.rb
View file @
2930cf7c
...
...
@@ -44,7 +44,7 @@ module ExportFileHelper
create
(
:ci_trigger
,
project:
project
)
key
=
create
(
:deploy_key
)
key
.
projects
<<
project
create
(
:
service
,
project:
project
)
create
(
:
integration
,
project:
project
)
create
(
:project_hook
,
project:
project
,
token:
'token'
)
create
(
:protected_branch
,
project:
project
)
...
...
spec/workers/deployments/hooks_worker_spec.rb
View file @
2930cf7c
...
...
@@ -13,7 +13,7 @@ RSpec.describe Deployments::HooksWorker do
it
'executes project services for deployment_hooks'
do
deployment
=
create
(
:deployment
,
:running
)
project
=
deployment
.
project
service
=
create
(
:
service
,
type:
'SlackService'
,
project:
project
,
deployment_events:
true
,
active:
true
)
service
=
create
(
:
integration
,
type:
'SlackService'
,
project:
project
,
deployment_events:
true
,
active:
true
)
expect
(
ProjectServiceWorker
).
to
receive
(
:perform_async
).
with
(
service
.
id
,
an_instance_of
(
Hash
))
...
...
@@ -23,7 +23,7 @@ RSpec.describe Deployments::HooksWorker do
it
'does not execute an inactive service'
do
deployment
=
create
(
:deployment
,
:running
)
project
=
deployment
.
project
create
(
:
service
,
type:
'SlackService'
,
project:
project
,
deployment_events:
true
,
active:
false
)
create
(
:
integration
,
type:
'SlackService'
,
project:
project
,
deployment_events:
true
,
active:
false
)
expect
(
ProjectServiceWorker
).
not_to
receive
(
:perform_async
)
...
...
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