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
32d449d1
Commit
32d449d1
authored
Jan 08, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure group_users to return distinct users
Caused uniqueness constraint when inserting as users
parent
aaf1e00b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
ee/app/models/concerns/approval_rule_like.rb
ee/app/models/concerns/approval_rule_like.rb
+1
-1
ee/spec/models/concerns/approval_rule_like_spec.rb
ee/spec/models/concerns/approval_rule_like_spec.rb
+12
-0
No files found.
ee/app/models/concerns/approval_rule_like.rb
View file @
32d449d1
...
...
@@ -8,7 +8,7 @@ module ApprovalRuleLike
included
do
has_and_belongs_to_many
:users
has_and_belongs_to_many
:groups
,
class_name:
'Group'
,
join_table:
"
#{
self
.
table_name
}
_groups"
has_many
:group_users
,
through: :groups
,
source: :users
has_many
:group_users
,
->
{
distinct
},
through: :groups
,
source: :users
validates
:name
,
presence:
true
end
...
...
ee/spec/models/concerns/approval_rule_like_spec.rb
View file @
32d449d1
...
...
@@ -87,4 +87,16 @@ describe ApprovalRuleLike do
it_behaves_like
'approval rule like'
end
context
'.group_users'
do
subject
{
create
(
:approval_project_rule
)
}
it
'returns distinct users'
do
group1
.
add_guest
(
user1
)
group2
.
add_guest
(
user1
)
subject
.
groups
=
[
group1
,
group2
]
expect
(
subject
.
group_users
).
to
eq
([
user1
])
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