mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
after do
|
||||||
|
@blocked_site.destroy
|
||||||
|
end
|
||||||
|
|
||||||
it 'allows site blocking and unblocking' do
|
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
|
site = Fabricate :site
|
||||||
|
|
||||||
page.set_rack_session id: site.id
|
page.set_rack_session id: site.id
|
||||||
|
|
||||||
visit "/browse?tag=#{tag}"
|
visit "/browse?tag=#{@tag}"
|
||||||
|
|
||||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{blocked_site.username}/
|
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{@blocked_site.username}/
|
||||||
|
|
||||||
visit "/site/#{blocked_site.username}"
|
visit "/site/#{@blocked_site.username}"
|
||||||
|
|
||||||
click_link 'Block'
|
click_link 'Block'
|
||||||
click_button 'Block Site'
|
click_button 'Block Site'
|
||||||
|
|
||||||
visit "/browse?tag=#{tag}"
|
visit "/browse?tag=#{@tag}"
|
||||||
|
|
||||||
_(page).must_have_content /no active sites found/i
|
_(page).must_have_content /no active sites found/i
|
||||||
|
|
||||||
site.reload
|
site.reload
|
||||||
_(site.blockings.length).must_equal 1
|
_(site.blockings.length).must_equal 1
|
||||||
_(site.blockings.first.site_id).must_equal blocked_site.id
|
_(site.blockings.first.site_id).must_equal @blocked_site.id
|
||||||
|
|
||||||
visit "/site/#{blocked_site.username}"
|
visit "/site/#{@blocked_site.username}"
|
||||||
|
|
||||||
click_link 'Unblock'
|
click_link 'Unblock'
|
||||||
|
|
||||||
visit "/browse?tag=#{tag}"
|
visit "/browse?tag=#{@tag}"
|
||||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{blocked_site.username}/
|
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{@blocked_site.username}/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it '404s if site is banned' do
|
it '404s if site is banned' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue