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
a168ed0e
Commit
a168ed0e
authored
Apr 30, 2020
by
syasonik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for creating/destroy published incidents
parent
81465333
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
ee/app/models/status_page/published_incident.rb
ee/app/models/status_page/published_incident.rb
+9
-2
ee/spec/models/status_page/published_incident_spec.rb
ee/spec/models/status_page/published_incident_spec.rb
+38
-0
No files found.
ee/app/models/status_page/published_incident.rb
View file @
a168ed0e
# frozen_string_literal: true
module
StatusPage
# Corresponds to an issue which has been published to a
# status-page app's AWS bucket.
# Corresponds to an issue which has been published to the Status Page.
class
PublishedIncident
<
ApplicationRecord
self
.
table_name
=
"status_page_published_incidents"
belongs_to
:issue
,
inverse_of: :status_page_published_incident
validates
:issue
,
presence:
true
def
self
.
track
(
issue
)
safe_find_or_create_by
(
issue:
issue
)
end
def
self
.
untrack
(
issue
)
find_by
(
issue:
issue
)
&
.
destroy
end
end
end
ee/spec/models/status_page/published_incident_spec.rb
View file @
a168ed0e
...
...
@@ -10,4 +10,42 @@ describe StatusPage::PublishedIncident do
describe
'validation'
do
it
{
is_expected
.
to
validate_presence_of
(
:issue
)
}
end
describe
'.track'
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
subject
{
described_class
.
track
(
issue
)
}
it
{
is_expected
.
to
be_a
(
described_class
)
}
specify
{
expect
(
subject
.
issue
).
to
eq
issue
}
specify
{
expect
{
subject
}.
to
change
{
described_class
.
count
}.
by
(
1
)
}
context
'when the incident already exists'
do
before
do
create
(
:status_page_published_incident
,
issue:
issue
)
end
it
{
is_expected
.
to
be_a
(
described_class
)
}
specify
{
expect
(
subject
.
issue
).
to
eq
issue
}
specify
{
expect
{
subject
}.
not_to
change
{
described_class
.
count
}
}
end
end
describe
'.untrack'
do
let_it_be
(
:issue
)
{
create
(
:issue
)
}
subject
{
described_class
.
untrack
(
issue
)
}
context
'when the incident is not yet tracked'
do
specify
{
expect
{
subject
}.
not_to
change
{
described_class
.
count
}
}
end
context
'when the incident is already tracked'
do
before
do
create
(
:status_page_published_incident
,
issue:
issue
)
end
specify
{
expect
{
subject
}.
to
change
{
described_class
.
count
}.
by
(
-
1
)
}
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