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
5becd865
Commit
5becd865
authored
Mar 25, 2020
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create basic functions for OpenProjectService
- associate with data fields - add specs
parent
22d211d0
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
3 deletions
+104
-3
app/models/project_services/open_project_service.rb
app/models/project_services/open_project_service.rb
+18
-0
app/models/project_services/open_project_tracker_data.rb
app/models/project_services/open_project_tracker_data.rb
+2
-2
spec/factories/services.rb
spec/factories/services.rb
+20
-0
spec/factories/services_data.rb
spec/factories/services_data.rb
+8
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
spec/models/project_services/jira_tracker_data_spec.rb
spec/models/project_services/jira_tracker_data_spec.rb
+1
-1
spec/models/project_services/open_project_service_spec.rb
spec/models/project_services/open_project_service_spec.rb
+35
-0
spec/models/project_services/open_project_tracker_data_spec.rb
...models/project_services/open_project_tracker_data_spec.rb
+19
-0
No files found.
app/models/project_services/open_project_service.rb
0 → 100644
View file @
5becd865
# frozen_string_literal: true
class
OpenProjectService
<
IssueTrackerService
validates
:url
,
public_url:
true
,
presence:
true
,
if: :activated?
validates
:api_url
,
public_url:
true
,
allow_blank:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
validates
:project_identifier_code
,
presence:
true
,
if: :activated?
data_field
:url
,
:api_url
,
:token
,
:closed_status_id
,
:project_identifier_code
def
data_fields
open_project_tracker_data
||
self
.
build_open_project_tracker_data
end
def
self
.
to_param
'open_project'
end
end
app/models/project_services/open_project_tracker_data.rb
View file @
5becd865
# frozen_string_literal: true
class
OpenProjectTrackerData
<
ApplicationRecord
include
Services
::
DataFields
# When the Open Project is fresh installed, the default closed status id is "13" based on current version: v8.
DEFAULT_CLOSED_STATUS_ID
=
"13"
include
Services
::
DataFields
attr_encrypted
:url
,
encryption_options
attr_encrypted
:api_url
,
encryption_options
attr_encrypted
:token
,
encryption_options
...
...
spec/factories/services.rb
View file @
5becd865
...
...
@@ -126,6 +126,26 @@ FactoryBot.define do
end
end
factory
:open_project_service
do
project
active
{
true
}
transient
do
url
{
'http://openproject.example.com'
}
api_url
{
'http://openproject.example.com/issues/:id'
}
token
{
'supersecret'
}
closed_status_id
{
'15'
}
project_identifier_code
{
'PRJ-1'
}
end
after
(
:build
)
do
|
service
,
evaluator
|
create
(
:open_project_tracker_data
,
service:
service
,
url:
evaluator
.
url
,
api_url:
evaluator
.
api_url
,
token:
evaluator
.
token
,
closed_status_id:
evaluator
.
closed_status_id
,
project_identifier_code:
evaluator
.
project_identifier_code
)
end
end
trait
:jira_cloud_service
do
url
{
'https://mysite.atlassian.net'
}
username
{
'jira_user'
}
...
...
spec/factories/services_data.rb
View file @
5becd865
...
...
@@ -9,4 +9,12 @@ FactoryBot.define do
factory
:issue_tracker_data
do
service
end
factory
:open_project_tracker_data
do
service
url
{
'http://openproject.example.com'
}
token
{
'supersecret'
}
project_identifier_code
{
'PRJ-1'
}
closed_status_id
{
'15'
}
end
end
spec/lib/gitlab/import_export/all_models.yml
View file @
5becd865
...
...
@@ -252,6 +252,7 @@ services:
-
service_hook
-
jira_tracker_data
-
issue_tracker_data
-
open_project_tracker_data
hooks
:
-
project
-
web_hook_logs
...
...
spec/models/project_services/jira_tracker_data_spec.rb
View file @
5becd865
...
...
@@ -3,7 +3,7 @@
require
'spec_helper'
describe
JiraTrackerData
do
let
(
:service
)
{
create
(
:jira_service
,
active:
false
,
properties:
{}
)
}
let
(
:service
)
{
create
(
:jira_service
,
active:
false
)
}
describe
'Associations'
do
it
{
is_expected
.
to
belong_to
(
:service
)
}
...
...
spec/models/project_services/open_project_service_spec.rb
0 → 100644
View file @
5becd865
# frozen_string_literal: true
require
'spec_helper'
describe
OpenProjectService
do
describe
'Validations'
do
context
'when service is active'
do
before
do
subject
.
active
=
true
end
it
{
is_expected
.
to
validate_presence_of
(
:url
)
}
it
{
is_expected
.
to
validate_presence_of
(
:token
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_identifier_code
)
}
it_behaves_like
'issue tracker service URL attribute'
,
:url
it_behaves_like
'issue tracker service URL attribute'
,
:api_url
end
context
'when service is inactive'
do
before
do
subject
.
active
=
false
end
it
{
is_expected
.
not_to
validate_presence_of
(
:url
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:token
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:project_identifier_code
)
}
end
end
describe
'Associations'
do
it
{
is_expected
.
to
belong_to
:project
}
it
{
is_expected
.
to
have_one
:service_hook
}
end
end
spec/models/project_services/open_project_tracker_data_spec.rb
0 → 100644
View file @
5becd865
# frozen_string_literal: true
require
'spec_helper'
describe
OpenProjectTrackerData
do
describe
'Associations'
do
it
{
is_expected
.
to
belong_to
(
:service
)
}
end
describe
'closed_status_id'
do
it
'returns the set value'
do
expect
(
build
(
:open_project_tracker_data
).
closed_status_id
).
to
eq
(
'15'
)
end
it
'returns the default value if not set'
do
expect
(
build
(
:open_project_tracker_data
,
closed_status_id:
nil
).
closed_status_id
).
to
eq
(
'13'
)
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