Skip to content

Commit 84c77bc

Browse files
committed
renamed pinned link 'present' filter to 'current' to avoid confusion with built-in methods such as 'present?', 'presence', etc
1 parent 452d6e2 commit 84c77bc

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

app/controllers/pinned_links_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class PinnedLinksController < ApplicationController
44
before_action :verify_mod_on_current_community, only: [:edit, :update]
55

66
def index
7-
@period = params[:period].presence || 'present'
7+
@period = params[:period].presence || 'current'
88

99
@links = if current_user.at_least_global_moderator? && params[:global] == '2'
1010
PinnedLink.unscoped
@@ -17,8 +17,8 @@ def index
1717
@links = case @period
1818
when 'past'
1919
@links.past
20-
when 'present'
21-
@links.present
20+
when 'current'
21+
@links.current
2222
when 'future'
2323
@links.future
2424
else

app/models/pinned_link.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class PinnedLink < ApplicationRecord
1212
timed.where('shown_before < ?', DateTime.now)
1313
}
1414

15-
# a present link is not timed or started in the past and ends in the future
16-
scope :present, lambda {
15+
# a current link is not timed or started in the past and ends in the future
16+
scope :current, lambda {
1717
where(shown_after: nil, shown_before: nil).or(
1818
timed.where('shown_after <= ?', DateTime.now)
1919
.where('shown_before > ?', DateTime.now)

app/views/pinned_links/index.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
<%= link_to 'past',
3434
query_url(period: 'past'),
3535
class: "button is-muted is-outlined #{'is-active' if @period == 'past'}" %>
36-
<%= link_to 'present',
37-
query_url(period: 'present'),
38-
class: "button is-muted is-outlined #{'is-active' if @period == 'present'}" %>
36+
<%= link_to 'current',
37+
query_url(period: 'current'),
38+
class: "button is-muted is-outlined #{'is-active' if @period == 'current'}" %>
3939
<%= link_to 'future',
4040
query_url(period: 'future'),
4141
class: "button is-muted is-outlined #{'is-active' if @period == 'future'}" %>

test/controllers/pinned_links_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class PinnedLinksControllerTest < ActionController::TestCase
6161
assert link.timed? && link.shown_before < now
6262
end
6363

64-
get :index, params: { period: 'present' }
64+
get :index, params: { period: 'current' }
6565
@links = assigns(:links)
6666
assert_response(:success)
6767
assert @links.any?

test/models/pinned_link_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class PinnedLinkTest < ActiveSupport::TestCase
1111
end
1212
end
1313

14-
test ':present scope should return non-timed or current links' do
14+
test ':current scope should return non-timed or current links' do
1515
now = DateTime.now
16-
present = PinnedLink.present
16+
current = PinnedLink.current
1717

18-
assert present.any?
18+
assert current.any?
1919

20-
present.each do |link|
20+
current.each do |link|
2121
assert !link.timed? || (link.shown_before > now && link.shown_after <= now)
2222
end
2323
end

0 commit comments

Comments
 (0)