Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EXPIRATION_DURATIONS constant in CustomFilter class #30088

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/models/custom_filter.rb
Expand Up @@ -28,6 +28,8 @@
account
).freeze

EXPIRATION_DURATIONS = [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].freeze

include Expireable
include Redisable

Expand All @@ -52,7 +54,7 @@
return @expires_in if defined?(@expires_in)
return nil if expires_at.nil?

[30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].find { |expires_in| expires_in.from_now >= expires_at }
EXPIRATION_DURATIONS.find { |expires_in| expires_in.from_now >= expires_at }

Check warning on line 57 in app/models/custom_filter.rb

View check run for this annotation

Codecov / codecov/patch

app/models/custom_filter.rb#L57

Added line #L57 was not covered by tests
end

def irreversible=(value)
Expand Down
2 changes: 1 addition & 1 deletion app/views/filters/_filter_fields.html.haml
Expand Up @@ -6,7 +6,7 @@
wrapper: :with_label
.fields-row__column.fields-row__column-6.fields-group
= f.input :expires_in,
collection: [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].map(&:to_i),
collection: CustomFilter::EXPIRATION_DURATIONS.map(&:to_i),
include_blank: I18n.t('invites.expires_in_prompt'),
label_method: ->(i) { I18n.t("invites.expires_in.#{i}") },
wrapper: :with_label
Expand Down