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
09255eec
Commit
09255eec
authored
Oct 14, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove ordering from :ci_commits relation
parent
a957eca6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
20 deletions
+22
-20
app/models/ci/commit.rb
app/models/ci/commit.rb
+2
-0
app/models/ci/project.rb
app/models/ci/project.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-1
spec/models/ci/commit_spec.rb
spec/models/ci/commit_spec.rb
+18
-0
spec/models/ci/project_spec.rb
spec/models/ci/project_spec.rb
+0
-18
No files found.
app/models/ci/commit.rb
View file @
09255eec
...
...
@@ -24,6 +24,8 @@ module Ci
has_many
:builds
,
class_name:
'Ci::Build'
has_many
:trigger_requests
,
dependent: :destroy
,
class_name:
'Ci::TriggerRequest'
scope
:ordered
,
->
{
order
(
'CASE WHEN ci_commits.committed_at IS NULL THEN 0 ELSE 1 END'
,
:committed_at
,
:id
)
}
validates_presence_of
:sha
validate
:valid_commit_sha
...
...
app/models/ci/project.rb
View file @
09255eec
...
...
@@ -205,7 +205,7 @@ module Ci
end
def
commits
gl_project
.
ci_commits
gl_project
.
ci_commits
.
ordered
end
def
builds
...
...
app/models/project.rb
View file @
09255eec
...
...
@@ -119,7 +119,7 @@ class Project < ActiveRecord::Base
has_many
:deploy_keys
,
through: :deploy_keys_projects
has_many
:users_star_projects
,
dependent: :destroy
has_many
:starrers
,
through: :users_star_projects
,
source: :user
has_many
:ci_commits
,
->
()
{
order
(
'CASE WHEN ci_commits.committed_at IS NULL THEN 0 ELSE 1 END'
,
:committed_at
,
:id
)
},
dependent: :destroy
,
class_name:
'Ci::Commit'
,
foreign_key: :gl_project_id
has_many
:ci_commits
,
dependent: :destroy
,
class_name:
'Ci::Commit'
,
foreign_key: :gl_project_id
has_many
:ci_builds
,
through: :ci_commits
,
source: :builds
,
dependent: :destroy
,
class_name:
'Ci::Build'
has_one
:import_data
,
dependent: :destroy
,
class_name:
"ProjectImportData"
...
...
spec/models/ci/commit_spec.rb
View file @
09255eec
...
...
@@ -32,6 +32,24 @@ describe Ci::Commit do
it
{
is_expected
.
to
respond_to
:git_author_email
}
it
{
is_expected
.
to
respond_to
:short_sha
}
describe
:ordered
do
let
(
:project
)
{
FactoryGirl
.
create
:empty_project
}
it
'returns ordered list of commits'
do
commit1
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
1
.
hour
.
ago
,
gl_project:
project
commit2
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
2
.
hour
.
ago
,
gl_project:
project
expect
(
project
.
ci_commits
.
ordered
).
to
eq
([
commit2
,
commit1
])
end
it
'returns commits ordered by committed_at and id, with nulls last'
do
commit1
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
1
.
hour
.
ago
,
gl_project:
project
commit2
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
nil
,
gl_project:
project
commit3
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
2
.
hour
.
ago
,
gl_project:
project
commit4
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
nil
,
gl_project:
project
expect
(
project
.
ci_commits
.
ordered
).
to
eq
([
commit2
,
commit4
,
commit3
,
commit1
])
end
end
describe
:last_build
do
subject
{
commit
.
last_build
}
before
do
...
...
spec/models/ci/project_spec.rb
View file @
09255eec
...
...
@@ -131,24 +131,6 @@ describe Ci::Project do
end
end
describe
'ordered commits'
do
let
(
:project
)
{
FactoryGirl
.
create
:empty_project
}
it
'returns ordered list of commits'
do
commit1
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
1
.
hour
.
ago
,
gl_project:
project
commit2
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
2
.
hour
.
ago
,
gl_project:
project
expect
(
project
.
ci_commits
).
to
eq
([
commit2
,
commit1
])
end
it
'returns commits ordered by committed_at and id, with nulls last'
do
commit1
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
1
.
hour
.
ago
,
gl_project:
project
commit2
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
nil
,
gl_project:
project
commit3
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
2
.
hour
.
ago
,
gl_project:
project
commit4
=
FactoryGirl
.
create
:ci_commit
,
committed_at:
nil
,
gl_project:
project
expect
(
project
.
ci_commits
).
to
eq
([
commit2
,
commit4
,
commit3
,
commit1
])
end
end
context
:valid_project
do
let
(
:commit
)
{
FactoryGirl
.
create
(
:ci_commit
)
}
...
...
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