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
c5944009
Commit
c5944009
authored
Jan 11, 2021
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for group member email
parent
ed3933a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
ee/app/models/ee/group_member.rb
ee/app/models/ee/group_member.rb
+6
-2
ee/spec/models/group_member_spec.rb
ee/spec/models/group_member_spec.rb
+32
-0
No files found.
ee/app/models/ee/group_member.rb
View file @
c5944009
...
@@ -113,6 +113,12 @@ module EE
...
@@ -113,6 +113,12 @@ module EE
def
post_create_hook
def
post_create_hook
super
super
if
provisioned_by_this_group?
run_after_commit_or_now
do
notification_service
.
new_group_member_with_confirmation
(
self
)
end
end
execute_hooks_for
(
:create
)
execute_hooks_for
(
:create
)
end
end
...
@@ -137,8 +143,6 @@ module EE
...
@@ -137,8 +143,6 @@ module EE
run_after_commit
do
run_after_commit
do
data
=
::
Gitlab
::
HookData
::
GroupMemberBuilder
.
new
(
self
).
build
(
event
)
data
=
::
Gitlab
::
HookData
::
GroupMemberBuilder
.
new
(
self
).
build
(
event
)
notification_service
.
new_group_member_with_confirmation
(
self
)
if
provisioned_by_this_group?
data
=
::
Gitlab
::
HookData
::
GroupMemberBuilder
.
new
(
self
).
build
(
:create
)
self
.
source
.
execute_hooks
(
data
,
:member_hooks
)
self
.
source
.
execute_hooks
(
data
,
:member_hooks
)
end
end
end
end
...
...
ee/spec/models/group_member_spec.rb
View file @
c5944009
...
@@ -345,6 +345,7 @@ RSpec.describe GroupMember do
...
@@ -345,6 +345,7 @@ RSpec.describe GroupMember do
end
end
end
end
<<<<<<<
HEAD
def
webhook_data
(
group_member
,
event
)
def
webhook_data
(
group_member
,
event
)
{
{
headers:
{
'Content-Type'
=>
'application/json'
,
'User-Agent'
=>
"GitLab/
#{
Gitlab
::
VERSION
}
"
,
'X-Gitlab-Event'
=>
'Member Hook'
},
headers:
{
'Content-Type'
=>
'application/json'
,
'User-Agent'
=>
"GitLab/
#{
Gitlab
::
VERSION
}
"
,
'X-Gitlab-Event'
=>
'Member Hook'
},
...
@@ -364,5 +365,36 @@ RSpec.describe GroupMember do
...
@@ -364,5 +365,36 @@ RSpec.describe GroupMember do
event_name:
event
event_name:
event
}.
to_json
}.
to_json
}
}
=======
context
'group member welcome email'
,
:sidekiq_inline
do
let_it_be
(
:group
)
{
create
(
:group_with_plan
,
plan: :gold_plan
)
}
let
(
:user
)
{
create
(
:user
)
}
context
'when user is provisioned by group'
do
before
do
user
.
user_detail
.
update!
(
provisioned_by_group_id:
group
.
id
)
end
it
'schedules the welcome email with confirmation'
do
expect_next_instance_of
(
NotificationService
)
do
|
notification
|
expect
(
notification
).
to
receive
(
:new_group_member_with_confirmation
)
expect
(
notification
).
not_to
receive
(
:new_group_member
)
end
group
.
add_developer
(
user
)
end
end
context
'when user is not provisioned by group'
do
it
'schedules plain welcome to the group email'
do
expect_next_instance_of
(
NotificationService
)
do
|
notification
|
expect
(
notification
).
to
receive
(
:new_group_member
)
expect
(
notification
).
not_to
receive
(
:new_group_member_with_confirmation
)
end
group
.
add_developer
(
user
)
end
end
>>>>>>>
456
bbd408c4
(
Add
specs
for
group
member
email
)
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