feat(featured_trainer): choose how many trainers to feature#1340
Open
kennethrioja wants to merge 1 commit into
Open
feat(featured_trainer): choose how many trainers to feature#1340kennethrioja wants to merge 1 commit into
kennethrioja wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds configurability for the “Featured trainer” section on the home page by interpreting the site.home_page.featured_trainer setting as a trainer count rather than a boolean toggle.
Changes:
- Update
StaticController#set_featured_trainerto sample a configurable number of trainers. - Update home page controller test expectations to reflect multiple featured trainers and add a “disabled” case.
- Update example config to document the new meaning of
featured_trainer(count; blank disables).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/controllers/static_controller.rb | Uses the configured featured_trainer value as the sample size when selecting featured trainers. |
| test/controllers/static_controller_test.rb | Adjusts assertions for multiple featured trainers and adds a “not shown when nil” case. |
| config/tess.example.yml | Documents featured_trainer as a numeric count with blank meaning disabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
39
to
+41
| f_trainers = trainers.where.not(users: { image_file_size: nil }) | ||
| trainers = f_trainers.exists? ? f_trainers : trainers | ||
| trainers.sample(1) | ||
| trainers.sample(TeSS::Config.site.dig('home_page', 'featured_trainer')) |
Comment on lines
314
to
+320
| test 'should show featured trainer' do | ||
| with_settings({ site: { home_page: { featured_trainer: true } } }) do | ||
| with_settings({ site: { home_page: { featured_trainer: 2 } } }) do | ||
| get :home | ||
| assert_select 'section#featured_trainer', count: 1 | ||
| assert_select 'section#featured_trainer h2', count: 1 | ||
| assert_select 'section#featured_trainer li', count: 1 | ||
| assert_select 'section#featured_trainer li', count: 2 | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Motivation and context
The value
1was hardcoded, I wanted moreScreenshots
N/A
Checklist