mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Merge pull request #448 from talklittle/fix-education-tests
Fix education tests
This commit is contained in:
commit
8867765c20
3 changed files with 63 additions and 23 deletions
|
@ -1,7 +1,12 @@
|
|||
CREATE_MATCH_REGEX = /^username$|^password$|^email$|^new_tags_string$|^is_education$/
|
||||
|
||||
def education_whitelist_required?
|
||||
return true if params[:is_education] == 'true' && $config['education_tag_whitelist']
|
||||
false
|
||||
end
|
||||
|
||||
def education_whitelisted?
|
||||
return true if params[:is_education] == 'true' && $config['education_tag_whitelist'] && !$config['education_tag_whitelist'].select {|t| params[:new_tags_string].match(t)}.empty?
|
||||
return true if education_whitelist_required? && !$config['education_tag_whitelist'].select {|t| params[:new_tags_string].match(t)}.empty?
|
||||
false
|
||||
end
|
||||
|
||||
|
@ -63,8 +68,13 @@ post '/create' do
|
|||
ga_adgroupid: session[:ga_adgroupid]
|
||||
)
|
||||
|
||||
if education_whitelist_required?
|
||||
if education_whitelisted?
|
||||
@site.email_confirmed = true
|
||||
else
|
||||
flash[:error] = 'The class tag is invalid.'
|
||||
return {result: 'error'}.to_json
|
||||
end
|
||||
else
|
||||
if !hcaptcha_valid?
|
||||
flash[:error] = 'The captcha was not valid, please try again.'
|
||||
|
|
|
@ -64,36 +64,45 @@ describe 'site page' do
|
|||
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
|
||||
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
|
||||
|
||||
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_button 'Block Site'
|
||||
|
||||
visit "/browse?tag=#{tag}"
|
||||
visit "/browse?tag=#{@tag}"
|
||||
|
||||
_(page).must_have_content /no active sites found/i
|
||||
|
||||
site.reload
|
||||
_(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'
|
||||
|
||||
visit "/browse?tag=#{tag}"
|
||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{blocked_site.username}/
|
||||
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
|
||||
|
|
|
@ -4,7 +4,28 @@ DEBIAN_FRONTEND=noninteractive
|
|||
|
||||
. /vagrant/vagrant/redis.sh
|
||||
|
||||
apt-get install -y git curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev libpq-dev libmagickwand-dev imagemagick libmagickwand-dev libmagic-dev file clamav-daemon
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
clamav-daemon \
|
||||
curl \
|
||||
file \
|
||||
git \
|
||||
imagemagick \
|
||||
libcurl4-openssl-dev \
|
||||
libffi-dev \
|
||||
libimlib2-dev \
|
||||
libmagic-dev \
|
||||
libmagickwand-dev \
|
||||
libpq-dev \
|
||||
libreadline-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libwebp-dev \
|
||||
libxml2-dev \
|
||||
libxslt1-dev \
|
||||
libyaml-dev \
|
||||
sqlite3 \
|
||||
zlib1g-dev
|
||||
|
||||
sed -i 's|[#]*DetectPUA false|DetectPUA true|g' /etc/clamav/clamd.conf
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue