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
e0177d23
Commit
e0177d23
authored
Jan 10, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SentryIssuesFinder and spec
parent
2e7d4521
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
0 deletions
+72
-0
app/finders/sentry_issues_finder.rb
app/finders/sentry_issues_finder.rb
+18
-0
spec/finders/sentry_issues_finder_spec.rb
spec/finders/sentry_issues_finder_spec.rb
+54
-0
No files found.
app/finders/sentry_issues_finder.rb
0 → 100644
View file @
e0177d23
# frozen_string_literal: true
class
SentryIssuesFinder
def
initialize
(
project
,
current_user
=
nil
)
@project
=
project
@current_user
=
current_user
end
def
find_by_identifier
(
identifier
)
return
unless
Ability
.
allowed?
(
@current_user
,
:read_sentry_issue
,
@project
)
sentry_issue
=
SentryIssue
.
for_identifier
(
identifier
).
first
return
unless
sentry_issue
&&
sentry_issue
.
issue
.
project
==
@project
sentry_issue
end
end
spec/finders/sentry_issues_finder_spec.rb
0 → 100644
View file @
e0177d23
# frozen_string_literal: true
require
'spec_helper'
describe
SentryIssuesFinder
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:sentry_issue
)
{
create
(
:sentry_issue
,
issue:
issue
)
}
let
(
:finder
)
{
described_class
.
new
(
project
,
user
)
}
describe
'#find_by_identifier'
do
let
(
:identifier
)
{
sentry_issue
.
sentry_issue_identifier
}
subject
{
finder
.
find_by_identifier
(
identifier
)
}
context
'when the user is not part of the project'
do
it
'returns no sentry issues'
do
is_expected
.
to
eq
(
nil
)
end
end
context
'when the user is a project developer'
do
before
do
project
.
add_developer
(
user
)
end
it
'returns the matching sentry issue'
do
expect
(
subject
).
to
eq
(
sentry_issue
)
end
context
'when identifier is incorrect is false'
do
let
(
:identifier
)
{
1234
}
it
'does not return a sentry issue'
do
expect
(
subject
).
to
eq
(
nil
)
end
end
context
'when accessing another projects identifier'
do
let
(
:second_project
)
{
create
(
:project
)
}
let
(
:second_issue
)
{
create
(
:issue
,
project:
second_project
)
}
let
(
:second_sentry_issue
)
{
create
(
:sentry_issue
,
issue:
second_issue
)
}
let
(
:identifier
)
{
second_sentry_issue
.
sentry_issue_identifier
}
it
'does not return a sentry issue'
do
expect
(
subject
).
to
eq
(
nil
)
end
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