Skip to content

Commit

Permalink
Merge pull request #2077 from biggianteye/sponsor-filter-tests
Browse files Browse the repository at this point in the history
Add tests for filtering by sponsor
  • Loading branch information
matyikriszta committed May 20, 2024
2 parents 75ebf83 + f6d7e05 commit 04b109f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/features/admin/sponsor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@
expect(page.all(:css, 'tbody tr', count: 1))
end

scenario 'can filter by sponsor' do
# Single workshop
Fabricate(:workshop_sponsor, sponsor: sponsor)
# Multiple works with the same sponsor and chapter
chapter = Fabricate(:chapter)
5.times do
Fabricate(:workshop_sponsor, sponsor: sponsor2, workshop: Fabricate(:workshop_no_sponsor, chapter: chapter))
end

visit admin_sponsors_path

expect(page).to have_content(sponsor.name)
expect(page).to have_content(sponsor2.name)

expect(page.all(:css, 'tbody tr', count: 2))

# Make sure both sponsors can be filtered by
[sponsor.name, sponsor2.name].each do |name|
fill_in 'sponsors_search[name]', with: name
click_on 'Filter'

expect(page.all(:css, 'tbody tr', count: 1))
end

# Invalid sponsor name should return no results
fill_in 'sponsors_search[name]', with: 'this-sponsor-does-not-exist'
click_on 'Filter'

expect(page.all(:css, 'tbody tr', count: 0))
expect(page).to have_content('No sponsors found')
end

scenario 'can clear filtering form' do
sponsored_workshop = Fabricate(:workshop_sponsor, sponsor: sponsor).workshop
hosted_workshop = Fabricate(:workshop_sponsor, sponsor: sponsor2, host: true).workshop
Expand Down

0 comments on commit 04b109f

Please sign in to comment.