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
Tatuya Kamada
gitlab-ce
Commits
8f8efcfa
Commit
8f8efcfa
authored
Sep 28, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
2c1f7cca
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
14 deletions
+10
-14
app/models/ci/project.rb
app/models/ci/project.rb
+3
-3
app/models/project.rb
app/models/project.rb
+0
-1
app/views/ci/admin/projects/_project.html.haml
app/views/ci/admin/projects/_project.html.haml
+1
-1
spec/models/ci/project_spec.rb
spec/models/ci/project_spec.rb
+4
-7
spec/requests/ci/builds_spec.rb
spec/requests/ci/builds_spec.rb
+1
-1
spec/requests/ci/commits_spec.rb
spec/requests/ci/commits_spec.rb
+1
-1
No files found.
app/models/ci/project.rb
View file @
8f8efcfa
...
...
@@ -48,7 +48,7 @@ module Ci
accepts_nested_attributes_for
:variables
,
allow_destroy:
true
delegate
:commits
,
:builds
,
:last_commit
,
to: :gl_project
delegate
:commits
,
:builds
,
to: :gl_project
#
# Validations
...
...
@@ -103,8 +103,8 @@ module Ci
end
def
ordered_by_last_commit_date
last_commit_subquery
=
"(SELECT
project_id, MAX(committed_at) committed_at FROM
#{
Ci
::
Commit
.
table_name
}
GROUP BY
project_id)"
joins
(
"LEFT JOIN
#{
last_commit_subquery
}
AS last_commit ON
#{
Ci
::
Project
.
table_name
}
.
id = last_commit.
project_id"
).
last_commit_subquery
=
"(SELECT
gl_project_id, MAX(committed_at) committed_at FROM
#{
Ci
::
Commit
.
table_name
}
GROUP BY gl_
project_id)"
joins
(
"LEFT JOIN
#{
last_commit_subquery
}
AS last_commit ON
#{
Ci
::
Project
.
table_name
}
.
gitlab_id = last_commit.gl_
project_id"
).
order
(
"CASE WHEN last_commit.committed_at IS NULL THEN 1 ELSE 0 END, last_commit.committed_at DESC"
)
end
...
...
app/models/project.rb
View file @
8f8efcfa
...
...
@@ -120,7 +120,6 @@ class Project < ActiveRecord::Base
has_many
:starrers
,
through: :users_star_projects
,
source: :user
has_many
: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
:builds
,
through: :commits
,
dependent: :destroy
,
class_name:
'Ci::Build'
has_one
:last_commit
,
->
{
order
'ci_commits.created_at DESC'
},
class_name:
'Ci::Commit'
,
foreign_key: :gl_project_id
has_one
:import_data
,
dependent: :destroy
,
class_name:
"ProjectImportData"
has_one
:gitlab_ci_project
,
dependent: :destroy
,
class_name:
"Ci::Project"
,
foreign_key: :gitlab_id
...
...
app/views/ci/admin/projects/_project.html.haml
View file @
8f8efcfa
-
last_commit
=
project
.
last_commi
t
-
last_commit
=
project
.
commits
.
las
t
%tr
%td
=
project
.
id
...
...
spec/models/ci/project_spec.rb
View file @
8f8efcfa
...
...
@@ -28,9 +28,8 @@
require
'spec_helper'
describe
Ci
::
Project
do
let
(
:gl_project
)
{
FactoryGirl
.
create
:empty_project
,
gitlab_ci_project:
project
}
let
(
:gl_project
)
{
}
subject
{
FactoryGirl
.
build
:ci_project
}
let
(
:gl_project
)
{
FactoryGirl
.
create
:empty_project
}
subject
{
FactoryGirl
.
create
:ci_project
,
gl_project:
gl_project
}
it
{
is_expected
.
to
have_many
(
:runner_projects
)
}
it
{
is_expected
.
to
have_many
(
:runners
)
}
...
...
@@ -40,9 +39,7 @@ describe Ci::Project do
it
{
is_expected
.
to
have_many
(
:triggers
)
}
it
{
is_expected
.
to
have_many
(
:services
)
}
it
{
is_expected
.
to
validate_presence_of
:name
}
it
{
is_expected
.
to
validate_presence_of
:timeout
}
it
{
is_expected
.
to
validate_presence_of
:default_ref
}
describe
'before_validation'
do
it
'should set an random token if none provided'
do
...
...
@@ -78,7 +75,7 @@ describe Ci::Project do
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
.
commits
).
to
eq
([
commit2
.
project
,
commit1
.
project
])
expect
(
project
.
commits
).
to
eq
([
commit2
,
commit1
])
end
it
'returns commits ordered by committed_at and id, with nulls last'
do
...
...
@@ -86,7 +83,7 @@ describe Ci::Project do
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
.
commits
).
to
eq
([
commit2
.
project
,
commit4
.
project
,
commit3
.
project
,
commit1
.
project
])
expect
(
project
.
commits
).
to
eq
([
commit2
,
commit4
,
commit3
,
commit1
])
end
end
...
...
spec/requests/ci/builds_spec.rb
View file @
8f8efcfa
...
...
@@ -8,7 +8,7 @@ describe "Builds" do
describe
"GET /:project/builds/:id/status.json"
do
before
do
get
status_ci_project_build_path
(
@project
,
@build
),
format: :json
get
status_ci_project_build_path
(
@
commit
.
project
,
@build
),
format: :json
end
it
{
expect
(
response
.
status
).
to
eq
(
200
)
}
...
...
spec/requests/ci/commits_spec.rb
View file @
8f8efcfa
...
...
@@ -7,7 +7,7 @@ describe "Commits" do
describe
"GET /:project/refs/:ref_name/commits/:id/status.json"
do
before
do
get
status_ci_project_ref_commits_path
(
@project
,
@commit
.
ref
,
@commit
.
sha
),
format: :json
get
status_ci_project_ref_commits_path
(
@
commit
.
project
,
@commit
.
ref
,
@commit
.
sha
),
format: :json
end
it
{
expect
(
response
.
status
).
to
eq
(
200
)
}
...
...
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