Skip to content

Commit

Permalink
renamed get_accessible_posts to accessible_posts_for (per @ArtOfCode-'…
Browse files Browse the repository at this point in the history
…s note) as 'get' prefix is not idiomatic
  • Loading branch information
Oaphi committed Jan 12, 2025
1 parent 71dc1af commit 6e75e63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/helpers/search_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module SearchHelper
# @param user [User] user to check
def get_accessible_posts(user)
def accessible_posts_for(user)
(user&.is_moderator || user&.is_admin ? Post : Post.undeleted)
.qa_only.list_includes
end

def search_posts
posts = get_accessible_posts(current_user)
posts = accessible_posts_for(current_user)
qualifiers = params_to_qualifiers
search_string = params[:search]

Expand Down
8 changes: 4 additions & 4 deletions test/helpers/search_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class SearchHelperTest < ActionView::TestCase
end
end

test 'get_accessible_posts should correctly check access' do
test 'accessible_posts_for should correctly check access' do
admin_user = users(:admin)
mod_user = users(:moderator)
standard_user = users(:standard_user)

admin_posts = get_accessible_posts(admin_user)
mod_posts = get_accessible_posts(mod_user)
user_posts = get_accessible_posts(standard_user)
admin_posts = accessible_posts_for(admin_user)
mod_posts = accessible_posts_for(mod_user)
user_posts = accessible_posts_for(standard_user)

can_admin_get_deleted_posts = admin_posts.any?(&:deleted)
can_mod_get_deleted_posts = mod_posts.any?(&:deleted)
Expand Down

0 comments on commit 6e75e63

Please sign in to comment.