Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mastofe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Pleroma
mastofe
Commits
6f75c845
Commit
6f75c845
authored
7 years ago
by
Yamagishi Kazutoshi
Committed by
Eugen Rochko
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix subscription expiration condition (#2715)
* Fix subscription expiration condition * dry and add spec
parent
b9b78549
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/subscription.rb
+4
-0
4 additions, 0 deletions
app/models/subscription.rb
app/views/admin/pubsubhubbub/index.html.haml
+2
-3
2 additions, 3 deletions
app/views/admin/pubsubhubbub/index.html.haml
spec/models/subscription_spec.rb
+14
-0
14 additions, 0 deletions
spec/models/subscription_spec.rb
with
20 additions
and
3 deletions
app/models/subscription.rb
+
4
−
0
View file @
6f75c845
...
...
@@ -33,6 +33,10 @@ class Subscription < ApplicationRecord
(
expires_at
-
Time
.
now
.
utc
).
to_i
end
def
expired?
Time
.
now
.
utc
>
expires_at
end
before_validation
:set_min_expiration
private
...
...
This diff is collapsed.
Click to expand it.
app/views/admin/pubsubhubbub/index.html.haml
+
2
−
3
View file @
6f75c845
...
...
@@ -11,7 +11,6 @@
%th
=
t
(
'admin.pubsubhubbub.last_delivery'
)
%tbody
-
@subscriptions
.
each
do
|
subscription
|
-
expired
=
Time
.
now
.
utc
<
subscription
.
expires_at
%tr
%td
%samp
=
subscription
.
account
.
acct
...
...
@@ -20,8 +19,8 @@
%td
-
if
subscription
.
confirmed?
%i
.fa.fa-check
%td
{
style:
"color: #{expired ? 'red' : 'inherit'};"
}
=
precede
expired
?
'-'
:
''
do
%td
{
style:
"color: #{
subscription.
expired
?
? 'red' : 'inherit'};"
}
=
precede
subscription
.
expired
?
?
'-'
:
''
do
=
time_ago_in_words
(
subscription
.
expires_at
)
%td
-
if
subscription
.
last_successful_delivery_at?
...
...
This diff is collapsed.
Click to expand it.
spec/models/subscription_spec.rb
+
14
−
0
View file @
6f75c845
require
'rails_helper'
RSpec
.
describe
Subscription
,
type: :model
do
let
(
:alice
)
{
Fabricate
(
:account
,
username:
'alice'
)
}
subject
{
Fabricate
(
:subscription
,
account:
alice
)
}
describe
'#expired?'
do
it
'return true when expires_at is past'
do
subject
.
expires_at
=
2
.
days
.
ago
expect
(
subject
.
expired?
).
to
be
true
end
it
'return false when expires_at is future'
do
subject
.
expires_at
=
2
.
days
.
from_now
expect
(
subject
.
expired?
).
to
be
false
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment