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
b7d14e28
Commit
b7d14e28
authored
Mar 14, 2021
by
Philip Cunningham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue with dastProfiles.branch GraphQL field
- Replace stub - Update specs - Add changelog entry
parent
f974964d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
12 deletions
+53
-12
ee/app/models/dast/branch.rb
ee/app/models/dast/branch.rb
+5
-3
ee/app/models/dast/profile.rb
ee/app/models/dast/profile.rb
+1
-1
ee/changelogs/unreleased/philipcunningham-fix-dast-branch-selection-issue.yml
...ased/philipcunningham-fix-dast-branch-selection-issue.yml
+5
-0
ee/spec/graphql/types/dast/profile_type_spec.rb
ee/spec/graphql/types/dast/profile_type_spec.rb
+1
-1
ee/spec/models/dast/branch_spec.rb
ee/spec/models/dast/branch_spec.rb
+40
-6
ee/spec/policies/dast/branch_policy_spec.rb
ee/spec/policies/dast/branch_policy_spec.rb
+1
-1
No files found.
ee/app/models/dast/branch.rb
View file @
b7d14e28
# frozen_string_literal: true
# frozen_string_literal: true
module
Dast
module
Dast
Branch
=
Struct
.
new
(
:project
)
do
Branch
=
Struct
.
new
(
:profile
)
do
delegate
:project
,
to: :profile
def
name
def
name
project
.
default_branch
pro
file
.
branch_name
||
pro
ject
.
default_branch
end
end
def
exists
def
exists
project
.
repository
.
branch_exists?
(
project
.
default_branch
)
project
.
repository
.
branch_exists?
(
name
)
end
end
end
end
end
end
ee/app/models/dast/profile.rb
View file @
b7d14e28
...
@@ -23,7 +23,7 @@ module Dast
...
@@ -23,7 +23,7 @@ module Dast
def
branch
def
branch
return
unless
project
.
repository
.
exists?
return
unless
project
.
repository
.
exists?
Dast
::
Branch
.
new
(
project
)
Dast
::
Branch
.
new
(
self
)
end
end
private
private
...
...
ee/changelogs/unreleased/philipcunningham-fix-dast-branch-selection-issue.yml
0 → 100644
View file @
b7d14e28
---
title
:
Replace stubbed dastProfiles.branch GraphQL field
merge_request
:
56604
author
:
type
:
fixed
ee/spec/graphql/types/dast/profile_type_spec.rb
View file @
b7d14e28
...
@@ -31,7 +31,7 @@ RSpec.describe GitlabSchema.types['DastProfile'] do
...
@@ -31,7 +31,7 @@ RSpec.describe GitlabSchema.types['DastProfile'] do
context
'when the feature flag is enabled'
do
context
'when the feature flag is enabled'
do
it
'correctly resolves the field'
do
it
'correctly resolves the field'
do
expected_result
=
Dast
::
Branch
.
new
(
pro
ject
)
expected_result
=
Dast
::
Branch
.
new
(
ob
ject
)
expect
(
resolve_field
(
:branch
,
object
,
current_user:
user
)).
to
eq
(
expected_result
)
expect
(
resolve_field
(
:branch
,
object
,
current_user:
user
)).
to
eq
(
expected_result
)
end
end
...
...
ee/spec/models/dast/branch_spec.rb
View file @
b7d14e28
...
@@ -3,11 +3,17 @@
...
@@ -3,11 +3,17 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Dast
::
Branch
do
RSpec
.
describe
Dast
::
Branch
do
let_it_be
(
:
project
)
{
create
(
:project
)
}
let_it_be
(
:
dast_profile
)
{
create
(
:dast_profile
)
}
subject
{
described_class
.
new
(
project
)
}
subject
{
described_class
.
new
(
dast_profile
)
}
describe
'instance methods'
do
describe
'#project'
do
it
'delegates to profile.project'
do
expect
(
subject
.
project
).
to
eq
(
dast_profile
.
project
)
end
end
context
'when profile.branch_name is nil'
do
context
'when the associated project does not have a repository'
do
context
'when the associated project does not have a repository'
do
describe
'#name'
do
describe
'#name'
do
it
'returns nil'
do
it
'returns nil'
do
...
@@ -23,11 +29,11 @@ RSpec.describe Dast::Branch do
...
@@ -23,11 +29,11 @@ RSpec.describe Dast::Branch do
end
end
context
'when the associated project has a repository'
do
context
'when the associated project has a repository'
do
let_it_be
(
:
project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:
dast_profile
)
{
create
(
:dast_profile
,
project:
create
(
:project
,
:repository
)
)
}
describe
'#name'
do
describe
'#name'
do
it
'returns
the
default_branch'
do
it
'returns
project.
default_branch'
do
expect
(
subject
.
name
).
to
eq
(
project
.
default_branch
)
expect
(
subject
.
name
).
to
eq
(
subject
.
project
.
default_branch
)
end
end
end
end
...
@@ -38,4 +44,32 @@ RSpec.describe Dast::Branch do
...
@@ -38,4 +44,32 @@ RSpec.describe Dast::Branch do
end
end
end
end
end
end
context
'when profile.branch_name is not nil'
do
let_it_be
(
:dast_profile
)
{
create
(
:dast_profile
,
branch_name:
'orphaned-branch'
)
}
describe
'#name'
do
it
'returns profile.branch_name'
do
expect
(
subject
.
name
).
to
eq
(
dast_profile
.
branch_name
)
end
end
context
'when the associated project does not have a repository'
do
describe
'#exists'
do
it
'returns false'
do
expect
(
subject
.
exists
).
to
eq
(
false
)
end
end
end
context
'when the associated branch has a repository and the branch exists'
do
let_it_be
(
:dast_profile
)
{
create
(
:dast_profile
,
project:
create
(
:project
,
:repository
),
branch_name:
'orphaned-branch'
)
}
describe
'#exists'
do
it
'returns true'
do
expect
(
subject
.
exists
).
to
eq
(
true
)
end
end
end
end
end
end
ee/spec/policies/dast/branch_policy_spec.rb
View file @
b7d14e28
...
@@ -4,6 +4,6 @@ require 'spec_helper'
...
@@ -4,6 +4,6 @@ require 'spec_helper'
RSpec
.
describe
Dast
::
BranchPolicy
do
RSpec
.
describe
Dast
::
BranchPolicy
do
it_behaves_like
'a dast on-demand scan policy'
do
it_behaves_like
'a dast on-demand scan policy'
do
let_it_be
(
:record
)
{
Dast
::
Branch
.
new
(
project
)
}
let_it_be
(
:record
)
{
Dast
::
Branch
.
new
(
create
(
:dast_profile
,
project:
project
)
)
}
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