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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
8661a35e
Commit
8661a35e
authored
Oct 04, 2018
by
Olivier Gonzalez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pipeline.default_branch? mehod
Helps to know if the pipeline ref matches the project's default branch
parent
dfb9ac3a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+4
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+30
-0
No files found.
app/models/ci/pipeline.rb
View file @
8661a35e
...
@@ -627,6 +627,10 @@ module Ci
...
@@ -627,6 +627,10 @@ module Ci
end
end
end
end
def
default_branch?
ref
==
project
.
default_branch
end
private
private
def
ci_yaml_from_repo
def
ci_yaml_from_repo
...
...
spec/models/ci/pipeline_spec.rb
View file @
8661a35e
...
@@ -1968,4 +1968,34 @@ describe Ci::Pipeline, :mailer do
...
@@ -1968,4 +1968,34 @@ describe Ci::Pipeline, :mailer do
end
end
end
end
end
end
describe
'#default_branch?'
do
let
(
:default_branch
)
{
'master'
}
subject
{
pipeline
.
default_branch?
}
before
do
allow
(
project
).
to
receive
(
:default_branch
).
and_return
(
default_branch
)
end
context
'when pipeline ref is the default branch of the project'
do
let
(
:pipeline
)
do
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
,
ref:
default_branch
)
end
it
"returns true"
do
expect
(
subject
).
to
be_truthy
end
end
context
'when pipeline ref is not the default branch of the project'
do
let
(
:pipeline
)
do
build
(
:ci_empty_pipeline
,
status: :created
,
project:
project
,
ref:
'another_branch'
)
end
it
"returns false"
do
expect
(
subject
).
to
be_falsey
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