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$/
|
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?
|
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
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,8 +68,13 @@ post '/create' do
|
||||||
ga_adgroupid: session[:ga_adgroupid]
|
ga_adgroupid: session[:ga_adgroupid]
|
||||||
)
|
)
|
||||||
|
|
||||||
if education_whitelisted?
|
if education_whitelist_required?
|
||||||
@site.email_confirmed = true
|
if education_whitelisted?
|
||||||
|
@site.email_confirmed = true
|
||||||
|
else
|
||||||
|
flash[:error] = 'The class tag is invalid.'
|
||||||
|
return {result: 'error'}.to_json
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if !hcaptcha_valid?
|
if !hcaptcha_valid?
|
||||||
flash[:error] = 'The captcha was not valid, please try again.'
|
flash[:error] = 'The captcha was not valid, please try again.'
|
||||||
|
|
|
@ -64,36 +64,45 @@ describe 'site page' do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'allows site blocking and unblocking' do
|
describe 'blocking' do
|
||||||
tag = SecureRandom.hex 10
|
before do
|
||||||
blocked_site = Fabricate :site, new_tags_string: tag, created_at: 2.weeks.ago, site_changed: true, views: Site::BROWSE_MINIMUM_FOLLOWER_VIEWS+1
|
@tag = SecureRandom.hex 10
|
||||||
site = Fabricate :site
|
@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'
|
_(page.find('.website-Gallery .username a')['href']).must_match /\/site\/#{@blocked_site.username}/
|
||||||
click_button 'Block Site'
|
|
||||||
|
|
||||||
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
|
visit "/browse?tag=#{@tag}"
|
||||||
_(site.blockings.length).must_equal 1
|
|
||||||
_(site.blockings.first.site_id).must_equal blocked_site.id
|
|
||||||
|
|
||||||
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}"
|
visit "/site/#{@blocked_site.username}"
|
||||||
_(page.find('.website-Gallery .username a')['href']).must_match /\/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
|
end
|
||||||
|
|
||||||
it '404s if site is banned' do
|
it '404s if site is banned' do
|
||||||
|
|
|
@ -4,7 +4,28 @@ DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
. /vagrant/vagrant/redis.sh
|
. /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
|
sed -i 's|[#]*DetectPUA false|DetectPUA true|g' /etc/clamav/clamd.conf
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue