Skip to content

Commit

Permalink
comments and test
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesndrs committed Dec 20, 2024
1 parent 901b037 commit f6ccfb0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/material.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions test/controllers/content_providers_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f6ccfb0

Please sign in to comment.