Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
023dbf42e828
Commit
023dbf42
authored
Apr 03, 2013
by
Andrey Kumanyaev
Browse files
Fix tests
parent
9cae343818af
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
023dbf42
...
...
@@ -86,9 +86,9 @@
validate
:check_limit
,
:repo_name
# Scopes
scope
:without_user
,
->
(
user
)
{
where
(
"id NOT IN (:ids)"
,
ids:
user
.
authorized_projects
.
map
(
&
:id
)
)
}
scope
:without_team
,
->
(
team
)
{
team
.
projects
.
present?
?
where
(
"id NOT IN (:ids)"
,
ids:
team
.
projects
.
map
(
&
:id
))
:
scoped
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
scope
:in_team
,
->
(
team
)
{
where
(
"id IN (:ids)"
,
ids:
team
.
projects
.
map
(
&
:id
))
}
scope
:without_user
,
->
(
user
)
{
where
(
"
projects.
id NOT IN (:ids)"
,
ids:
user
.
authorized_projects
.
map
(
&
:id
)
)
}
scope
:without_team
,
->
(
team
)
{
team
.
projects
.
present?
?
where
(
"
projects.
id NOT IN (:ids)"
,
ids:
team
.
projects
.
map
(
&
:id
))
:
scoped
}
scope
:not_in_group
,
->
(
group
)
{
where
(
"
projects.
id NOT IN (:ids)"
,
ids:
group
.
project_ids
)
}
scope
:in_team
,
->
(
team
)
{
where
(
"
projects.
id IN (:ids)"
,
ids:
team
.
projects
.
map
(
&
:id
))
}
scope
:in_namespace
,
->
(
namespace
)
{
where
(
namespace_id:
namespace
.
id
)
}
scope
:in_group_namespace
,
->
{
joins
(
:group
)
}
...
...
@@ -93,6 +93,6 @@
scope
:in_namespace
,
->
(
namespace
)
{
where
(
namespace_id:
namespace
.
id
)
}
scope
:in_group_namespace
,
->
{
joins
(
:group
)
}
scope
:sorted_by_activity
,
->
{
order
(
"last_activity_at DESC"
)
}
scope
:sorted_by_activity
,
->
{
order
(
"
projects.
last_activity_at DESC"
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
scope
:public_only
,
->
{
where
(
public:
true
)
}
...
...
@@ -190,7 +190,7 @@
end
def
last_activity_date
last_activity_at
last_activity_at
||
updated_at
end
def
project_id
...
...
spec/models/project_spec.rb
View file @
023dbf42
...
...
@@ -108,8 +108,8 @@
describe
'last_activity_date'
do
it
'returns the creation date of the project\'s last event if present'
do
project
.
stub
(
last_event:
last_even
t
)
project
.
last_activity_date
.
should
==
last_event
.
created_at
last_activity_event
=
create
(
:event
,
project:
projec
t
)
project
.
last_activity_date
.
to_s
(
:db
).
should
==
last_event
.
created_at
.
to_s
(
:db
)
end
it
'returns the project\'s last update date if it has no events'
do
...
...
Write
Preview
Supports
Markdown
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