-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix newly created user is not added into global-viewer group (#247)
* Fix newly created user is not added into global-viewer group despite having the appropriate ENV * add role_id validation for GroupUser and fix add_global_viewer_group spec for User model Co-authored-by: Beni Budiharto <[email protected]> Co-authored-by: Rayhan Gusty Alif <[email protected]> Co-authored-by: Beni Budiharto <[email protected]>
- Loading branch information
1 parent
a2d3cd6
commit 40c2f4c
Showing
2 changed files
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,13 @@ | |
require 'faker' | ||
|
||
RSpec.describe User, type: :model do | ||
if Figaro.env.global_viewer == "true" | ||
before(:each) do | ||
create(:group, name: Figaro.env.global_viewer_role) | ||
@role = create(:app_group_role) | ||
end | ||
end | ||
|
||
describe '#self.find_by_username_or_email' do | ||
before(:each) do | ||
@user = create(:user, username: 'test_user', email: '[email protected]') | ||
|
@@ -99,7 +106,7 @@ | |
let!(:app_group) { create(:app_group) } | ||
|
||
it 'should filter out unassociated app group' do | ||
app_groups = user.filter_accessible_app_groups(AppGroup.all) | ||
app_groups = user.filter_accessible_app_groups(AppGroup.all, roles: @role) | ||
expect(app_groups.exists?).to be false | ||
end | ||
|
||
|
@@ -173,7 +180,7 @@ | |
let!(:group) { create(:group) } | ||
|
||
it 'should filter out unassociated app group' do | ||
groups = user.filter_accessible_user_groups(Group.all) | ||
groups = user.filter_accessible_user_groups(Group.all, roles: @role) | ||
expect(groups.exists?).to be false | ||
end | ||
|
||
|