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
Boxiang Sun
gitlab-ce
Commits
a86bd87a
Commit
a86bd87a
authored
Sep 09, 2012
by
Alex Denisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User joined project event added
parent
a56cec11
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
78 additions
and
3 deletions
+78
-3
app/assets/stylesheets/common.scss
app/assets/stylesheets/common.scss
+8
-0
app/decorators/event_decorator.rb
app/decorators/event_decorator.rb
+4
-1
app/models/event.rb
app/models/event.rb
+8
-1
app/observers/users_project_observer.rb
app/observers/users_project_observer.rb
+6
-0
app/views/events/_event.html.haml
app/views/events/_event.html.haml
+4
-0
app/views/events/_event_joined.html.haml
app/views/events/_event_joined.html.haml
+8
-0
features/dashboard/dashboard.feature
features/dashboard/dashboard.feature
+6
-1
features/step_definitions/dashboard_steps.rb
features/step_definitions/dashboard_steps.rb
+15
-0
spec/models/event_spec.rb
spec/models/event_spec.rb
+11
-0
spec/observers/users_project_observer_spec.rb
spec/observers/users_project_observer_spec.rb
+8
-0
No files found.
app/assets/stylesheets/common.scss
View file @
a86bd87a
...
...
@@ -179,6 +179,14 @@ span.update-author {
&
.merged
{
background-color
:
#2A2
;
}
&
.joined
{
background-color
:
#1cb9ff
;
}
&
.left
{
background-color
:
#ff5057
;
}
}
form
{
...
...
app/decorators/event_decorator.rb
View file @
a86bd87a
...
...
@@ -8,7 +8,10 @@ class EventDecorator < ApplicationDecorator
"
#{
self
.
author_name
}
#{
self
.
action_name
}
MR #
#{
self
.
target_id
}
:"
+
self
.
merge_request_title
elsif
self
.
push?
"
#{
self
.
author_name
}
#{
self
.
push_action_name
}
#{
self
.
ref_type
}
"
+
self
.
ref_name
else
elsif
self
.
joined?
"
#{
self
.
author_name
}
#{
self
.
action_name
}
#{
self
.
project
.
name
}
"
else
""
end
end
...
...
app/models/event.rb
View file @
a86bd87a
...
...
@@ -10,6 +10,7 @@ class Event < ActiveRecord::Base
Pushed
=
5
Commented
=
6
Merged
=
7
Joined
=
8
# User joined project
belongs_to
:project
belongs_to
:target
,
polymorphic:
true
...
...
@@ -37,7 +38,7 @@ class Event < ActiveRecord::Base
# - new issue
# - merge request
def
allowed?
push?
||
issue?
||
merge_request?
push?
||
issue?
||
merge_request?
||
joined?
end
def
push?
...
...
@@ -84,6 +85,10 @@ class Event < ActiveRecord::Base
[
Closed
,
Reopened
].
include?
(
action
)
end
def
joined?
action
==
self
.
class
::
Joined
end
def
issue
target
if
target_type
==
"Issue"
end
...
...
@@ -101,6 +106,8 @@ class Event < ActiveRecord::Base
"closed"
elsif
merged?
"merged"
elsif
joined?
'joined'
else
"opened"
end
...
...
app/observers/users_project_observer.rb
View file @
a86bd87a
class
UsersProjectObserver
<
ActiveRecord
::
Observer
def
after_create
(
users_project
)
Notify
.
project_access_granted_email
(
users_project
.
id
).
deliver
Event
.
create
(
project_id:
users_project
.
project
.
id
,
action:
Event
::
Joined
,
author_id:
users_project
.
user
.
id
)
end
def
after_update
(
users_project
)
...
...
app/views/events/_event.html.haml
View file @
a86bd87a
...
...
@@ -11,3 +11,7 @@
.event_feed
=
render
"events/event_push"
,
event:
event
-
elsif
event
.
joined?
.event_feed
=
render
"events/event_joined"
,
event:
event
app/views/events/_event_joined.html.haml
0 → 100644
View file @
a86bd87a
=
image_tag
gravatar_icon
(
event
.
author_email
),
class:
"avatar"
%strong
#{
event
.
author_name
}
%span
.event_label
{
class:
event
.
action_name
}=
event
.
action_name
%strong
=
link_to
event
.
project
.
name
,
event
.
project
%span
.cgray
=
time_ago_in_words
(
event
.
created_at
)
ago.
features/dashboard/dashboard.feature
View file @
a86bd87a
...
...
@@ -15,4 +15,9 @@ Feature: Dashboard
And
I click
"Create Merge Request"
link
Then
I see prefilled new Merge Request page
@current
Scenario
:
I
should see User joined Project event
Given
user with name
"John Doe"
joined project
"Shop"
When
I visit dashboard page
Then
I should see
"John Doe joined Shop"
event
features/step_definitions/dashboard_steps.rb
View file @
a86bd87a
...
...
@@ -109,3 +109,18 @@ Given /^I have authored merge requests$/ do
:author
=>
@user
,
:project
=>
project2
end
Given
/^user with name "(.*?)" joined project "(.*?)"$/
do
|
user_name
,
project_name
|
user
=
Factory
.
create
(
:user
,
{
name:
user_name
})
project
=
Project
.
find_by_name
project_name
Event
.
create
(
project:
project
,
author_id:
user
.
id
,
action:
Event
::
Joined
)
end
Then
/^I should see "(.*?)" event$/
do
|
event_text
|
page
.
should
have_content
(
event_text
)
end
spec/models/event_spec.rb
View file @
a86bd87a
...
...
@@ -49,4 +49,15 @@ describe Event do
it
{
@event
.
branch_name
.
should
==
"master"
}
it
{
@event
.
author
.
should
==
@user
}
end
describe
"New team mamber"
do
let
(
:project
)
{
Factory
.
create
:project
}
let
(
:new_user
)
{
Factory
.
create
:user
}
it
"should create event"
do
UsersProject
.
observers
.
enable
:users_project_observer
expect
{
UsersProject
.
bulk_import
(
project
,
[
new_user
.
id
],
UsersProject
::
DEVELOPER
)
}.
to
change
{
Event
.
count
}.
by
(
1
)
end
end
end
spec/observers/users_project_observer_spec.rb
View file @
a86bd87a
...
...
@@ -23,6 +23,14 @@ describe UsersProjectObserver do
Notify
.
should_receive
(
:project_access_granted_email
).
with
(
users_project
.
id
).
and_return
(
double
(
deliver:
true
))
subject
.
after_create
(
users_project
)
end
it
"should create new event"
do
Event
.
should_receive
(
:create
).
with
(
project_id:
users_project
.
project
.
id
,
action:
Event
::
Joined
,
author_id:
users_project
.
user
.
id
)
subject
.
after_create
(
users_project
)
end
end
describe
"#after_update"
do
...
...
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