diff --git a/app/models/material.rb b/app/models/material.rb index b88055a00..31382f26e 100644 --- a/app/models/material.rb +++ b/app/models/material.rb @@ -143,11 +143,11 @@ def self.facet_fields end def self.not_disabled - where('materials.visible is true') + where(visible: true) end def self.disabled - where('materials.visible is false') + where(visible: false) end def self.check_exists(material_params) diff --git a/test/controllers/content_providers_controller_test.rb b/test/controllers/content_providers_controller_test.rb index 1f897abef..c46ff2a19 100644 --- a/test/controllers/content_providers_controller_test.rb +++ b/test/controllers/content_providers_controller_test.rb @@ -582,4 +582,18 @@ class ContentProvidersControllerTest < ActionController::TestCase get :show, params: { id: content_provider } assert_response :forbidden end + + test 'should hide disabled materials on content provider page' do + new_material = Material.create!(title: 'my_material', description: 'visible material', url: 'http://new.url.com', content_provider: @content_provider, user: @content_provider.user) + get :show, params: { id: @content_provider } + assert_response :success + assert_select '.search-results-count.my-3', text: 'Showing 10 materials' + assert_select '.masonry-brick-heading h4', text: 'my_material' + new_material.visible = false + new_material.save! + get :show, params: { id: @content_provider } + assert_response :success + assert_select '.search-results-count.my-3', text: 'Showing 9 materials' + assert_select '.masonry-brick-heading h4', text: 'my_material', count: 0 + end end