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
95e4217a
Commit
95e4217a
authored
Feb 13, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2979 from Undev/fix_naming
Constants in Events looks good now
parents
b9f8b401
839957cf
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
43 additions
and
43 deletions
+43
-43
app/models/event.rb
app/models/event.rb
+18
-18
app/models/merge_request.rb
app/models/merge_request.rb
+3
-3
app/models/project.rb
app/models/project.rb
+2
-2
app/observers/activity_observer.rb
app/observers/activity_observer.rb
+1
-1
app/observers/users_project_observer.rb
app/observers/users_project_observer.rb
+2
-2
features/steps/dashboard/dashboard.rb
features/steps/dashboard/dashboard.rb
+2
-2
features/steps/dashboard/dashboard_event_filters.rb
features/steps/dashboard/dashboard_event_filters.rb
+3
-3
features/steps/shared/project.rb
features/steps/shared/project.rb
+1
-1
lib/event_filter.rb
lib/event_filter.rb
+5
-5
spec/factories.rb
spec/factories.rb
+1
-1
spec/models/event_spec.rb
spec/models/event_spec.rb
+1
-1
spec/models/project_hooks_spec.rb
spec/models/project_hooks_spec.rb
+1
-1
spec/observers/activity_observer_spec.rb
spec/observers/activity_observer_spec.rb
+3
-3
No files found.
app/models/event.rb
View file @
95e4217a
...
...
@@ -20,15 +20,15 @@ class Event < ActiveRecord::Base
default_scope
where
(
"author_id IS NOT NULL"
)
C
reated
=
1
U
pdated
=
2
C
losed
=
3
R
eopened
=
4
P
ushed
=
5
C
ommented
=
6
M
erged
=
7
J
oined
=
8
# User joined project
L
eft
=
9
# User left project
C
REATED
=
1
U
PDATED
=
2
C
LOSED
=
3
R
EOPENED
=
4
P
USHED
=
5
C
OMMENTED
=
6
M
ERGED
=
7
J
OINED
=
8
# User joined project
L
EFT
=
9
# User left project
delegate
:name
,
:email
,
to: :author
,
prefix:
true
,
allow_nil:
true
delegate
:title
,
to: :issue
,
prefix:
true
,
allow_nil:
true
...
...
@@ -43,15 +43,15 @@ class Event < ActiveRecord::Base
# Scopes
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
scope
:code_push
,
->
{
where
(
action:
P
ushed
)
}
scope
:code_push
,
->
{
where
(
action:
P
USHED
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
class
<<
self
def
determine_action
(
record
)
if
[
Issue
,
MergeRequest
].
include?
record
.
class
Event
::
C
reated
Event
::
C
REATED
elsif
record
.
kind_of?
Note
Event
::
C
ommented
Event
::
C
OMMENTED
end
end
end
...
...
@@ -79,19 +79,19 @@ class Event < ActiveRecord::Base
end
def
push?
action
==
self
.
class
::
P
ushed
&&
valid_push?
action
==
self
.
class
::
P
USHED
&&
valid_push?
end
def
merged?
action
==
self
.
class
::
M
erged
action
==
self
.
class
::
M
ERGED
end
def
closed?
action
==
self
.
class
::
C
losed
action
==
self
.
class
::
C
LOSED
end
def
reopened?
action
==
self
.
class
::
R
eopened
action
==
self
.
class
::
R
EOPENED
end
def
milestone?
...
...
@@ -111,11 +111,11 @@ class Event < ActiveRecord::Base
end
def
joined?
action
==
J
oined
action
==
J
OINED
end
def
left?
action
==
L
eft
action
==
L
EFT
end
def
membership_changed?
...
...
app/models/merge_request.rb
View file @
95e4217a
...
...
@@ -133,11 +133,11 @@ class MergeRequest < ActiveRecord::Base
end
def
merge_event
self
.
project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
M
erged
).
last
self
.
project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
M
ERGED
).
last
end
def
closed_event
self
.
project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
C
losed
).
last
self
.
project
.
events
.
where
(
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
action:
Event
::
C
LOSED
).
last
end
def
commits
...
...
@@ -184,7 +184,7 @@ class MergeRequest < ActiveRecord::Base
self
.
mark_as_merged!
Event
.
create
(
project:
self
.
project
,
action:
Event
::
M
erged
,
action:
Event
::
M
ERGED
,
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
author_id:
user_id
...
...
app/models/project.rb
View file @
95e4217a
...
...
@@ -103,7 +103,7 @@ class Project < ActiveRecord::Base
end
def
with_push
includes
(
:events
).
where
(
'events.action = ?'
,
Event
::
P
ushed
)
includes
(
:events
).
where
(
'events.action = ?'
,
Event
::
P
USHED
)
end
def
active
...
...
@@ -336,7 +336,7 @@ class Project < ActiveRecord::Base
def
observe_push
(
data
)
Event
.
create
(
project:
self
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
author_id:
data
[
:user_id
]
)
...
...
app/observers/activity_observer.rb
View file @
95e4217a
...
...
@@ -26,7 +26,7 @@ class ActivityObserver < ActiveRecord::Observer
project:
record
.
project
,
target_id:
record
.
id
,
target_type:
record
.
class
.
name
,
action:
(
record
.
closed
?
Event
::
C
losed
:
Event
::
Reopened
),
action:
(
record
.
closed
?
Event
::
C
LOSED
:
Event
::
REOPENED
),
author_id:
record
.
author_id_of_changes
)
end
...
...
app/observers/users_project_observer.rb
View file @
95e4217a
...
...
@@ -7,7 +7,7 @@ class UsersProjectObserver < ActiveRecord::Observer
def
after_create
(
users_project
)
Event
.
create
(
project_id:
users_project
.
project
.
id
,
action:
Event
::
J
oined
,
action:
Event
::
J
OINED
,
author_id:
users_project
.
user
.
id
)
end
...
...
@@ -15,7 +15,7 @@ class UsersProjectObserver < ActiveRecord::Observer
def
after_destroy
(
users_project
)
Event
.
create
(
project_id:
users_project
.
project
.
id
,
action:
Event
::
L
eft
,
action:
Event
::
L
EFT
,
author_id:
users_project
.
user
.
id
)
end
...
...
features/steps/dashboard/dashboard.rb
View file @
95e4217a
...
...
@@ -33,7 +33,7 @@ class Dashboard < Spinach::FeatureSteps
Event
.
create
(
project:
project
,
author_id:
user
.
id
,
action:
Event
::
J
oined
action:
Event
::
J
OINED
)
end
...
...
@@ -47,7 +47,7 @@ class Dashboard < Spinach::FeatureSteps
Event
.
create
(
project:
project
,
author_id:
user
.
id
,
action:
Event
::
L
eft
action:
Event
::
L
EFT
)
end
...
...
features/steps/dashboard/dashboard_event_filters.rb
View file @
95e4217a
...
...
@@ -45,7 +45,7 @@ class EventFilters < Spinach::FeatureSteps
@event
=
Event
.
create
(
project:
@project
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
author_id:
@user
.
id
)
...
...
@@ -56,7 +56,7 @@ class EventFilters < Spinach::FeatureSteps
Event
.
create
(
project:
@project
,
author_id:
user
.
id
,
action:
Event
::
J
oined
action:
Event
::
J
OINED
)
end
...
...
@@ -64,7 +64,7 @@ class EventFilters < Spinach::FeatureSteps
merge_request
=
create
:merge_request
,
author:
@user
,
project:
@project
Event
.
create
(
project:
@project
,
action:
Event
::
M
erged
,
action:
Event
::
M
ERGED
,
target_id:
merge_request
.
id
,
target_type:
"MergeRequest"
,
author_id:
@user
.
id
...
...
features/steps/shared/project.rb
View file @
95e4217a
...
...
@@ -33,7 +33,7 @@ module SharedProject
@event
=
Event
.
create
(
project:
@project
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
author_id:
@user
.
id
)
...
...
lib/event_filter.rb
View file @
95e4217a
...
...
@@ -37,15 +37,15 @@ class EventFilter
filter
=
params
.
dup
actions
=
[]
actions
<<
Event
::
P
ushed
if
filter
.
include?
'push'
actions
<<
Event
::
M
erged
if
filter
.
include?
'merged'
actions
<<
Event
::
P
USHED
if
filter
.
include?
'push'
actions
<<
Event
::
M
ERGED
if
filter
.
include?
'merged'
if
filter
.
include?
'team'
actions
<<
Event
::
J
oined
actions
<<
Event
::
L
eft
actions
<<
Event
::
J
OINED
actions
<<
Event
::
L
EFT
end
actions
<<
Event
::
C
ommented
if
filter
.
include?
'comments'
actions
<<
Event
::
C
OMMENTED
if
filter
.
include?
'comments'
events
=
events
.
where
(
action:
actions
)
end
...
...
spec/factories.rb
View file @
95e4217a
...
...
@@ -123,7 +123,7 @@ FactoryGirl.define do
factory
:event
do
factory
:closed_issue_event
do
project
action
{
Event
::
C
losed
}
action
{
Event
::
C
LOSED
}
target
factory: :closed_issue
author
factory: :user
end
...
...
spec/models/event_spec.rb
View file @
95e4217a
...
...
@@ -52,7 +52,7 @@ describe Event do
@event
=
Event
.
create
(
project:
project
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
author_id:
@user
.
id
)
...
...
spec/models/project_hooks_spec.rb
View file @
95e4217a
...
...
@@ -19,7 +19,7 @@ describe Project, "Hooks" do
event
.
should_not
be_nil
event
.
project
.
should
==
project
event
.
action
.
should
==
Event
::
P
ushed
event
.
action
.
should
==
Event
::
P
USHED
event
.
data
.
should
==
data
end
end
...
...
spec/observers/activity_observer_spec.rb
View file @
95e4217a
...
...
@@ -17,7 +17,7 @@ describe ActivityObserver do
end
it_should_be_valid_event
it
{
@event
.
action
.
should
==
Event
::
C
reated
}
it
{
@event
.
action
.
should
==
Event
::
C
REATED
}
it
{
@event
.
target
.
should
==
@merge_request
}
end
...
...
@@ -30,7 +30,7 @@ describe ActivityObserver do
end
it_should_be_valid_event
it
{
@event
.
action
.
should
==
Event
::
C
reated
}
it
{
@event
.
action
.
should
==
Event
::
C
REATED
}
it
{
@event
.
target
.
should
==
@issue
}
end
...
...
@@ -44,7 +44,7 @@ describe ActivityObserver do
end
it_should_be_valid_event
it
{
@event
.
action
.
should
==
Event
::
C
ommented
}
it
{
@event
.
action
.
should
==
Event
::
C
OMMENTED
}
it
{
@event
.
target
.
should
==
@note
}
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