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
Kazuhiko Shiozaki
gitlab-ce
Commits
9e3094b2
Commit
9e3094b2
authored
Jun 17, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove UsersGroup observer
parent
b3a90aba
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
42 deletions
+45
-42
app/models/users_group.rb
app/models/users_group.rb
+17
-0
app/observers/users_group_observer.rb
app/observers/users_group_observer.rb
+0
-9
config/application.rb
config/application.rb
+0
-1
spec/models/users_group_spec.rb
spec/models/users_group_spec.rb
+28
-0
spec/observers/users_group_observer_spec.rb
spec/observers/users_group_observer_spec.rb
+0
-32
No files found.
app/models/users_group.rb
View file @
9e3094b2
...
@@ -33,6 +33,9 @@ class UsersGroup < ActiveRecord::Base
...
@@ -33,6 +33,9 @@ class UsersGroup < ActiveRecord::Base
scope
:with_group
,
->
(
group
)
{
where
(
group_id:
group
.
id
)
}
scope
:with_group
,
->
(
group
)
{
where
(
group_id:
group
.
id
)
}
scope
:with_user
,
->
(
user
)
{
where
(
user_id:
user
.
id
)
}
scope
:with_user
,
->
(
user
)
{
where
(
user_id:
user
.
id
)
}
after_create
:notify_create
after_update
:notify_update
validates
:group_access
,
inclusion:
{
in:
UsersGroup
.
group_access_roles
.
values
},
presence:
true
validates
:group_access
,
inclusion:
{
in:
UsersGroup
.
group_access_roles
.
values
},
presence:
true
validates
:user_id
,
presence:
true
validates
:user_id
,
presence:
true
validates
:group_id
,
presence:
true
validates
:group_id
,
presence:
true
...
@@ -43,4 +46,18 @@ class UsersGroup < ActiveRecord::Base
...
@@ -43,4 +46,18 @@ class UsersGroup < ActiveRecord::Base
def
access_field
def
access_field
group_access
group_access
end
end
def
notify_create
notification_service
.
new_group_member
(
self
)
end
def
notify_update
if
group_access_changed?
notification_service
.
update_group_member
(
self
)
end
end
def
notification_service
NotificationService
.
new
end
end
end
app/observers/users_group_observer.rb
deleted
100644 → 0
View file @
b3a90aba
class
UsersGroupObserver
<
BaseObserver
def
after_create
(
membership
)
notification
.
new_group_member
(
membership
)
end
def
after_update
(
membership
)
notification
.
update_group_member
(
membership
)
if
membership
.
group_access_changed?
end
end
config/application.rb
View file @
9e3094b2
...
@@ -23,7 +23,6 @@ module Gitlab
...
@@ -23,7 +23,6 @@ module Gitlab
:project_observer
,
:project_observer
,
:system_hook_observer
,
:system_hook_observer
,
:user_observer
,
:user_observer
,
:users_group_observer
,
:users_project_observer
:users_project_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
...
...
spec/models/users_group_spec.rb
View file @
9e3094b2
...
@@ -37,4 +37,32 @@ describe UsersGroup do
...
@@ -37,4 +37,32 @@ describe UsersGroup do
it
{
should
respond_to
(
:user_name
)
}
it
{
should
respond_to
(
:user_name
)
}
it
{
should
respond_to
(
:user_email
)
}
it
{
should
respond_to
(
:user_email
)
}
end
end
context
'notification'
do
describe
"#after_create"
do
it
"should send email to user"
do
membership
=
build
(
:users_group
)
membership
.
stub
(
notification_service:
double
(
'NotificationService'
).
as_null_object
)
membership
.
should_receive
(
:notification_service
)
membership
.
save
end
end
describe
"#after_update"
do
before
do
@membership
=
create
:users_group
@membership
.
stub
(
notification_service:
double
(
'NotificationService'
).
as_null_object
)
end
it
"should send email to user"
do
@membership
.
should_receive
(
:notification_service
)
@membership
.
update_attribute
(
:group_access
,
UsersGroup
::
MASTER
)
end
it
"does not send an email when the access level has not changed"
do
@membership
.
should_not_receive
(
:notification_service
)
@membership
.
update_attribute
(
:group_access
,
UsersGroup
::
OWNER
)
end
end
end
end
end
spec/observers/users_group_observer_spec.rb
deleted
100644 → 0
View file @
b3a90aba
require
'spec_helper'
describe
UsersGroupObserver
do
before
(
:each
)
{
enable_observers
}
after
(
:each
)
{
disable_observers
}
subject
{
UsersGroupObserver
.
instance
}
before
{
subject
.
stub
(
notification:
double
(
'NotificationService'
).
as_null_object
)
}
describe
"#after_create"
do
it
"should send email to user"
do
subject
.
should_receive
(
:notification
)
create
(
:users_group
)
end
end
describe
"#after_update"
do
before
do
@membership
=
create
:users_group
end
it
"should send email to user"
do
subject
.
should_receive
(
:notification
)
@membership
.
update_attribute
(
:group_access
,
UsersGroup
::
MASTER
)
end
it
"does not send an email when the access level has not changed"
do
subject
.
should_not_receive
(
:notification
)
@membership
.
update_attribute
(
:group_access
,
UsersGroup
::
OWNER
)
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