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
bc54c517
Commit
bc54c517
authored
Oct 12, 2021
by
Axel García
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix false positive on OneTrust helper specs
It also moves the logic from the AuthHelper to its own helper.
parent
2075d6fe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
46 deletions
+58
-46
app/helpers/auth_helper.rb
app/helpers/auth_helper.rb
+0
-7
app/helpers/one_trust_helper.rb
app/helpers/one_trust_helper.rb
+10
-0
spec/helpers/auth_helper_spec.rb
spec/helpers/auth_helper_spec.rb
+0
-39
spec/helpers/one_trust_helper_spec.rb
spec/helpers/one_trust_helper_spec.rb
+48
-0
No files found.
app/helpers/auth_helper.rb
View file @
bc54c517
...
...
@@ -169,13 +169,6 @@ module AuthHelper
!
current_user
end
def
one_trust_enabled?
Feature
.
enabled?
(
:ecomm_instrumentation
,
nil
,
type: :ops
)
&&
extra_config
.
has_key?
(
'one_trust_id'
)
&&
extra_config
.
one_trust_id
.
present?
&&
!
current_user
end
def
auth_app_owner_text
(
owner
)
return
unless
owner
...
...
app/helpers/one_trust_helper.rb
0 → 100644
View file @
bc54c517
# frozen_string_literal: true
module
OneTrustHelper
def
one_trust_enabled?
Feature
.
enabled?
(
:ecomm_instrumentation
,
type: :ops
)
&&
Gitlab
.
config
.
extra
.
has_key?
(
'one_trust_id'
)
&&
Gitlab
.
config
.
extra
.
one_trust_id
.
present?
&&
!
current_user
end
end
spec/helpers/auth_helper_spec.rb
View file @
bc54c517
...
...
@@ -314,45 +314,6 @@ RSpec.describe AuthHelper do
end
end
describe
'#one_trust_enabled?'
do
let
(
:user
)
{
nil
}
before
do
stub_config
(
extra:
{
one_trust_id:
'key'
})
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
subject
(
:one_trust_enabled?
)
{
helper
.
one_trust_enabled?
}
context
'with ecomm_instrumentation feature flag enabled'
do
before
do
stub_feature_flags
(
ecomm_instrumentation:
true
)
end
context
'when current user is set'
do
let
(
:user
)
{
instance_double
(
'User'
)
}
it
{
is_expected
.
to
be_falsey
}
end
context
'when no id is set'
do
before
do
stub_config
(
extra:
{})
end
it
{
is_expected
.
to
be_falsey
}
end
context
'when id is set and no user is set'
do
before
do
stub_config
(
extra:
{
one_trust_id:
'key'
})
end
it
{
is_expected
.
to
be_truthy
}
end
end
end
describe
'#auth_app_owner_text'
do
shared_examples
'generates text with the correct info'
do
it
'includes the name of the application owner'
do
...
...
spec/helpers/one_trust_helper_spec.rb
0 → 100644
View file @
bc54c517
# frozen_string_literal: true
require
"spec_helper"
RSpec
.
describe
OneTrustHelper
do
describe
'#one_trust_enabled?'
do
let
(
:user
)
{
nil
}
before
do
stub_config
(
extra:
{
one_trust_id:
'id'
})
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
subject
(
:one_trust_enabled?
)
{
helper
.
one_trust_enabled?
}
context
'with ecomm_instrumentation feature flag disabled'
do
before
do
stub_feature_flags
(
ecomm_instrumentation:
false
)
end
context
'when id is set and no user is set'
do
let
(
:user
)
{
instance_double
(
'User'
)
}
it
{
is_expected
.
to
be_falsey
}
end
end
context
'with ecomm_instrumentation feature flag enabled'
do
context
'when current user is set'
do
let
(
:user
)
{
instance_double
(
'User'
)
}
it
{
is_expected
.
to
be_falsey
}
end
context
'when no id is set'
do
before
do
stub_config
(
extra:
{})
end
it
{
is_expected
.
to
be_falsey
}
end
context
'when id is set and no user is set'
do
it
{
is_expected
.
to
be_truthy
}
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