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
45e0e68f
Commit
45e0e68f
authored
Jun 15, 2021
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename jenkins service to jenkins integration
Renames project association to jenkins association name.
parent
3f8193f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
40 deletions
+47
-40
app/models/integration.rb
app/models/integration.rb
+1
-0
app/models/project.rb
app/models/project.rb
+1
-1
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-1
spec/models/integrations/jenkins_spec.rb
spec/models/integrations/jenkins_spec.rb
+44
-38
No files found.
app/models/integration.rb
View file @
45e0e68f
...
@@ -48,6 +48,7 @@ class Integration < ApplicationRecord
...
@@ -48,6 +48,7 @@ class Integration < ApplicationRecord
flowdock
flowdock
hangouts_chat
hangouts_chat
irker
irker
jenkins
packagist pipelines_email pivotaltracker pushover
packagist pipelines_email pivotaltracker pushover
mattermost mattermost_slash_commands microsoft_teams mock_ci mock_monitoring
mattermost mattermost_slash_commands microsoft_teams mock_ci mock_monitoring
]
.
to_set
.
freeze
]
.
to_set
.
freeze
...
...
app/models/project.rb
View file @
45e0e68f
...
@@ -172,7 +172,7 @@ class Project < ApplicationRecord
...
@@ -172,7 +172,7 @@ class Project < ApplicationRecord
has_one
:flowdock_integration
,
class_name:
'Integrations::Flowdock'
has_one
:flowdock_integration
,
class_name:
'Integrations::Flowdock'
has_one
:hangouts_chat_integration
,
class_name:
'Integrations::HangoutsChat'
has_one
:hangouts_chat_integration
,
class_name:
'Integrations::HangoutsChat'
has_one
:irker_integration
,
class_name:
'Integrations::Irker'
has_one
:irker_integration
,
class_name:
'Integrations::Irker'
has_one
:jenkins_
service
,
class_name:
'Integrations::Jenkins'
has_one
:jenkins_
integration
,
class_name:
'Integrations::Jenkins'
has_one
:jira_service
,
class_name:
'Integrations::Jira'
has_one
:jira_service
,
class_name:
'Integrations::Jira'
has_one
:mattermost_integration
,
class_name:
'Integrations::Mattermost'
has_one
:mattermost_integration
,
class_name:
'Integrations::Mattermost'
has_one
:mattermost_slash_commands_integration
,
class_name:
'Integrations::MattermostSlashCommands'
has_one
:mattermost_slash_commands_integration
,
class_name:
'Integrations::MattermostSlashCommands'
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
45e0e68f
...
@@ -485,7 +485,7 @@ project:
...
@@ -485,7 +485,7 @@ project:
-
protected_environments
-
protected_environments
-
mirror_user
-
mirror_user
-
push_rule
-
push_rule
-
jenkins_
service
-
jenkins_
integration
-
index_status
-
index_status
-
feature_usage
-
feature_usage
-
approval_rules
-
approval_rules
...
...
spec/models/integrations/jenkins_spec.rb
View file @
45e0e68f
...
@@ -30,8 +30,8 @@ RSpec.describe Integrations::Jenkins do
...
@@ -30,8 +30,8 @@ RSpec.describe Integrations::Jenkins do
end
end
describe
'username validation'
do
describe
'username validation'
do
before
do
let
(
:jenkins_integration
)
do
@jenkins_service
=
described_class
.
create!
(
described_class
.
create!
(
active:
active
,
active:
active
,
project:
project
,
project:
project
,
properties:
{
properties:
{
...
@@ -43,7 +43,7 @@ RSpec.describe Integrations::Jenkins do
...
@@ -43,7 +43,7 @@ RSpec.describe Integrations::Jenkins do
)
)
end
end
subject
{
@jenkins_service
}
subject
{
jenkins_integration
}
context
'when the service is active'
do
context
'when the service is active'
do
let
(
:active
)
{
true
}
let
(
:active
)
{
true
}
...
@@ -84,7 +84,7 @@ RSpec.describe Integrations::Jenkins do
...
@@ -84,7 +84,7 @@ RSpec.describe Integrations::Jenkins do
describe
'#hook_url'
do
describe
'#hook_url'
do
let
(
:username
)
{
nil
}
let
(
:username
)
{
nil
}
let
(
:password
)
{
nil
}
let
(
:password
)
{
nil
}
let
(
:jenkins_
service
)
do
let
(
:jenkins_
integration
)
do
described_class
.
new
(
described_class
.
new
(
project:
project
,
project:
project
,
properties:
{
properties:
{
...
@@ -96,7 +96,7 @@ RSpec.describe Integrations::Jenkins do
...
@@ -96,7 +96,7 @@ RSpec.describe Integrations::Jenkins do
)
)
end
end
subject
{
jenkins_
service
.
hook_url
}
subject
{
jenkins_
integration
.
hook_url
}
context
'when the jenkins_url has no relative path'
do
context
'when the jenkins_url has no relative path'
do
let
(
:jenkins_url
)
{
'http://jenkins.example.com/'
}
let
(
:jenkins_url
)
{
'http://jenkins.example.com/'
}
...
@@ -138,10 +138,10 @@ RSpec.describe Integrations::Jenkins do
...
@@ -138,10 +138,10 @@ RSpec.describe Integrations::Jenkins do
user
=
create
(
:user
,
username:
'username'
)
user
=
create
(
:user
,
username:
'username'
)
project
=
create
(
:project
,
name:
'project'
)
project
=
create
(
:project
,
name:
'project'
)
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
push_sample_data
=
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
jenkins_
service
=
described_class
.
create!
(
jenkins_params
)
jenkins_
integration
=
described_class
.
create!
(
jenkins_params
)
stub_request
(
:post
,
jenkins_hook_url
).
with
(
headers:
{
'Authorization'
=>
jenkins_authorization
})
stub_request
(
:post
,
jenkins_hook_url
).
with
(
headers:
{
'Authorization'
=>
jenkins_authorization
})
result
=
jenkins_
service
.
test
(
push_sample_data
)
result
=
jenkins_
integration
.
test
(
push_sample_data
)
expect
(
result
).
to
eq
({
success:
true
,
result:
''
})
expect
(
result
).
to
eq
({
success:
true
,
result:
''
})
end
end
...
@@ -152,20 +152,20 @@ RSpec.describe Integrations::Jenkins do
...
@@ -152,20 +152,20 @@ RSpec.describe Integrations::Jenkins do
let
(
:namespace
)
{
create
(
:group
,
:private
)
}
let
(
:namespace
)
{
create
(
:group
,
:private
)
}
let
(
:project
)
{
create
(
:project
,
:private
,
name:
'project'
,
namespace:
namespace
)
}
let
(
:project
)
{
create
(
:project
,
:private
,
name:
'project'
,
namespace:
namespace
)
}
let
(
:push_sample_data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
}
let
(
:push_sample_data
)
{
Gitlab
::
DataBuilder
::
Push
.
build_sample
(
project
,
user
)
}
let
(
:jenkins_
service
)
{
described_class
.
create!
(
jenkins_params
)
}
let
(
:jenkins_
integration
)
{
described_class
.
create!
(
jenkins_params
)
}
before
do
before
do
stub_request
(
:post
,
jenkins_hook_url
)
stub_request
(
:post
,
jenkins_hook_url
)
end
end
it
'invokes the Jenkins API'
do
it
'invokes the Jenkins API'
do
jenkins_
service
.
execute
(
push_sample_data
)
jenkins_
integration
.
execute
(
push_sample_data
)
expect
(
a_request
(
:post
,
jenkins_hook_url
)).
to
have_been_made
.
once
expect
(
a_request
(
:post
,
jenkins_hook_url
)).
to
have_been_made
.
once
end
end
it
'adds default web hook headers to the request'
do
it
'adds default web hook headers to the request'
do
jenkins_
service
.
execute
(
push_sample_data
)
jenkins_
integration
.
execute
(
push_sample_data
)
expect
(
expect
(
a_request
(
:post
,
jenkins_hook_url
)
a_request
(
:post
,
jenkins_hook_url
)
...
@@ -174,7 +174,7 @@ RSpec.describe Integrations::Jenkins do
...
@@ -174,7 +174,7 @@ RSpec.describe Integrations::Jenkins do
end
end
it
'request url contains properly serialized username and password'
do
it
'request url contains properly serialized username and password'
do
jenkins_
service
.
execute
(
push_sample_data
)
jenkins_
integration
.
execute
(
push_sample_data
)
expect
(
expect
(
a_request
(
:post
,
'http://jenkins.example.com/project/my_project'
)
a_request
(
:post
,
'http://jenkins.example.com/project/my_project'
)
...
@@ -187,8 +187,8 @@ RSpec.describe Integrations::Jenkins do
...
@@ -187,8 +187,8 @@ RSpec.describe Integrations::Jenkins do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
context
'when a password was previously set'
do
context
'when a password was previously set'
do
before
do
let
(
:jenkins_integration
)
do
@jenkins_service
=
described_class
.
create!
(
described_class
.
create!
(
project:
project
,
project:
project
,
properties:
{
properties:
{
jenkins_url:
'http://jenkins.example.com/'
,
jenkins_url:
'http://jenkins.example.com/'
,
...
@@ -199,42 +199,47 @@ RSpec.describe Integrations::Jenkins do
...
@@ -199,42 +199,47 @@ RSpec.describe Integrations::Jenkins do
end
end
it
'resets password if url changed'
do
it
'resets password if url changed'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins-edited.example.com/'
jenkins_integration
.
jenkins_url
=
'http://jenkins-edited.example.com/'
@jenkins_service
.
save!
jenkins_integration
.
save!
expect
(
@jenkins_service
.
password
).
to
be_nil
expect
(
jenkins_integration
.
password
).
to
be_nil
end
end
it
'resets password if username is blank'
do
it
'resets password if username is blank'
do
@jenkins_service
.
username
=
''
jenkins_integration
.
username
=
''
@jenkins_service
.
save!
jenkins_integration
.
save!
expect
(
@jenkins_service
.
password
).
to
be_nil
expect
(
jenkins_integration
.
password
).
to
be_nil
end
end
it
'does not reset password if username changed'
do
it
'does not reset password if username changed'
do
@jenkins_service
.
username
=
'some_name'
jenkins_integration
.
username
=
'some_name'
@jenkins_service
.
save!
jenkins_integration
.
save!
expect
(
@jenkins_service
.
password
).
to
eq
(
'password'
)
expect
(
jenkins_integration
.
password
).
to
eq
(
'password'
)
end
end
it
'does not reset password if new url is set together with password, even if it\'s the same password'
do
it
'does not reset password if new url is set together with password, even if it\'s the same password'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins_edited.example.com/'
jenkins_integration
.
jenkins_url
=
'http://jenkins_edited.example.com/'
@jenkins_service
.
password
=
'password'
jenkins_integration
.
password
=
'password'
@jenkins_service
.
save!
jenkins_integration
.
save!
expect
(
@jenkins_service
.
password
).
to
eq
(
'password'
)
expect
(
@jenkins_service
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
expect
(
jenkins_integration
.
password
).
to
eq
(
'password'
)
expect
(
jenkins_integration
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
end
end
it
'resets password if url changed, even if setter called multiple times'
do
it
'resets password if url changed, even if setter called multiple times'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins1.example.com/'
jenkins_integration
.
jenkins_url
=
'http://jenkins1.example.com/'
@jenkins_service
.
jenkins_url
=
'http://jenkins1.example.com/'
jenkins_integration
.
jenkins_url
=
'http://jenkins1.example.com/'
@jenkins_service
.
save!
jenkins_integration
.
save!
expect
(
@jenkins_service
.
password
).
to
be_nil
expect
(
jenkins_integration
.
password
).
to
be_nil
end
end
end
end
context
'when no password was previously set'
do
context
'when no password was previously set'
do
before
do
let
(
:jenkins_integration
)
do
@jenkins_service
=
described_class
.
create!
(
described_class
.
create!
(
project:
create
(
:project
),
project:
create
(
:project
),
properties:
{
properties:
{
jenkins_url:
'http://jenkins.example.com/'
,
jenkins_url:
'http://jenkins.example.com/'
,
...
@@ -244,11 +249,12 @@ RSpec.describe Integrations::Jenkins do
...
@@ -244,11 +249,12 @@ RSpec.describe Integrations::Jenkins do
end
end
it
'saves password if new url is set together with password'
do
it
'saves password if new url is set together with password'
do
@jenkins_service
.
jenkins_url
=
'http://jenkins_edited.example.com/'
jenkins_integration
.
jenkins_url
=
'http://jenkins_edited.example.com/'
@jenkins_service
.
password
=
'password'
jenkins_integration
.
password
=
'password'
@jenkins_service
.
save!
jenkins_integration
.
save!
expect
(
@jenkins_service
.
password
).
to
eq
(
'password'
)
expect
(
@jenkins_service
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
expect
(
jenkins_integration
.
password
).
to
eq
(
'password'
)
expect
(
jenkins_integration
.
jenkins_url
).
to
eq
(
'http://jenkins_edited.example.com/'
)
end
end
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