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
1f240b09
Commit
1f240b09
authored
Sep 10, 2012
by
Alex Denisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User left project event added
parent
a86bd87a
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
75 additions
and
10 deletions
+75
-10
app/decorators/event_decorator.rb
app/decorators/event_decorator.rb
+1
-2
app/models/event.rb
app/models/event.rb
+13
-2
app/models/users_project.rb
app/models/users_project.rb
+1
-1
app/observers/users_project_observer.rb
app/observers/users_project_observer.rb
+9
-0
app/views/events/_event.html.haml
app/views/events/_event.html.haml
+2
-2
app/views/events/_event_membership_changed.html.haml
app/views/events/_event_membership_changed.html.haml
+1
-0
features/dashboard/dashboard.feature
features/dashboard/dashboard.feature
+7
-2
features/step_definitions/dashboard_steps.rb
features/step_definitions/dashboard_steps.rb
+10
-0
spec/models/event_spec.rb
spec/models/event_spec.rb
+12
-1
spec/observers/users_project_observer_spec.rb
spec/observers/users_project_observer_spec.rb
+19
-0
No files found.
app/decorators/event_decorator.rb
View file @
1f240b09
...
@@ -8,9 +8,8 @@ class EventDecorator < ApplicationDecorator
...
@@ -8,9 +8,8 @@ class EventDecorator < ApplicationDecorator
"
#{
self
.
author_name
}
#{
self
.
action_name
}
MR #
#{
self
.
target_id
}
:"
+
self
.
merge_request_title
"
#{
self
.
author_name
}
#{
self
.
action_name
}
MR #
#{
self
.
target_id
}
:"
+
self
.
merge_request_title
elsif
self
.
push?
elsif
self
.
push?
"
#{
self
.
author_name
}
#{
self
.
push_action_name
}
#{
self
.
ref_type
}
"
+
self
.
ref_name
"
#{
self
.
author_name
}
#{
self
.
push_action_name
}
#{
self
.
ref_type
}
"
+
self
.
ref_name
elsif
self
.
join
ed?
elsif
self
.
membership_chang
ed?
"
#{
self
.
author_name
}
#{
self
.
action_name
}
#{
self
.
project
.
name
}
"
"
#{
self
.
author_name
}
#{
self
.
action_name
}
#{
self
.
project
.
name
}
"
else
else
""
""
end
end
...
...
app/models/event.rb
View file @
1f240b09
...
@@ -11,6 +11,7 @@ class Event < ActiveRecord::Base
...
@@ -11,6 +11,7 @@ class Event < ActiveRecord::Base
Commented
=
6
Commented
=
6
Merged
=
7
Merged
=
7
Joined
=
8
# User joined project
Joined
=
8
# User joined project
Left
=
9
# User left project
belongs_to
:project
belongs_to
:project
belongs_to
:target
,
polymorphic:
true
belongs_to
:target
,
polymorphic:
true
...
@@ -38,7 +39,7 @@ class Event < ActiveRecord::Base
...
@@ -38,7 +39,7 @@ class Event < ActiveRecord::Base
# - new issue
# - new issue
# - merge request
# - merge request
def
allowed?
def
allowed?
push?
||
issue?
||
merge_request?
||
join
ed?
push?
||
issue?
||
merge_request?
||
membership_chang
ed?
end
end
def
push?
def
push?
...
@@ -86,7 +87,15 @@ class Event < ActiveRecord::Base
...
@@ -86,7 +87,15 @@ class Event < ActiveRecord::Base
end
end
def
joined?
def
joined?
action
==
self
.
class
::
Joined
action
==
Joined
end
def
left?
action
==
Left
end
def
membership_changed?
joined?
||
left?
end
end
def
issue
def
issue
...
@@ -108,6 +117,8 @@ class Event < ActiveRecord::Base
...
@@ -108,6 +117,8 @@ class Event < ActiveRecord::Base
"merged"
"merged"
elsif
joined?
elsif
joined?
'joined'
'joined'
elsif
left?
'left'
else
else
"opened"
"opened"
end
end
...
...
app/models/users_project.rb
View file @
1f240b09
...
@@ -23,7 +23,7 @@ class UsersProject < ActiveRecord::Base
...
@@ -23,7 +23,7 @@ class UsersProject < ActiveRecord::Base
def
self
.
bulk_delete
(
project
,
user_ids
)
def
self
.
bulk_delete
(
project
,
user_ids
)
UsersProject
.
transaction
do
UsersProject
.
transaction
do
UsersProject
.
where
(
:user_id
=>
user_ids
,
:project_id
=>
project
.
id
).
each
do
|
users_project
|
UsersProject
.
where
(
:user_id
=>
user_ids
,
:project_id
=>
project
.
id
).
each
do
|
users_project
|
users_project
.
de
lete
users_project
.
de
stroy
end
end
end
end
end
end
...
...
app/observers/users_project_observer.rb
View file @
1f240b09
...
@@ -12,4 +12,13 @@ class UsersProjectObserver < ActiveRecord::Observer
...
@@ -12,4 +12,13 @@ class UsersProjectObserver < ActiveRecord::Observer
def
after_update
(
users_project
)
def
after_update
(
users_project
)
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
end
end
def
after_destroy
(
users_project
)
Event
.
create
(
project_id:
users_project
.
project
.
id
,
action:
Event
::
Left
,
author_id:
users_project
.
user
.
id
)
end
end
end
app/views/events/_event.html.haml
View file @
1f240b09
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
.event_feed
.event_feed
=
render
"events/event_push"
,
event:
event
=
render
"events/event_push"
,
event:
event
-
elsif
event
.
join
ed?
-
elsif
event
.
membership_chang
ed?
.event_feed
.event_feed
=
render
"events/event_
join
ed"
,
event:
event
=
render
"events/event_
membership_chang
ed"
,
event:
event
app/views/events/_event_
join
ed.html.haml
→
app/views/events/_event_
membership_chang
ed.html.haml
View file @
1f240b09
=
image_tag
gravatar_icon
(
event
.
author_email
),
class:
"avatar"
=
image_tag
gravatar_icon
(
event
.
author_email
),
class:
"avatar"
%strong
#{
event
.
author_name
}
%strong
#{
event
.
author_name
}
%span
.event_label
{
class:
event
.
action_name
}=
event
.
action_name
%span
.event_label
{
class:
event
.
action_name
}=
event
.
action_name
project
%strong
=
link_to
event
.
project
.
name
,
event
.
project
%strong
=
link_to
event
.
project
.
name
,
event
.
project
%span
.cgray
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
=
time_ago_in_words
(
event
.
created_at
)
...
...
features/dashboard/dashboard.feature
View file @
1f240b09
...
@@ -15,9 +15,14 @@ Feature: Dashboard
...
@@ -15,9 +15,14 @@ Feature: Dashboard
And
I click
"Create Merge Request"
link
And
I click
"Create Merge Request"
link
Then
I see prefilled new Merge Request page
Then
I see prefilled new Merge Request page
@current
Scenario
:
I
should see User joined Project event
Scenario
:
I
should see User joined Project event
Given
user with name
"John Doe"
joined project
"Shop"
Given
user with name
"John Doe"
joined project
"Shop"
When
I visit dashboard page
When
I visit dashboard page
Then
I should see
"John Doe joined Shop"
event
Then
I should see
"John Doe joined project Shop"
event
Scenario
:
I
should see User left Project event
Given
user with name
"John Doe"
joined project
"Shop"
And
user with name
"John Doe"
left project
"Shop"
When
I visit dashboard page
Then
I should see
"John Doe left project Shop"
event
features/step_definitions/dashboard_steps.rb
View file @
1f240b09
...
@@ -120,6 +120,16 @@ Given /^user with name "(.*?)" joined project "(.*?)"$/ do |user_name, project_n
...
@@ -120,6 +120,16 @@ Given /^user with name "(.*?)" joined project "(.*?)"$/ do |user_name, project_n
)
)
end
end
Given
/^user with name "(.*?)" left project "(.*?)"$/
do
|
user_name
,
project_name
|
user
=
User
.
find_by_name
user_name
project
=
Project
.
find_by_name
project_name
Event
.
create
(
project:
project
,
author_id:
user
.
id
,
action:
Event
::
Left
)
end
Then
/^I should see "(.*?)" event$/
do
|
event_text
|
Then
/^I should see "(.*?)" event$/
do
|
event_text
|
page
.
should
have_content
(
event_text
)
page
.
should
have_content
(
event_text
)
end
end
...
...
spec/models/event_spec.rb
View file @
1f240b09
...
@@ -50,7 +50,7 @@ describe Event do
...
@@ -50,7 +50,7 @@ describe Event do
it
{
@event
.
author
.
should
==
@user
}
it
{
@event
.
author
.
should
==
@user
}
end
end
describe
"
New team mamber
"
do
describe
"
Joined project team
"
do
let
(
:project
)
{
Factory
.
create
:project
}
let
(
:project
)
{
Factory
.
create
:project
}
let
(
:new_user
)
{
Factory
.
create
:user
}
let
(
:new_user
)
{
Factory
.
create
:user
}
it
"should create event"
do
it
"should create event"
do
...
@@ -60,4 +60,15 @@ describe Event do
...
@@ -60,4 +60,15 @@ describe Event do
}.
to
change
{
Event
.
count
}.
by
(
1
)
}.
to
change
{
Event
.
count
}.
by
(
1
)
end
end
end
end
describe
"Left project team"
do
let
(
:project
)
{
Factory
.
create
:project
}
let
(
:new_user
)
{
Factory
.
create
:user
}
it
"should create event"
do
UsersProject
.
bulk_import
(
project
,
[
new_user
.
id
],
UsersProject
::
DEVELOPER
)
UsersProject
.
observers
.
enable
:users_project_observer
expect
{
UsersProject
.
bulk_delete
(
project
,
[
new_user
.
id
])
}.
to
change
{
Event
.
count
}.
by
(
1
)
end
end
end
end
spec/observers/users_project_observer_spec.rb
View file @
1f240b09
...
@@ -45,4 +45,23 @@ describe UsersProjectObserver do
...
@@ -45,4 +45,23 @@ describe UsersProjectObserver do
subject
.
after_update
(
users_project
)
subject
.
after_update
(
users_project
)
end
end
end
end
describe
"#after_destroy"
do
it
"should called when UsersProject destroyed"
do
subject
.
should_receive
(
:after_destroy
)
UsersProject
.
observers
.
enable
:users_project_observer
do
UsersProject
.
bulk_delete
(
users_project
.
project
,
[
users_project
.
user
.
id
]
)
end
end
it
"should create new event"
do
Event
.
should_receive
(
:create
).
with
(
project_id:
users_project
.
project
.
id
,
action:
Event
::
Left
,
author_id:
users_project
.
user
.
id
)
subject
.
after_destroy
(
users_project
)
end
end
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