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
e9c06d39
Commit
e9c06d39
authored
Jan 11, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use class method instead of scope
- Refactor specs a bit too - Rename finder to be singular
parent
ff92f865
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
86 deletions
+4
-86
app/finders/sentry_issues_finder.rb
app/finders/sentry_issues_finder.rb
+0
-24
spec/finders/sentry_issues_finder_spec.rb
spec/finders/sentry_issues_finder_spec.rb
+0
-54
spec/models/sentry_issue_spec.rb
spec/models/sentry_issue_spec.rb
+4
-8
No files found.
app/finders/sentry_issues_finder.rb
deleted
100644 → 0
View file @
ff92f865
# 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
authorized?
sentry_issue
=
SentryIssue
.
for_identifier
(
identifier
).
first
return
unless
sentry_issue
&&
sentry_issue
.
issue
.
project
==
@project
sentry_issue
end
private
def
authorized?
Ability
.
allowed?
(
@current_user
,
:read_sentry_issue
,
@project
)
end
end
spec/finders/sentry_issues_finder_spec.rb
deleted
100644 → 0
View file @
ff92f865
# 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
spec/models/sentry_issue_spec.rb
View file @
e9c06d39
...
...
@@ -39,18 +39,14 @@ describe SentryIssue do
end
describe
'scopes'
do
describe
'
#
for_identifier'
do
let
(
:sentry_issue
)
{
create
(
:sentry_issue
)
}
describe
'for_identifier'
do
let
!
(
:sentry_issue
)
{
create
(
:sentry_issue
)
}
let
(
:identifier
)
{
sentry_issue
.
sentry_issue_identifier
}
before
do
# create second sentry_issue
create
(
:sentry_issue
)
end
let!
(
:second_sentry_issue
)
{
create
(
:sentry_issue
)
}
subject
{
described_class
.
for_identifier
(
identifier
)
}
it
{
is_expected
.
to
contain_exactly
(
sentry_issue
)
}
it
{
is_expected
.
to
eq
(
sentry_issue
)
}
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