mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Fix suggestions test being off by one sometimes
Delete the leftover Site model in an unrelated test to fix the race condition
This commit is contained in:
parent
beafd2daf8
commit
e901f599c2
1 changed files with 28 additions and 19 deletions
|
@ -64,36 +64,45 @@ describe 'site page' do
|
|||
end
|
||||
|
||||
|
||||
it 'allows site blocking and unblocking' do
|
||||
tag = SecureRandom.hex 10
|
||||
blocked_site = Fabricate :site, new_tags_string: tag, created_at: 2.weeks.ago, site_changed: true, views: Site::BROWSE_MINIMUM_FOLLOWER_VIEWS+1
|
||||
site = Fabricate :site
|
||||
describe 'blocking' do
|
||||
before do
|
||||
@tag = SecureRandom.hex 10
|
||||
@blocked_site = Fabricate :site, new_tags_string: @tag, created_at: 2.weeks.ago, site_changed: true, views: Site::BROWSE_MINIMUM_FOLLOWER_VIEWS+1
|
||||
end
|
||||
|
||||
page.set_rack_session id: site.id
|
||||
after do
|
||||
@blocked_site.destroy
|
||||
end
|
||||
|
||||
visit "/browse?tag=#{tag}"
|
||||
it 'allows site blocking and unblocking' do
|
||||
site = Fabricate :site
|
||||
|
||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{blocked_site.username}/
|
||||
page.set_rack_session id: site.id
|
||||
|
||||
visit "/site/#{blocked_site.username}"
|
||||
visit "/browse?tag=#{@tag}"
|
||||
|
||||
click_link 'Block'
|
||||
click_button 'Block Site'
|
||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{@blocked_site.username}/
|
||||
|
||||
visit "/browse?tag=#{tag}"
|
||||
visit "/site/#{@blocked_site.username}"
|
||||
|
||||
_(page).must_have_content /no active sites found/i
|
||||
click_link 'Block'
|
||||
click_button 'Block Site'
|
||||
|
||||
site.reload
|
||||
_(site.blockings.length).must_equal 1
|
||||
_(site.blockings.first.site_id).must_equal blocked_site.id
|
||||
visit "/browse?tag=#{@tag}"
|
||||
|
||||
visit "/site/#{blocked_site.username}"
|
||||
_(page).must_have_content /no active sites found/i
|
||||
|
||||
click_link 'Unblock'
|
||||
site.reload
|
||||
_(site.blockings.length).must_equal 1
|
||||
_(site.blockings.first.site_id).must_equal @blocked_site.id
|
||||
|
||||
visit "/browse?tag=#{tag}"
|
||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{blocked_site.username}/
|
||||
visit "/site/#{@blocked_site.username}"
|
||||
|
||||
click_link 'Unblock'
|
||||
|
||||
visit "/browse?tag=#{@tag}"
|
||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{@blocked_site.username}/
|
||||
end
|
||||
end
|
||||
|
||||
it '404s if site is banned' do
|
||||
|
|
Loading…
Add table
Reference in a new issue