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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
839957cf
Commit
839957cf
authored
11 years ago
by
Andrew8xx8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Constants in Events looks good now
parent
b9f8b401
No related merge requests found
Changes
13
Hide 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 @
839957cf
...
@@ -20,15 +20,15 @@ class Event < ActiveRecord::Base
...
@@ -20,15 +20,15 @@ class Event < ActiveRecord::Base
default_scope
where
(
"author_id IS NOT NULL"
)
default_scope
where
(
"author_id IS NOT NULL"
)
C
reated
=
1
C
REATED
=
1
U
pdated
=
2
U
PDATED
=
2
C
losed
=
3
C
LOSED
=
3
R
eopened
=
4
R
EOPENED
=
4
P
ushed
=
5
P
USHED
=
5
C
ommented
=
6
C
OMMENTED
=
6
M
erged
=
7
M
ERGED
=
7
J
oined
=
8
# User joined project
J
OINED
=
8
# User joined project
L
eft
=
9
# User left project
L
EFT
=
9
# User left project
delegate
:name
,
:email
,
to: :author
,
prefix:
true
,
allow_nil:
true
delegate
:name
,
:email
,
to: :author
,
prefix:
true
,
allow_nil:
true
delegate
:title
,
to: :issue
,
prefix:
true
,
allow_nil:
true
delegate
:title
,
to: :issue
,
prefix:
true
,
allow_nil:
true
...
@@ -43,15 +43,15 @@ class Event < ActiveRecord::Base
...
@@ -43,15 +43,15 @@ class Event < ActiveRecord::Base
# Scopes
# Scopes
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
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
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
class
<<
self
class
<<
self
def
determine_action
(
record
)
def
determine_action
(
record
)
if
[
Issue
,
MergeRequest
].
include?
record
.
class
if
[
Issue
,
MergeRequest
].
include?
record
.
class
Event
::
C
reated
Event
::
C
REATED
elsif
record
.
kind_of?
Note
elsif
record
.
kind_of?
Note
Event
::
C
ommented
Event
::
C
OMMENTED
end
end
end
end
end
end
...
@@ -79,19 +79,19 @@ class Event < ActiveRecord::Base
...
@@ -79,19 +79,19 @@ class Event < ActiveRecord::Base
end
end
def
push?
def
push?
action
==
self
.
class
::
P
ushed
&&
valid_push?
action
==
self
.
class
::
P
USHED
&&
valid_push?
end
end
def
merged?
def
merged?
action
==
self
.
class
::
M
erged
action
==
self
.
class
::
M
ERGED
end
end
def
closed?
def
closed?
action
==
self
.
class
::
C
losed
action
==
self
.
class
::
C
LOSED
end
end
def
reopened?
def
reopened?
action
==
self
.
class
::
R
eopened
action
==
self
.
class
::
R
EOPENED
end
end
def
milestone?
def
milestone?
...
@@ -111,11 +111,11 @@ class Event < ActiveRecord::Base
...
@@ -111,11 +111,11 @@ class Event < ActiveRecord::Base
end
end
def
joined?
def
joined?
action
==
J
oined
action
==
J
OINED
end
end
def
left?
def
left?
action
==
L
eft
action
==
L
EFT
end
end
def
membership_changed?
def
membership_changed?
...
...
This diff is collapsed.
Click to expand it.
app/models/merge_request.rb
View file @
839957cf
...
@@ -133,11 +133,11 @@ class MergeRequest < ActiveRecord::Base
...
@@ -133,11 +133,11 @@ class MergeRequest < ActiveRecord::Base
end
end
def
merge_event
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
end
def
closed_event
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
end
def
commits
def
commits
...
@@ -184,7 +184,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -184,7 +184,7 @@ class MergeRequest < ActiveRecord::Base
self
.
mark_as_merged!
self
.
mark_as_merged!
Event
.
create
(
Event
.
create
(
project:
self
.
project
,
project:
self
.
project
,
action:
Event
::
M
erged
,
action:
Event
::
M
ERGED
,
target_id:
self
.
id
,
target_id:
self
.
id
,
target_type:
"MergeRequest"
,
target_type:
"MergeRequest"
,
author_id:
user_id
author_id:
user_id
...
...
This diff is collapsed.
Click to expand it.
app/models/project.rb
View file @
839957cf
...
@@ -103,7 +103,7 @@ class Project < ActiveRecord::Base
...
@@ -103,7 +103,7 @@ class Project < ActiveRecord::Base
end
end
def
with_push
def
with_push
includes
(
:events
).
where
(
'events.action = ?'
,
Event
::
P
ushed
)
includes
(
:events
).
where
(
'events.action = ?'
,
Event
::
P
USHED
)
end
end
def
active
def
active
...
@@ -336,7 +336,7 @@ class Project < ActiveRecord::Base
...
@@ -336,7 +336,7 @@ class Project < ActiveRecord::Base
def
observe_push
(
data
)
def
observe_push
(
data
)
Event
.
create
(
Event
.
create
(
project:
self
,
project:
self
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
data:
data
,
author_id:
data
[
:user_id
]
author_id:
data
[
:user_id
]
)
)
...
...
This diff is collapsed.
Click to expand it.
app/observers/activity_observer.rb
View file @
839957cf
...
@@ -26,7 +26,7 @@ class ActivityObserver < ActiveRecord::Observer
...
@@ -26,7 +26,7 @@ class ActivityObserver < ActiveRecord::Observer
project:
record
.
project
,
project:
record
.
project
,
target_id:
record
.
id
,
target_id:
record
.
id
,
target_type:
record
.
class
.
name
,
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
author_id:
record
.
author_id_of_changes
)
)
end
end
...
...
This diff is collapsed.
Click to expand it.
app/observers/users_project_observer.rb
View file @
839957cf
...
@@ -7,7 +7,7 @@ class UsersProjectObserver < ActiveRecord::Observer
...
@@ -7,7 +7,7 @@ class UsersProjectObserver < ActiveRecord::Observer
def
after_create
(
users_project
)
def
after_create
(
users_project
)
Event
.
create
(
Event
.
create
(
project_id:
users_project
.
project
.
id
,
project_id:
users_project
.
project
.
id
,
action:
Event
::
J
oined
,
action:
Event
::
J
OINED
,
author_id:
users_project
.
user
.
id
author_id:
users_project
.
user
.
id
)
)
end
end
...
@@ -15,7 +15,7 @@ class UsersProjectObserver < ActiveRecord::Observer
...
@@ -15,7 +15,7 @@ class UsersProjectObserver < ActiveRecord::Observer
def
after_destroy
(
users_project
)
def
after_destroy
(
users_project
)
Event
.
create
(
Event
.
create
(
project_id:
users_project
.
project
.
id
,
project_id:
users_project
.
project
.
id
,
action:
Event
::
L
eft
,
action:
Event
::
L
EFT
,
author_id:
users_project
.
user
.
id
author_id:
users_project
.
user
.
id
)
)
end
end
...
...
This diff is collapsed.
Click to expand it.
features/steps/dashboard/dashboard.rb
View file @
839957cf
...
@@ -33,7 +33,7 @@ class Dashboard < Spinach::FeatureSteps
...
@@ -33,7 +33,7 @@ class Dashboard < Spinach::FeatureSteps
Event
.
create
(
Event
.
create
(
project:
project
,
project:
project
,
author_id:
user
.
id
,
author_id:
user
.
id
,
action:
Event
::
J
oined
action:
Event
::
J
OINED
)
)
end
end
...
@@ -47,7 +47,7 @@ class Dashboard < Spinach::FeatureSteps
...
@@ -47,7 +47,7 @@ class Dashboard < Spinach::FeatureSteps
Event
.
create
(
Event
.
create
(
project:
project
,
project:
project
,
author_id:
user
.
id
,
author_id:
user
.
id
,
action:
Event
::
L
eft
action:
Event
::
L
EFT
)
)
end
end
...
...
This diff is collapsed.
Click to expand it.
features/steps/dashboard/dashboard_event_filters.rb
View file @
839957cf
...
@@ -45,7 +45,7 @@ class EventFilters < Spinach::FeatureSteps
...
@@ -45,7 +45,7 @@ class EventFilters < Spinach::FeatureSteps
@event
=
Event
.
create
(
@event
=
Event
.
create
(
project:
@project
,
project:
@project
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
data:
data
,
author_id:
@user
.
id
author_id:
@user
.
id
)
)
...
@@ -56,7 +56,7 @@ class EventFilters < Spinach::FeatureSteps
...
@@ -56,7 +56,7 @@ class EventFilters < Spinach::FeatureSteps
Event
.
create
(
Event
.
create
(
project:
@project
,
project:
@project
,
author_id:
user
.
id
,
author_id:
user
.
id
,
action:
Event
::
J
oined
action:
Event
::
J
OINED
)
)
end
end
...
@@ -64,7 +64,7 @@ class EventFilters < Spinach::FeatureSteps
...
@@ -64,7 +64,7 @@ class EventFilters < Spinach::FeatureSteps
merge_request
=
create
:merge_request
,
author:
@user
,
project:
@project
merge_request
=
create
:merge_request
,
author:
@user
,
project:
@project
Event
.
create
(
Event
.
create
(
project:
@project
,
project:
@project
,
action:
Event
::
M
erged
,
action:
Event
::
M
ERGED
,
target_id:
merge_request
.
id
,
target_id:
merge_request
.
id
,
target_type:
"MergeRequest"
,
target_type:
"MergeRequest"
,
author_id:
@user
.
id
author_id:
@user
.
id
...
...
This diff is collapsed.
Click to expand it.
features/steps/shared/project.rb
View file @
839957cf
...
@@ -33,7 +33,7 @@ module SharedProject
...
@@ -33,7 +33,7 @@ module SharedProject
@event
=
Event
.
create
(
@event
=
Event
.
create
(
project:
@project
,
project:
@project
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
data:
data
,
author_id:
@user
.
id
author_id:
@user
.
id
)
)
...
...
This diff is collapsed.
Click to expand it.
lib/event_filter.rb
View file @
839957cf
...
@@ -37,15 +37,15 @@ class EventFilter
...
@@ -37,15 +37,15 @@ class EventFilter
filter
=
params
.
dup
filter
=
params
.
dup
actions
=
[]
actions
=
[]
actions
<<
Event
::
P
ushed
if
filter
.
include?
'push'
actions
<<
Event
::
P
USHED
if
filter
.
include?
'push'
actions
<<
Event
::
M
erged
if
filter
.
include?
'merged'
actions
<<
Event
::
M
ERGED
if
filter
.
include?
'merged'
if
filter
.
include?
'team'
if
filter
.
include?
'team'
actions
<<
Event
::
J
oined
actions
<<
Event
::
J
OINED
actions
<<
Event
::
L
eft
actions
<<
Event
::
L
EFT
end
end
actions
<<
Event
::
C
ommented
if
filter
.
include?
'comments'
actions
<<
Event
::
C
OMMENTED
if
filter
.
include?
'comments'
events
=
events
.
where
(
action:
actions
)
events
=
events
.
where
(
action:
actions
)
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/factories.rb
View file @
839957cf
...
@@ -123,7 +123,7 @@ FactoryGirl.define do
...
@@ -123,7 +123,7 @@ FactoryGirl.define do
factory
:event
do
factory
:event
do
factory
:closed_issue_event
do
factory
:closed_issue_event
do
project
project
action
{
Event
::
C
losed
}
action
{
Event
::
C
LOSED
}
target
factory: :closed_issue
target
factory: :closed_issue
author
factory: :user
author
factory: :user
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/models/event_spec.rb
View file @
839957cf
...
@@ -52,7 +52,7 @@ describe Event do
...
@@ -52,7 +52,7 @@ describe Event do
@event
=
Event
.
create
(
@event
=
Event
.
create
(
project:
project
,
project:
project
,
action:
Event
::
P
ushed
,
action:
Event
::
P
USHED
,
data:
data
,
data:
data
,
author_id:
@user
.
id
author_id:
@user
.
id
)
)
...
...
This diff is collapsed.
Click to expand it.
spec/models/project_hooks_spec.rb
View file @
839957cf
...
@@ -19,7 +19,7 @@ describe Project, "Hooks" do
...
@@ -19,7 +19,7 @@ describe Project, "Hooks" do
event
.
should_not
be_nil
event
.
should_not
be_nil
event
.
project
.
should
==
project
event
.
project
.
should
==
project
event
.
action
.
should
==
Event
::
P
ushed
event
.
action
.
should
==
Event
::
P
USHED
event
.
data
.
should
==
data
event
.
data
.
should
==
data
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/observers/activity_observer_spec.rb
View file @
839957cf
...
@@ -17,7 +17,7 @@ describe ActivityObserver do
...
@@ -17,7 +17,7 @@ describe ActivityObserver do
end
end
it_should_be_valid_event
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
}
it
{
@event
.
target
.
should
==
@merge_request
}
end
end
...
@@ -30,7 +30,7 @@ describe ActivityObserver do
...
@@ -30,7 +30,7 @@ describe ActivityObserver do
end
end
it_should_be_valid_event
it_should_be_valid_event
it
{
@event
.
action
.
should
==
Event
::
C
reated
}
it
{
@event
.
action
.
should
==
Event
::
C
REATED
}
it
{
@event
.
target
.
should
==
@issue
}
it
{
@event
.
target
.
should
==
@issue
}
end
end
...
@@ -44,7 +44,7 @@ describe ActivityObserver do
...
@@ -44,7 +44,7 @@ describe ActivityObserver do
end
end
it_should_be_valid_event
it_should_be_valid_event
it
{
@event
.
action
.
should
==
Event
::
C
ommented
}
it
{
@event
.
action
.
should
==
Event
::
C
OMMENTED
}
it
{
@event
.
target
.
should
==
@note
}
it
{
@event
.
target
.
should
==
@note
}
end
end
end
end
This diff is collapsed.
Click to expand it.
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