Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/static_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def set_featured_trainer
trainers = Trainer.joins(:user).order(:id)
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'))
end

def set_content_providers
Expand Down
2 changes: 1 addition & 1 deletion config/tess.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ default: &default
promo_blocks: false
upcoming_events: # Number of events on home page. Leave blank to turn off
latest_materials: # Number of materials on home page. Leave blank to turn off
featured_trainer: false
featured_trainer: # Number of trainers to feature on home page. Leave blank to turn off
counters: false # Whether or not to show number of database objects in separate blocks
search_box: true # Whether or not to show the search box
additional_links: # Add custom links in separate blocks
Expand Down
13 changes: 11 additions & 2 deletions test/controllers/static_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,20 @@ class StaticControllerTest < ActionController::TestCase
end

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
end

test 'should not show featured trainer' do
with_settings({ site: { home_page: { featured_trainer: nil } } }) do
get :home
assert_select 'section#featured_trainer', count: 0
assert_select 'section#featured_trainer h2', count: 0
assert_select 'section#featured_trainer li', count: 0
end
end

Expand Down