mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
mostly finished port to ruby3
This commit is contained in:
parent
a9dd102383
commit
0ca1473d22
30 changed files with 765 additions and 731 deletions
15
Gemfile
15
Gemfile
|
@ -1,6 +1,6 @@
|
||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
gem 'sinatra', '2.0.5'
|
gem 'sinatra'
|
||||||
gem 'redis'
|
gem 'redis'
|
||||||
gem 'redis-namespace'
|
gem 'redis-namespace'
|
||||||
gem 'sequel'
|
gem 'sequel'
|
||||||
|
@ -11,9 +11,10 @@ gem 'puma', require: nil
|
||||||
gem 'rmagick', require: nil
|
gem 'rmagick', require: nil
|
||||||
gem 'sidekiq', '~> 5.2.0'
|
gem 'sidekiq', '~> 5.2.0'
|
||||||
gem 'mail'
|
gem 'mail'
|
||||||
|
gem 'net-smtp'
|
||||||
gem 'tilt'
|
gem 'tilt'
|
||||||
gem 'erubis'
|
gem 'erubis'
|
||||||
gem 'stripe', '~> 5.17.0' #, source: 'https://code.stripe.com/'
|
gem 'stripe' #, source: 'https://code.stripe.com/'
|
||||||
gem 'terrapin'
|
gem 'terrapin'
|
||||||
gem 'zipruby'
|
gem 'zipruby'
|
||||||
gem 'sass', require: nil
|
gem 'sass', require: nil
|
||||||
|
@ -26,7 +27,7 @@ gem 'addressable', '>= 2.8.0', require: 'addressable/uri'
|
||||||
gem 'paypal-recurring', require: 'paypal/recurring'
|
gem 'paypal-recurring', require: 'paypal/recurring'
|
||||||
gem 'geoip'
|
gem 'geoip'
|
||||||
gem 'io-extra', require: 'io/extra'
|
gem 'io-extra', require: 'io/extra'
|
||||||
gem 'rye'
|
#gem 'rye'
|
||||||
gem 'base32'
|
gem 'base32'
|
||||||
gem 'coveralls', require: false
|
gem 'coveralls', require: false
|
||||||
gem 'sanitize'
|
gem 'sanitize'
|
||||||
|
@ -53,11 +54,11 @@ gem 'activesupport'
|
||||||
gem 'facter', require: nil
|
gem 'facter', require: nil
|
||||||
gem 'maxmind-db'
|
gem 'maxmind-db'
|
||||||
gem 'json', '>= 2.3.0'
|
gem 'json', '>= 2.3.0'
|
||||||
gem 'nokogiri', '= 1.11.4'
|
gem 'nokogiri'
|
||||||
|
gem 'rss'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem 'pry'
|
gem 'pry'
|
||||||
gem 'pry-byebug'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
@ -75,8 +76,8 @@ group :test do
|
||||||
gem 'rake', '>= 12.3.3', require: nil
|
gem 'rake', '>= 12.3.3', require: nil
|
||||||
gem 'capybara', require: nil #, '2.10.1', require: nil
|
gem 'capybara', require: nil #, '2.10.1', require: nil
|
||||||
gem 'rack_session_access', require: nil
|
gem 'rack_session_access', require: nil
|
||||||
gem 'webmock', '3.5.1', require: nil
|
gem 'webmock', require: nil
|
||||||
gem 'stripe-ruby-mock', '2.5.8', require: 'stripe_mock'
|
gem 'stripe-ruby-mock', '~> 3.1.0.rc3', require: 'stripe_mock'
|
||||||
gem 'timecop'
|
gem 'timecop'
|
||||||
gem 'mock_redis'
|
gem 'mock_redis'
|
||||||
gem 'simplecov', require: nil
|
gem 'simplecov', require: nil
|
||||||
|
|
330
Gemfile.lock
330
Gemfile.lock
|
@ -22,23 +22,19 @@ GIT
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
acme-client (2.0.6)
|
acme-client (2.0.9)
|
||||||
faraday (>= 0.17, < 2.0.0)
|
faraday (>= 0.17, < 2.0.0)
|
||||||
activesupport (6.0.3.1)
|
activesupport (7.0.2.3)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 1.6, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (>= 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 2.0)
|
||||||
zeitwerk (~> 2.2, >= 2.2.2)
|
|
||||||
addressable (2.8.0)
|
addressable (2.8.0)
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
annoy (0.5.6)
|
|
||||||
highline (>= 1.5.0)
|
|
||||||
ansi (1.5.0)
|
ansi (1.5.0)
|
||||||
base32 (0.3.2)
|
base32 (0.3.4)
|
||||||
bcrypt (3.1.13)
|
bcrypt (3.1.17)
|
||||||
builder (3.2.3)
|
builder (3.2.4)
|
||||||
byebug (11.0.1)
|
|
||||||
capybara (3.36.0)
|
capybara (3.36.0)
|
||||||
addressable
|
addressable
|
||||||
matrix
|
matrix
|
||||||
|
@ -50,85 +46,114 @@ GEM
|
||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
certified (1.0.0)
|
certified (1.0.0)
|
||||||
climate_control (0.2.0)
|
climate_control (0.2.0)
|
||||||
coderay (1.1.2)
|
coderay (1.1.3)
|
||||||
concurrent-ruby (1.1.9)
|
concurrent-ruby (1.1.10)
|
||||||
connection_pool (2.2.5)
|
connection_pool (2.2.5)
|
||||||
coveralls (0.8.23)
|
coveralls (0.7.1)
|
||||||
json (>= 1.8, < 3)
|
multi_json (~> 1.3)
|
||||||
simplecov (~> 0.16.1)
|
rest-client
|
||||||
term-ansicolor (~> 1.3)
|
simplecov (>= 0.7)
|
||||||
thor (>= 0.19.4, < 2.0)
|
term-ansicolor
|
||||||
tins (~> 1.6)
|
thor
|
||||||
crack (0.4.3)
|
crack (0.4.5)
|
||||||
safe_yaml (~> 1.0.0)
|
rexml
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
dante (0.2.0)
|
dante (0.2.0)
|
||||||
docile (1.3.2)
|
digest (3.1.0)
|
||||||
|
docile (1.4.0)
|
||||||
domain_name (0.5.20190701)
|
domain_name (0.5.20190701)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
drydock (0.6.9)
|
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
exifr (1.3.6)
|
exifr (1.3.9)
|
||||||
fabrication (2.20.2)
|
fabrication (2.27.0)
|
||||||
facter (2.5.6)
|
facter (4.2.8)
|
||||||
faker (2.4.0)
|
hocon (~> 1.3)
|
||||||
i18n (~> 1.6.0)
|
thor (>= 1.0.1, < 2.0)
|
||||||
faraday (0.17.3)
|
faker (2.20.0)
|
||||||
|
i18n (>= 1.8.11, < 2)
|
||||||
|
faraday (1.10.0)
|
||||||
|
faraday-em_http (~> 1.0)
|
||||||
|
faraday-em_synchrony (~> 1.0)
|
||||||
|
faraday-excon (~> 1.1)
|
||||||
|
faraday-httpclient (~> 1.0)
|
||||||
|
faraday-multipart (~> 1.0)
|
||||||
|
faraday-net_http (~> 1.0)
|
||||||
|
faraday-net_http_persistent (~> 1.0)
|
||||||
|
faraday-patron (~> 1.0)
|
||||||
|
faraday-rack (~> 1.0)
|
||||||
|
faraday-retry (~> 1.0)
|
||||||
|
ruby2_keywords (>= 0.0.4)
|
||||||
|
faraday-em_http (1.0.0)
|
||||||
|
faraday-em_synchrony (1.0.0)
|
||||||
|
faraday-excon (1.1.0)
|
||||||
|
faraday-httpclient (1.0.1)
|
||||||
|
faraday-multipart (1.0.3)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
faraday_middleware (0.14.0)
|
faraday-net_http (1.0.1)
|
||||||
faraday (>= 0.7.4, < 1.0)
|
faraday-net_http_persistent (1.2.0)
|
||||||
|
faraday-patron (1.0.0)
|
||||||
|
faraday-rack (1.0.0)
|
||||||
|
faraday-retry (1.0.3)
|
||||||
|
faraday_middleware (1.2.0)
|
||||||
|
faraday (~> 1.0)
|
||||||
feedjira (2.1.4)
|
feedjira (2.1.4)
|
||||||
faraday (>= 0.9)
|
faraday (>= 0.9)
|
||||||
faraday_middleware (>= 0.9)
|
faraday_middleware (>= 0.9)
|
||||||
loofah (>= 2.0)
|
loofah (>= 2.0)
|
||||||
sax-machine (>= 1.0)
|
sax-machine (>= 1.0)
|
||||||
ffi (1.11.1)
|
ffi (1.15.5)
|
||||||
|
ffi-compiler (1.0.1)
|
||||||
|
ffi (>= 1.0.0)
|
||||||
|
rake
|
||||||
filesize (0.2.0)
|
filesize (0.2.0)
|
||||||
fspath (3.1.2)
|
fspath (3.1.2)
|
||||||
gandi (3.3.28)
|
gandi (3.3.28)
|
||||||
hashie
|
hashie
|
||||||
xmlrpc
|
xmlrpc
|
||||||
geoip (1.6.4)
|
geoip (1.6.4)
|
||||||
hashdiff (1.0.0)
|
hashdiff (1.0.1)
|
||||||
hashie (3.6.0)
|
hashie (5.0.0)
|
||||||
highline (2.0.2)
|
|
||||||
hiredis (0.6.3)
|
hiredis (0.6.3)
|
||||||
hoe (3.22.1)
|
hocon (1.3.1)
|
||||||
|
hoe (3.23.1)
|
||||||
rake (>= 0.8, < 15.0)
|
rake (>= 0.8, < 15.0)
|
||||||
htmlentities (4.3.4)
|
htmlentities (4.3.4)
|
||||||
http (4.1.1)
|
http (5.0.4)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.8)
|
||||||
http-cookie (~> 1.0)
|
http-cookie (~> 1.0)
|
||||||
http-form_data (~> 2.0)
|
http-form_data (~> 2.2)
|
||||||
http_parser.rb (~> 0.6.0)
|
llhttp-ffi (~> 0.4.0)
|
||||||
http-accept (1.7.0)
|
http-accept (1.7.0)
|
||||||
http-cookie (1.0.3)
|
http-cookie (1.0.4)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http-form_data (2.1.1)
|
http-form_data (2.3.0)
|
||||||
http_parser.rb (0.6.0)
|
i18n (1.10.0)
|
||||||
i18n (1.6.0)
|
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
image_optim (0.26.5)
|
image_optim (0.31.1)
|
||||||
exifr (~> 1.2, >= 1.2.2)
|
exifr (~> 1.2, >= 1.2.2)
|
||||||
fspath (~> 3.0)
|
fspath (~> 3.0)
|
||||||
image_size (>= 1.5, < 3)
|
image_size (>= 1.5, < 4)
|
||||||
in_threads (~> 1.3)
|
in_threads (~> 1.3)
|
||||||
progress (~> 3.0, >= 3.0.1)
|
progress (~> 3.0, >= 3.0.1)
|
||||||
image_optim_pack (0.6.0)
|
image_optim_pack (0.8.0.20220131)
|
||||||
fspath (>= 2.1, < 4)
|
fspath (>= 2.1, < 4)
|
||||||
image_optim (~> 0.19)
|
image_optim (~> 0.19)
|
||||||
image_optim_pack (0.6.0-x86_64-linux)
|
image_optim_pack (0.8.0.20220131-x86_64-linux)
|
||||||
fspath (>= 2.1, < 4)
|
fspath (>= 2.1, < 4)
|
||||||
image_optim (~> 0.19)
|
image_optim (~> 0.19)
|
||||||
image_size (2.0.2)
|
image_size (3.0.1)
|
||||||
in_threads (1.5.3)
|
in_threads (1.6.0)
|
||||||
io-extra (1.3.0)
|
io-extra (1.4.0)
|
||||||
|
io-wait (0.2.1)
|
||||||
ipaddress (0.8.3)
|
ipaddress (0.8.3)
|
||||||
json (2.3.1)
|
json (2.6.1)
|
||||||
loofah (2.5.0)
|
llhttp-ffi (0.4.0)
|
||||||
|
ffi-compiler (~> 1.0)
|
||||||
|
rake (~> 13.0)
|
||||||
|
loofah (2.15.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
m (1.5.1)
|
m (1.6.0)
|
||||||
method_source (>= 0.6.7)
|
method_source (>= 0.6.7)
|
||||||
rake (>= 0.9.2.2)
|
rake (>= 0.9.2.2)
|
||||||
magic (0.2.9)
|
magic (0.2.9)
|
||||||
|
@ -136,164 +161,159 @@ GEM
|
||||||
mail (2.7.1)
|
mail (2.7.1)
|
||||||
mini_mime (>= 0.1.1)
|
mini_mime (>= 0.1.1)
|
||||||
matrix (0.4.2)
|
matrix (0.4.2)
|
||||||
maxmind-db (1.0.0)
|
maxmind-db (1.1.1)
|
||||||
metaclass (0.0.4)
|
method_source (1.0.0)
|
||||||
method_source (0.9.2)
|
mime-types (3.4.1)
|
||||||
mime-types (3.3)
|
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2019.0904)
|
mime-types-data (3.2022.0105)
|
||||||
mini_mime (1.1.2)
|
mini_mime (1.1.2)
|
||||||
mini_portile2 (2.5.3)
|
mini_portile2 (2.8.0)
|
||||||
minitest (5.11.3)
|
minitest (5.15.0)
|
||||||
minitest-reporters (1.3.8)
|
minitest-reporters (1.5.0)
|
||||||
ansi
|
ansi
|
||||||
builder
|
builder
|
||||||
minitest (>= 5.0)
|
minitest (>= 5.0)
|
||||||
ruby-progressbar
|
ruby-progressbar
|
||||||
mocha (1.9.0)
|
mocha (1.13.0)
|
||||||
metaclass (~> 0.0.1)
|
mock_redis (0.30.0)
|
||||||
mock_redis (0.21.0)
|
ruby2_keywords
|
||||||
monetize (1.9.2)
|
monetize (1.12.0)
|
||||||
money (~> 6.12)
|
money (~> 6.12)
|
||||||
money (6.13.4)
|
money (6.16.0)
|
||||||
i18n (>= 0.6.4, <= 2)
|
i18n (>= 0.6.4, <= 2)
|
||||||
msgpack (1.3.1)
|
msgpack (1.4.5)
|
||||||
multi_json (1.13.1)
|
multi_json (1.15.0)
|
||||||
multipart-post (2.1.1)
|
multipart-post (2.1.1)
|
||||||
mustermann (1.0.3)
|
mustermann (1.1.1)
|
||||||
net-scp (2.0.0)
|
ruby2_keywords (~> 0.0.1)
|
||||||
net-ssh (>= 2.6.5, < 6.0.0)
|
net-protocol (0.1.2)
|
||||||
net-ssh (5.2.0)
|
io-wait
|
||||||
|
timeout
|
||||||
|
net-smtp (0.3.1)
|
||||||
|
digest
|
||||||
|
net-protocol
|
||||||
|
timeout
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nio4r (2.5.8)
|
nio4r (2.5.8)
|
||||||
nokogiri (1.11.4)
|
nokogiri (1.13.3)
|
||||||
mini_portile2 (~> 2.5.0)
|
mini_portile2 (~> 2.8.0)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.11.4-x86_64-linux)
|
nokogiri (1.13.3-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogumbo (2.0.2)
|
ox (2.14.10)
|
||||||
nokogiri (~> 1.8, >= 1.8.4)
|
|
||||||
ox (2.11.0)
|
|
||||||
paypal-recurring (1.1.0)
|
paypal-recurring (1.1.0)
|
||||||
pg (1.1.4)
|
pg (1.3.4)
|
||||||
progress (3.5.2)
|
progress (3.6.0)
|
||||||
pry (0.12.2)
|
pry (0.14.1)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1)
|
||||||
method_source (~> 0.9.0)
|
method_source (~> 1.0)
|
||||||
pry-byebug (3.7.0)
|
|
||||||
byebug (~> 11.0)
|
|
||||||
pry (~> 0.10)
|
|
||||||
public_suffix (4.0.6)
|
public_suffix (4.0.6)
|
||||||
puma (5.5.1)
|
puma (5.6.2)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
racc (1.6.0)
|
racc (1.6.0)
|
||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
rack-cache (1.9.0)
|
rack-cache (1.13.0)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
rack-protection (2.0.5)
|
rack-protection (2.2.0)
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rack_session_access (0.2.0)
|
rack_session_access (0.2.0)
|
||||||
builder (>= 2.0.0)
|
builder (>= 2.0.0)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rake (13.0.1)
|
rake (13.0.6)
|
||||||
rb-fsevent (0.10.3)
|
rb-fsevent (0.11.1)
|
||||||
rb-inotify (0.10.0)
|
rb-inotify (0.10.1)
|
||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
redis (3.3.5)
|
redis (4.5.1)
|
||||||
redis-namespace (1.6.0)
|
redis-namespace (1.8.2)
|
||||||
redis (>= 3.0.4)
|
redis (>= 3.0.4)
|
||||||
regexp_parser (2.1.1)
|
regexp_parser (2.2.1)
|
||||||
rest-client (2.1.0)
|
rest-client (2.1.0)
|
||||||
http-accept (>= 1.7.0, < 2.0)
|
http-accept (>= 1.7.0, < 2.0)
|
||||||
http-cookie (>= 1.0.2, < 2.0)
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
mime-types (>= 1.16, < 4.0)
|
mime-types (>= 1.16, < 4.0)
|
||||||
netrc (~> 0.8)
|
netrc (~> 0.8)
|
||||||
|
rexml (3.2.5)
|
||||||
rinku (2.0.6)
|
rinku (2.0.6)
|
||||||
rmagick (4.1.2)
|
rmagick (4.2.4)
|
||||||
ruby-progressbar (1.10.1)
|
rss (0.2.9)
|
||||||
rye (0.9.13)
|
rexml
|
||||||
annoy
|
ruby-progressbar (1.11.0)
|
||||||
docile (>= 1.0.1)
|
ruby2_keywords (0.0.5)
|
||||||
highline (>= 1.5.1)
|
sanitize (6.0.0)
|
||||||
net-scp (>= 1.0.2)
|
|
||||||
net-ssh (>= 2.0.13)
|
|
||||||
sysinfo (>= 0.8.1)
|
|
||||||
safe_yaml (1.0.5)
|
|
||||||
sanitize (5.2.1)
|
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.8.0)
|
nokogiri (>= 1.12.0)
|
||||||
nokogumbo (~> 2.0)
|
|
||||||
sass (3.7.4)
|
sass (3.7.4)
|
||||||
sass-listen (~> 4.0.0)
|
sass-listen (~> 4.0.0)
|
||||||
sass-listen (4.0.0)
|
sass-listen (4.0.0)
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||||
rb-inotify (~> 0.9, >= 0.9.7)
|
rb-inotify (~> 0.9, >= 0.9.7)
|
||||||
sax-machine (1.3.2)
|
sax-machine (1.3.2)
|
||||||
sequel (5.24.0)
|
sequel (5.54.0)
|
||||||
sequel_pg (1.12.2)
|
sequel_pg (1.15.0)
|
||||||
pg (>= 0.18.0)
|
pg (>= 0.18.0, != 1.2.0)
|
||||||
sequel (>= 4.38.0)
|
sequel (>= 4.38.0)
|
||||||
shotgun (0.9.2)
|
shotgun (0.9.2)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
sidekiq (5.2.0)
|
sidekiq (5.2.10)
|
||||||
connection_pool (~> 2.2, >= 2.2.2)
|
connection_pool (~> 2.2, >= 2.2.2)
|
||||||
rack-protection (>= 1.5.0)
|
|
||||||
redis (>= 3.3.5, < 5)
|
|
||||||
simplecov (0.16.1)
|
|
||||||
docile (~> 1.1)
|
|
||||||
json (>= 1.8, < 3)
|
|
||||||
simplecov-html (~> 0.10.0)
|
|
||||||
simplecov-html (0.10.2)
|
|
||||||
simpleidn (0.1.1)
|
|
||||||
unf (~> 0.1.4)
|
|
||||||
sinatra (2.0.5)
|
|
||||||
mustermann (~> 1.0)
|
|
||||||
rack (~> 2.0)
|
rack (~> 2.0)
|
||||||
rack-protection (= 2.0.5)
|
rack-protection (>= 1.5.0)
|
||||||
|
redis (~> 4.5, < 4.6.0)
|
||||||
|
simplecov (0.21.2)
|
||||||
|
docile (~> 1.1)
|
||||||
|
simplecov-html (~> 0.11)
|
||||||
|
simplecov_json_formatter (~> 0.1)
|
||||||
|
simplecov-html (0.12.3)
|
||||||
|
simplecov_json_formatter (0.1.4)
|
||||||
|
simpleidn (0.2.1)
|
||||||
|
unf (~> 0.1.4)
|
||||||
|
sinatra (2.2.0)
|
||||||
|
mustermann (~> 1.0)
|
||||||
|
rack (~> 2.2)
|
||||||
|
rack-protection (= 2.2.0)
|
||||||
tilt (~> 2.0)
|
tilt (~> 2.0)
|
||||||
sinatra-flash (0.3.0)
|
sinatra-flash (0.3.0)
|
||||||
sinatra (>= 1.0.0)
|
sinatra (>= 1.0.0)
|
||||||
sinatra-xsendfile (0.4.2)
|
sinatra-xsendfile (0.4.2)
|
||||||
sinatra (>= 0.9.1)
|
sinatra (>= 0.9.1)
|
||||||
storable (0.8.9)
|
stripe (5.46.0)
|
||||||
stripe (5.17.0)
|
stripe-ruby-mock (3.1.0.rc3)
|
||||||
stripe-ruby-mock (2.5.8)
|
|
||||||
dante (>= 0.2.0)
|
dante (>= 0.2.0)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
stripe (>= 2.0.3)
|
stripe (> 5, < 6)
|
||||||
sysinfo (0.8.1)
|
sync (0.5.0)
|
||||||
drydock
|
|
||||||
storable
|
|
||||||
term-ansicolor (1.7.1)
|
term-ansicolor (1.7.1)
|
||||||
tins (~> 1.0)
|
tins (~> 1.0)
|
||||||
terrapin (0.6.0)
|
terrapin (0.6.0)
|
||||||
climate_control (>= 0.0.3, < 1.0)
|
climate_control (>= 0.0.3, < 1.0)
|
||||||
thor (0.20.3)
|
thor (1.2.1)
|
||||||
thread (0.2.2)
|
thread (0.2.2)
|
||||||
thread_safe (0.3.6)
|
tilt (2.0.10)
|
||||||
tilt (2.0.9)
|
timecop (0.9.5)
|
||||||
timecop (0.9.1)
|
timeout (0.2.0)
|
||||||
tins (1.21.1)
|
tins (1.31.0)
|
||||||
tzinfo (1.2.7)
|
sync
|
||||||
thread_safe (~> 0.1)
|
tzinfo (2.0.4)
|
||||||
|
concurrent-ruby (~> 1.0)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.6)
|
unf_ext (0.0.8.1)
|
||||||
uuidtools (2.1.5)
|
uuidtools (2.1.5)
|
||||||
webmock (3.5.1)
|
webmock (3.14.0)
|
||||||
addressable (>= 2.3.6)
|
addressable (>= 2.8.0)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff
|
hashdiff (>= 0.4.0, < 2.0.0)
|
||||||
|
webrick (1.7.0)
|
||||||
websocket-driver (0.7.5)
|
websocket-driver (0.7.5)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.5)
|
websocket-extensions (0.1.5)
|
||||||
will_paginate (3.1.8)
|
will_paginate (3.3.1)
|
||||||
xmlrpc (0.3.0)
|
xmlrpc (0.3.2)
|
||||||
|
webrick
|
||||||
xpath (3.2.0)
|
xpath (3.2.0)
|
||||||
nokogiri (~> 1.8)
|
nokogiri (~> 1.8)
|
||||||
zeitwerk (2.3.0)
|
|
||||||
zipruby (0.3.6)
|
zipruby (0.3.6)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
|
@ -338,11 +358,11 @@ DEPENDENCIES
|
||||||
mock_redis
|
mock_redis
|
||||||
monetize
|
monetize
|
||||||
msgpack
|
msgpack
|
||||||
nokogiri (= 1.11.4)
|
net-smtp
|
||||||
|
nokogiri
|
||||||
paypal-recurring
|
paypal-recurring
|
||||||
pg
|
pg
|
||||||
pry
|
pry
|
||||||
pry-byebug
|
|
||||||
puma
|
puma
|
||||||
rack-cache
|
rack-cache
|
||||||
rack-test
|
rack-test
|
||||||
|
@ -353,7 +373,7 @@ DEPENDENCIES
|
||||||
rest-client
|
rest-client
|
||||||
rinku
|
rinku
|
||||||
rmagick
|
rmagick
|
||||||
rye
|
rss
|
||||||
sanitize
|
sanitize
|
||||||
sass
|
sass
|
||||||
sequel
|
sequel
|
||||||
|
@ -362,19 +382,19 @@ DEPENDENCIES
|
||||||
sidekiq (~> 5.2.0)
|
sidekiq (~> 5.2.0)
|
||||||
simplecov
|
simplecov
|
||||||
simpleidn
|
simpleidn
|
||||||
sinatra (= 2.0.5)
|
sinatra
|
||||||
sinatra-flash
|
sinatra-flash
|
||||||
sinatra-xsendfile
|
sinatra-xsendfile
|
||||||
stripe (~> 5.17.0)
|
stripe
|
||||||
stripe-ruby-mock (= 2.5.8)
|
stripe-ruby-mock (~> 3.1.0.rc3)
|
||||||
terrapin
|
terrapin
|
||||||
thread
|
thread
|
||||||
tilt
|
tilt
|
||||||
timecop
|
timecop
|
||||||
webmock (= 3.5.1)
|
webmock
|
||||||
will_paginate
|
will_paginate
|
||||||
xmlrpc
|
xmlrpc
|
||||||
zipruby
|
zipruby
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.1.4
|
2.3.10
|
||||||
|
|
|
@ -12,7 +12,14 @@ Bundler.require
|
||||||
Bundler.require :development if ENV['RACK_ENV'] == 'development'
|
Bundler.require :development if ENV['RACK_ENV'] == 'development'
|
||||||
|
|
||||||
require 'tilt/erubis'
|
require 'tilt/erubis'
|
||||||
require 'active_support/core_ext/integer/time'
|
require 'active_support'
|
||||||
|
require 'active_support/time'
|
||||||
|
|
||||||
|
class File
|
||||||
|
def self.exists?(val)
|
||||||
|
self.exist?(val)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Dir['./ext/**/*.rb'].each {|f| require f}
|
Dir['./ext/**/*.rb'].each {|f| require f}
|
||||||
|
|
||||||
|
@ -163,3 +170,5 @@ $gandi = Gandi::Session.new $config['gandi_api_key'], gandi_opts
|
||||||
$image_optim = ImageOptim.new pngout: false, svgo: false
|
$image_optim = ImageOptim.new pngout: false, svgo: false
|
||||||
|
|
||||||
Money.locale_backend = nil
|
Money.locale_backend = nil
|
||||||
|
Money.default_currency = Money::Currency.new("USD")
|
||||||
|
Money.rounding_mode = BigDecimal::ROUND_HALF_UP
|
||||||
|
|
|
@ -13,6 +13,7 @@ class Archive < Sequel::Model
|
||||||
end
|
end
|
||||||
|
|
||||||
def unpin
|
def unpin
|
||||||
|
return nil
|
||||||
# Not ideal. An SoA version is in progress.
|
# Not ideal. An SoA version is in progress.
|
||||||
if ENV['RACK_ENV'] == 'production' && $config['ipfs_ssh_host'] && $config['ipfs_ssh_user']
|
if ENV['RACK_ENV'] == 'production' && $config['ipfs_ssh_host'] && $config['ipfs_ssh_user']
|
||||||
rbox = Rye::Box.new $config['ipfs_ssh_host'], :user => $config['ipfs_ssh_user']
|
rbox = Rye::Box.new $config['ipfs_ssh_host'], :user => $config['ipfs_ssh_user']
|
||||||
|
|
|
@ -763,10 +763,11 @@ class Site < Sequel::Model
|
||||||
purge_cache path
|
purge_cache path
|
||||||
end
|
end
|
||||||
|
|
||||||
Rye::Cmd.add_command :ipfs
|
#Rye::Cmd.add_command :ipfs
|
||||||
|
|
||||||
def add_to_ipfs
|
def add_to_ipfs
|
||||||
# Not ideal. An SoA version is in progress.
|
# Not ideal. An SoA version is in progress.
|
||||||
|
return nil
|
||||||
|
|
||||||
if archives_dataset.count > Archive::MAXIMUM_ARCHIVES_PER_SITE
|
if archives_dataset.count > Archive::MAXIMUM_ARCHIVES_PER_SITE
|
||||||
archives_dataset.order(:updated_at).first.destroy
|
archives_dataset.order(:updated_at).first.destroy
|
||||||
|
@ -833,7 +834,7 @@ class Site < Sequel::Model
|
||||||
path = scrubbed_path path
|
path = scrubbed_path path
|
||||||
relative_path = files_path path
|
relative_path = files_path path
|
||||||
|
|
||||||
if Dir.exists?(relative_path) || File.exist?(relative_path)
|
if Dir.exist?(relative_path) || File.exist?(relative_path)
|
||||||
return 'Directory (or file) already exists.'
|
return 'Directory (or file) already exists.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ Rainbows! do
|
||||||
|
|
||||||
before_fork do |server, worker|
|
before_fork do |server, worker|
|
||||||
old_pid = "/var/run/neocities/neocities.pid.oldbin"
|
old_pid = "/var/run/neocities/neocities.pid.oldbin"
|
||||||
if File.exists?(old_pid) && server.pid != old_pid
|
if File.exist?(old_pid) && server.pid != old_pid
|
||||||
begin
|
begin
|
||||||
Process.kill("QUIT", File.read(old_pid).to_i)
|
Process.kill("QUIT", File.read(old_pid).to_i)
|
||||||
rescue Errno::ENOENT, Errno::ESRCH
|
rescue Errno::ENOENT, Errno::ESRCH
|
||||||
|
|
|
@ -15,13 +15,13 @@ describe '/admin' do
|
||||||
include Capybara::DSL
|
include Capybara::DSL
|
||||||
|
|
||||||
it 'works for admin site' do
|
it 'works for admin site' do
|
||||||
page.body.must_match /Administration/
|
_(page.body).must_match /Administration/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for site without admin' do
|
it 'fails for site without admin' do
|
||||||
page.set_rack_session id: @site.id
|
page.set_rack_session id: @site.id
|
||||||
visit '/admin'
|
visit '/admin'
|
||||||
page.current_path.must_equal '/'
|
_(page.current_path).must_equal '/'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,9 +29,10 @@ describe '/admin' do
|
||||||
include Capybara::DSL
|
include Capybara::DSL
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@stripe_helper = StripeMock.create_test_helper
|
stripe_helper = StripeMock.create_test_helper
|
||||||
StripeMock.start
|
StripeMock.start
|
||||||
@plan = @stripe_helper.create_plan id: 'special', amount: 0
|
stripe_helper.create_product(id: 'supporter', name: 'Supporter Plan')
|
||||||
|
@plan = stripe_helper.create_plan(product: 'supporter', amount: 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -43,10 +44,10 @@ describe '/admin' do
|
||||||
fill_in 'username', with: @site.username
|
fill_in 'username', with: @site.username
|
||||||
click_button 'Upgrade to Supporter'
|
click_button 'Upgrade to Supporter'
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.stripe_customer_id.wont_be_nil
|
_(@site.stripe_customer_id).wont_be_nil
|
||||||
@site.stripe_subscription_id.wont_be_nil
|
_(@site.stripe_subscription_id).wont_be_nil
|
||||||
@site.values[:plan_type].must_equal 'special'
|
_(@site.values[:plan_type]).must_equal 'special'
|
||||||
@site.supporter?.must_equal true
|
_(@site.supporter?).must_equal true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,20 +83,20 @@ describe '/admin' do
|
||||||
click_button 'Send'
|
click_button 'Send'
|
||||||
|
|
||||||
relevant_jobs = EmailWorker.jobs.select{|j| relevant_emails.include?(j['args'].first['to']) }
|
relevant_jobs = EmailWorker.jobs.select{|j| relevant_emails.include?(j['args'].first['to']) }
|
||||||
relevant_jobs.length.must_equal sites_emailed_count
|
_(relevant_jobs.length).must_equal sites_emailed_count
|
||||||
|
|
||||||
relevant_jobs.each do |job|
|
relevant_jobs.each do |job|
|
||||||
args = job['args'].first
|
args = job['args'].first
|
||||||
args['from'].must_equal 'Kyle from Neocities <kyle@neocities.org>'
|
_(args['from']).must_equal 'Kyle from Neocities <kyle@neocities.org>'
|
||||||
args['subject'].must_equal 'Subject Test'
|
_(args['subject']).must_equal 'Subject Test'
|
||||||
args['body'].must_equal 'Body Test'
|
_(args['body']).must_equal 'Body Test'
|
||||||
end
|
end
|
||||||
|
|
||||||
relevant_jobs.select {|j| j['at'].nil? || j['at'] == Time.now.to_f}.length.must_equal 1
|
_(relevant_jobs.select {|j| j['at'].nil? || j['at'] == Time.now.to_f}.length).must_equal 1
|
||||||
relevant_jobs.select {|j| j['at'] == (Time.now + 0.5).to_f}.length.must_equal 1
|
_(relevant_jobs.select {|j| j['at'] == (Time.now + 0.5).to_f}.length).must_equal 1
|
||||||
|
|
||||||
relevant_jobs.select {|j| j['at'] == (time+1.day.to_i).to_f}.length.must_equal 1
|
_(relevant_jobs.select {|j| j['at'] == (time+1.day.to_i).to_f}.length).must_equal 1
|
||||||
relevant_jobs.select {|j| j['at'] == (time+1.day.to_i+0.5).to_f}.length.must_equal 1
|
_(relevant_jobs.select {|j| j['at'] == (time+1.day.to_i+0.5).to_f}.length).must_equal 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,9 +14,9 @@ describe 'dashboard' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'records a dashboard access' do
|
it 'records a dashboard access' do
|
||||||
@site.reload.dashboard_accessed.must_equal false
|
_(@site.reload.dashboard_accessed).must_equal false
|
||||||
visit '/dashboard'
|
visit '/dashboard'
|
||||||
@site.reload.dashboard_accessed.must_equal true
|
_(@site.reload.dashboard_accessed).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a base directory' do
|
it 'creates a base directory' do
|
||||||
|
@ -25,8 +25,8 @@ describe 'dashboard' do
|
||||||
fill_in 'name', with: 'testimages'
|
fill_in 'name', with: 'testimages'
|
||||||
#click_button 'Create'
|
#click_button 'Create'
|
||||||
all('#createDir button[type=submit]').first.click
|
all('#createDir button[type=submit]').first.click
|
||||||
page.must_have_content /testimages/
|
_(page).must_have_content /testimages/
|
||||||
File.directory?(@site.files_path('testimages')).must_equal true
|
_(File.directory?(@site.files_path('testimages'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a new file' do
|
it 'creates a new file' do
|
||||||
|
@ -36,8 +36,8 @@ describe 'dashboard' do
|
||||||
fill_in 'filename', with: "#{random}.html"
|
fill_in 'filename', with: "#{random}.html"
|
||||||
#click_button 'Create'
|
#click_button 'Create'
|
||||||
all('#createFile button[type=submit]').first.click
|
all('#createFile button[type=submit]').first.click
|
||||||
page.must_have_content /#{random}\.html/
|
_(page).must_have_content /#{random}\.html/
|
||||||
File.exist?(@site.files_path("#{random}.html")).must_equal true
|
_(File.exist?(@site.files_path("#{random}.html"))).must_equal true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ describe 'signup' do
|
||||||
Capybara.default_driver = :apparition
|
Capybara.default_driver = :apparition
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
visit '/education'
|
visit '/education'
|
||||||
page.must_have_content 'Neocities' # Used to force load wait
|
_(page).must_have_content 'Neocities' # Used to force load wait
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -31,30 +31,30 @@ describe 'signup' do
|
||||||
fill_in 'email', with: @site[:email]
|
fill_in 'email', with: @site[:email]
|
||||||
fill_in 'new_tags_string', with: 'nope'
|
fill_in 'new_tags_string', with: 'nope'
|
||||||
click_button 'Create My Site'
|
click_button 'Create My Site'
|
||||||
page.wont_have_content /Let's Get Started/
|
_(page).wont_have_content /Let's Get Started/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with valid data' do
|
it 'succeeds with valid data' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
click_button 'Create My Site'
|
click_button 'Create My Site'
|
||||||
page.must_have_content /Let's Get Started/
|
_(page).must_have_content /Let's Get Started/
|
||||||
|
|
||||||
index_file_path = File.join Site::SITE_FILES_ROOT, Site.sharding_dir(@site[:username]), @site[:username], 'index.html'
|
index_file_path = File.join Site::SITE_FILES_ROOT, Site.sharding_dir(@site[:username]), @site[:username], 'index.html'
|
||||||
File.exist?(index_file_path).must_equal true
|
_(File.exist?(index_file_path)).must_equal true
|
||||||
|
|
||||||
site = Site[username: @site[:username]]
|
site = Site[username: @site[:username]]
|
||||||
site.site_files.length.must_equal 4
|
_(site.site_files.length).must_equal 4
|
||||||
site.site_changed.must_equal false
|
_(site.site_changed).must_equal false
|
||||||
site.site_updated_at.must_be_nil
|
_(site.site_updated_at).must_be_nil
|
||||||
site.is_education.must_equal true
|
_(site.is_education).must_equal true
|
||||||
site.tags.length.must_equal 1
|
_(site.tags.length).must_equal 1
|
||||||
site.tags.first.name.must_equal @class_tag
|
_(site.tags.first.name).must_equal @class_tag
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for multiple tags' do
|
it 'fails for multiple tags' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in :new_tags_string, with: 'derp, ie'
|
fill_in :new_tags_string, with: 'derp, ie'
|
||||||
click_button 'Create My Site'
|
click_button 'Create My Site'
|
||||||
page.must_have_content 'Must only have one tag'
|
_(page).must_have_content 'Must only have one tag'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,8 +11,8 @@ describe '/' do
|
||||||
|
|
||||||
it 'loads the news feed with welcome' do
|
it 'loads the news feed with welcome' do
|
||||||
visit '/'
|
visit '/'
|
||||||
page.body.must_match /Thanks for joining the Neocities community/i
|
_(page.body).must_match /Thanks for joining the Neocities community/i
|
||||||
page.body.wont_match /You aren’t following any websites yet/i
|
_(page.body).wont_match /You aren’t following any websites yet/i
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays a follow and an unrelated follow' do
|
it 'displays a follow and an unrelated follow' do
|
||||||
|
@ -21,7 +21,7 @@ describe '/' do
|
||||||
@another_site = Fabricate :site
|
@another_site = Fabricate :site
|
||||||
@followed_site.toggle_follow @another_site
|
@followed_site.toggle_follow @another_site
|
||||||
visit '/'
|
visit '/'
|
||||||
find('.news-item', match: :first).text.must_match /#{@followed_site.username} followed #{@another_site.username}/i
|
_(find('.news-item', match: :first).text).must_match /#{@followed_site.username} followed #{@another_site.username}/i
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'loads my activities only' do
|
it 'loads my activities only' do
|
||||||
|
@ -30,14 +30,14 @@ describe '/' do
|
||||||
@another_site = Fabricate :site
|
@another_site = Fabricate :site
|
||||||
@followed_site.toggle_follow @another_site
|
@followed_site.toggle_follow @another_site
|
||||||
visit '/?activity=mine'
|
visit '/?activity=mine'
|
||||||
find('.news-item').text.must_match //i
|
_(find('.news-item').text).must_match //i
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'loads a specific event with the id' do
|
it 'loads a specific event with the id' do
|
||||||
@followed_site = Fabricate :site
|
@followed_site = Fabricate :site
|
||||||
@site.toggle_follow @followed_site
|
@site.toggle_follow @followed_site
|
||||||
visit "/?event_id=#{@followed_site.events.first.id}"
|
visit "/?event_id=#{@followed_site.events.first.id}"
|
||||||
find('.news-item').text.must_match /you followed #{@followed_site.username}/i
|
_(find('.news-item').text).must_match /you followed #{@followed_site.username}/i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ describe '/' do
|
||||||
links.each do |l|
|
links.each do |l|
|
||||||
visit '/'
|
visit '/'
|
||||||
find('a', text: l.first, match: :first).click
|
find('a', text: l.first, match: :first).click
|
||||||
page.status_code.must_equal 200
|
_(page.status_code).must_equal 200
|
||||||
page.current_path.must_equal "/#{l.last}"
|
_(page.current_path).must_equal "/#{l.last}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,29 +74,29 @@ describe '/' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'works for valid email' do
|
it 'works for valid email' do
|
||||||
page.current_url.must_match /\/forgot_username$/
|
_(page.current_url).must_match /\/forgot_username$/
|
||||||
fill_in :email, with: @site.email
|
fill_in :email, with: @site.email
|
||||||
click_button 'Find username'
|
click_button 'Find username'
|
||||||
URI.parse(page.current_url).path.must_equal '/'
|
_(URI.parse(page.current_url).path).must_equal '/'
|
||||||
page.must_have_content 'If your email was valid, the Neocities Cat will send an e-mail with your username in it'
|
_(page).must_have_content 'If your email was valid, the Neocities Cat will send an e-mail with your username in it'
|
||||||
email_args = EmailWorker.jobs.first['args'].first
|
email_args = EmailWorker.jobs.first['args'].first
|
||||||
email_args['to'].must_equal @site.email
|
_(email_args['to']).must_equal @site.email
|
||||||
email_args['subject'].must_match /username lookup/i
|
_(email_args['subject']).must_match /username lookup/i
|
||||||
email_args['body'].must_match /your username is #{@site.username}/i
|
_(email_args['body']).must_match /your username is #{@site.username}/i
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails silently for unknown email' do
|
it 'fails silently for unknown email' do
|
||||||
fill_in :email, with: 'N-O-P-E@example.com'
|
fill_in :email, with: 'N-O-P-E@example.com'
|
||||||
click_button 'Find username'
|
click_button 'Find username'
|
||||||
URI.parse(page.current_url).path.must_equal '/'
|
_(URI.parse(page.current_url).path).must_equal '/'
|
||||||
page.must_have_content 'If your email was valid, the Neocities Cat will send an e-mail with your username in it'
|
_(page).must_have_content 'If your email was valid, the Neocities Cat will send an e-mail with your username in it'
|
||||||
EmailWorker.jobs.length.must_equal 0
|
_(EmailWorker.jobs.length).must_equal 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for no input' do
|
it 'fails for no input' do
|
||||||
click_button 'Find username'
|
click_button 'Find username'
|
||||||
URI.parse(page.current_url).path.must_equal '/forgot_username'
|
_(URI.parse(page.current_url).path).must_equal '/forgot_username'
|
||||||
page.must_have_content 'Cannot use an empty email address'
|
_(page).must_have_content 'Cannot use an empty email address'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ describe '/password_reset' do
|
||||||
|
|
||||||
it 'should load the password reset page' do
|
it 'should load the password reset page' do
|
||||||
visit '/password_reset'
|
visit '/password_reset'
|
||||||
page.body.must_match /Reset Password/
|
_(page.body).must_match /Reset Password/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not load password reset if logged in' do
|
it 'should not load password reset if logged in' do
|
||||||
|
@ -18,14 +18,14 @@ describe '/password_reset' do
|
||||||
page.set_rack_session id: @site.id
|
page.set_rack_session id: @site.id
|
||||||
|
|
||||||
visit '/password_reset'
|
visit '/password_reset'
|
||||||
URI.parse(page.current_url).path.must_equal '/'
|
_(URI.parse(page.current_url).path).must_equal '/'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'errors for missing email' do
|
it 'errors for missing email' do
|
||||||
visit '/password_reset'
|
visit '/password_reset'
|
||||||
click_button 'Send Reset Token'
|
click_button 'Send Reset Token'
|
||||||
URI.parse(page.current_url).path.must_equal '/password_reset'
|
_(URI.parse(page.current_url).path).must_equal '/password_reset'
|
||||||
body.must_match /You must enter a valid email address/
|
_(body).must_match /You must enter a valid email address/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for invalid username or token' do
|
it 'fails for invalid username or token' do
|
||||||
|
@ -45,8 +45,8 @@ describe '/password_reset' do
|
||||||
|
|
||||||
].each do |params|
|
].each do |params|
|
||||||
visit "/password_reset_confirm?#{Rack::Utils.build_query params}"
|
visit "/password_reset_confirm?#{Rack::Utils.build_query params}"
|
||||||
page.must_have_content 'Could not find a site with this username and token'
|
_(page).must_have_content 'Could not find a site with this username and token'
|
||||||
@site.reload.password_reset_confirmed.must_equal false
|
_(@site.reload.password_reset_confirmed).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -55,8 +55,8 @@ describe '/password_reset' do
|
||||||
{username: '', token: ''}
|
{username: '', token: ''}
|
||||||
].each do |params|
|
].each do |params|
|
||||||
visit "/password_reset_confirm?#{Rack::Utils.build_query params}"
|
visit "/password_reset_confirm?#{Rack::Utils.build_query params}"
|
||||||
page.must_have_content 'Token cannot be empty'
|
_(page).must_have_content 'Token cannot be empty'
|
||||||
@site.reload.password_reset_confirmed.must_equal false
|
_(@site.reload.password_reset_confirmed).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -67,24 +67,24 @@ describe '/password_reset' do
|
||||||
fill_in 'email', with: @site.email
|
fill_in 'email', with: @site.email
|
||||||
click_button 'Send Reset Token'
|
click_button 'Send Reset Token'
|
||||||
|
|
||||||
body.must_match /send an e-mail to your account with password reset instructions/
|
_(body).must_match /send an e-mail to your account with password reset instructions/
|
||||||
@site.reload.password_reset_token.blank?.must_equal false
|
_(@site.reload.password_reset_token.blank?).must_equal false
|
||||||
EmailWorker.jobs.first['args'].first['body'].must_match /#{Rack::Utils.build_query(username: @site.username, token: @site.password_reset_token)}/
|
_(EmailWorker.jobs.first['args'].first['body']).must_match /#{Rack::Utils.build_query(username: @site.username, token: @site.password_reset_token)}/
|
||||||
|
|
||||||
visit "/password_reset_confirm?#{Rack::Utils.build_query username: @site.username, token: @site.reload.password_reset_token}"
|
visit "/password_reset_confirm?#{Rack::Utils.build_query username: @site.username, token: @site.reload.password_reset_token}"
|
||||||
|
|
||||||
page.current_url.must_match /.+\/settings#password/
|
_(page.current_url).must_match /.+\/settings#password/
|
||||||
|
|
||||||
fill_in 'new_password', with: 'n3wp4s$'
|
fill_in 'new_password', with: 'n3wp4s$'
|
||||||
fill_in 'new_password_confirm', with: 'n3wp4s$'
|
fill_in 'new_password_confirm', with: 'n3wp4s$'
|
||||||
click_button 'Change Password'
|
click_button 'Change Password'
|
||||||
|
|
||||||
page.current_url.must_match /.+\/settings#password/
|
_(page.current_url).must_match /.+\/settings#password/
|
||||||
page.must_have_content 'Successfully changed password'
|
_(page).must_have_content 'Successfully changed password'
|
||||||
Site.valid_login?(@site.username, 'n3wp4s$').must_equal true
|
_(Site.valid_login?(@site.username, 'n3wp4s$')).must_equal true
|
||||||
page.get_rack_session['id'].must_equal @site.id
|
_(page.get_rack_session['id']).must_equal @site.id
|
||||||
@site.reload.password_reset_token.must_be_nil
|
_(@site.reload.password_reset_token).must_be_nil
|
||||||
@site.password_reset_confirmed.must_equal false
|
_(@site.password_reset_confirmed).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,38 +20,38 @@ describe 'site/settings' do
|
||||||
fill_in 'email', with: @new_email
|
fill_in 'email', with: @new_email
|
||||||
click_button 'Change Email'
|
click_button 'Change Email'
|
||||||
|
|
||||||
page.must_have_content /enter the confirmation code here/
|
_(page).must_have_content /enter the confirmation code here/
|
||||||
|
|
||||||
fill_in 'token', with: @site.reload.email_confirmation_token
|
fill_in 'token', with: @site.reload.email_confirmation_token
|
||||||
click_button 'Confirm Email'
|
click_button 'Confirm Email'
|
||||||
|
|
||||||
page.must_have_content /Email address changed/i
|
_(page).must_have_content /Email address changed/i
|
||||||
|
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.email.must_equal @new_email
|
_(@site.email).must_equal @new_email
|
||||||
@site.password_reset_token.must_be_nil
|
_(@site.password_reset_token).must_be_nil
|
||||||
|
|
||||||
EmailWorker.jobs.length.must_equal 2
|
_(EmailWorker.jobs.length).must_equal 2
|
||||||
|
|
||||||
args = EmailWorker.jobs.select {|job| job['args'].first['subject'] =~ /confirm your email address/i}.first['args'].first
|
args = EmailWorker.jobs.select {|job| job['args'].first['subject'] =~ /confirm your email address/i}.first['args'].first
|
||||||
args['to'].must_equal @new_email
|
_(args['to']).must_equal @new_email
|
||||||
args['subject'].must_match /confirm your email address/i
|
_(args['subject']).must_match /confirm your email address/i
|
||||||
args['body'].must_match /hello #{@site.username}/i
|
_(args['body']).must_match /hello #{@site.username}/i
|
||||||
args['body'].must_match /#{@site.email_confirmation_token}/
|
_(args['body']).must_match /#{@site.email_confirmation_token}/
|
||||||
|
|
||||||
args = EmailWorker.jobs.select {|job| job['args'].first['subject'] =~ /your email address.+changed/i}.first['args'].first
|
args = EmailWorker.jobs.select {|job| job['args'].first['subject'] =~ /your email address.+changed/i}.first['args'].first
|
||||||
args['body'].must_match /previous email.+#{original_email}/
|
_(args['body']).must_match /previous email.+#{original_email}/
|
||||||
args['body'].must_match /new email.+#{@site.email}/
|
_(args['body']).must_match /new email.+#{@site.email}/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail for invalid email address' do
|
it 'should fail for invalid email address' do
|
||||||
@new_email = SecureRandom.uuid.gsub '-', ''
|
@new_email = SecureRandom.uuid.gsub '-', ''
|
||||||
fill_in 'email', with: @new_email
|
fill_in 'email', with: @new_email
|
||||||
click_button 'Change Email'
|
click_button 'Change Email'
|
||||||
page.must_have_content /a valid email address is required/i
|
_(page).must_have_content /a valid email address is required/i
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.email.wont_equal @new_email
|
_(@site.email).wont_equal @new_email
|
||||||
EmailWorker.jobs.empty?.must_equal true
|
_(EmailWorker.jobs.empty?).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail for existing email' do
|
it 'should fail for existing email' do
|
||||||
|
@ -60,10 +60,10 @@ describe 'site/settings' do
|
||||||
|
|
||||||
fill_in 'email', with: @existing_email
|
fill_in 'email', with: @existing_email
|
||||||
click_button 'Change Email'
|
click_button 'Change Email'
|
||||||
page.must_have_content /this email address already exists on neocities/i
|
_(page).must_have_content /this email address already exists on neocities/i
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.email.wont_equal @new_email
|
_(@site.email).wont_equal @new_email
|
||||||
EmailWorker.jobs.empty?.must_equal true
|
_(EmailWorker.jobs.empty?).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should update email preferences' do
|
it 'should update email preferences' do
|
||||||
|
@ -71,15 +71,15 @@ describe 'site/settings' do
|
||||||
uncheck 'send_comment_emails'
|
uncheck 'send_comment_emails'
|
||||||
uncheck 'send_follow_emails'
|
uncheck 'send_follow_emails'
|
||||||
|
|
||||||
@site.send_emails.must_equal true
|
_(@site.send_emails).must_equal true
|
||||||
@site.send_comment_emails.must_equal true
|
_(@site.send_comment_emails).must_equal true
|
||||||
@site.send_follow_emails.must_equal true
|
_(@site.send_follow_emails).must_equal true
|
||||||
|
|
||||||
click_button 'Update Notification Settings'
|
click_button 'Update Notification Settings'
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.send_emails.must_equal false
|
_(@site.send_emails).must_equal false
|
||||||
@site.send_comment_emails.must_equal false
|
_(@site.send_comment_emails).must_equal false
|
||||||
@site.send_follow_emails.must_equal false
|
_(@site.send_follow_emails).must_equal false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -112,13 +112,13 @@ describe 'site/settings' do
|
||||||
EmailWorker.drain
|
EmailWorker.drain
|
||||||
email = Mail::TestMailer.deliveries.first
|
email = Mail::TestMailer.deliveries.first
|
||||||
|
|
||||||
email.body.to_s.must_match @email_unsubscribe_url
|
_(email.body.to_s).must_match @email_unsubscribe_url
|
||||||
@site.send_emails.must_equal true
|
_(@site.send_emails).must_equal true
|
||||||
visit '/settings/unsubscribe_email?'+@params_query
|
visit '/settings/unsubscribe_email?'+@params_query
|
||||||
|
|
||||||
page.body.must_match /You have been successfully unsubscribed.+#{@site.email}/i
|
_(page.body).must_match /You have been successfully unsubscribed.+#{@site.email}/i
|
||||||
|
|
||||||
@site.reload.send_emails.must_equal false
|
_(@site.reload.send_emails).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail to subscribe for bad token' do
|
it 'should fail to subscribe for bad token' do
|
||||||
|
@ -142,12 +142,12 @@ describe 'site/settings' do
|
||||||
fill_in 'new_password_confirm', with: 'derpie2'
|
fill_in 'new_password_confirm', with: 'derpie2'
|
||||||
click_button 'Change Password'
|
click_button 'Change Password'
|
||||||
|
|
||||||
page.must_have_content /successfully changed password/i
|
_(page).must_have_content /successfully changed password/i
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.valid_password?('derpie').must_equal false
|
_(@site.valid_password?('derpie')).must_equal false
|
||||||
@site.valid_password?('derpie2').must_equal true
|
_(@site.valid_password?('derpie2')).must_equal true
|
||||||
|
|
||||||
EmailWorker.jobs.select {|job| job['args'].first['subject'] =~ /password has been changed/i}.length.must_equal 1
|
_(EmailWorker.jobs.select {|job| job['args'].first['subject'] =~ /password has been changed/i}.length).must_equal 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not change for invalid current password' do
|
it 'should not change for invalid current password' do
|
||||||
|
@ -156,12 +156,12 @@ describe 'site/settings' do
|
||||||
fill_in 'new_password_confirm', with: 'derpie2'
|
fill_in 'new_password_confirm', with: 'derpie2'
|
||||||
click_button 'Change Password'
|
click_button 'Change Password'
|
||||||
|
|
||||||
page.must_have_content /provided password does not match the current one/i
|
_(page).must_have_content /provided password does not match the current one/i
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.valid_password?('derpie').must_equal true
|
_(@site.valid_password?('derpie')).must_equal true
|
||||||
@site.valid_password?('derpie2').must_equal false
|
_(@site.valid_password?('derpie2')).must_equal false
|
||||||
|
|
||||||
EmailWorker.jobs.length.must_equal 0
|
_(EmailWorker.jobs.length).must_equal 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -93,13 +93,13 @@ describe 'site/settings' do
|
||||||
page.set_rack_session id: @other_site.id
|
page.set_rack_session id: @other_site.id
|
||||||
|
|
||||||
visit "/settings/#{@parent_site.username}"
|
visit "/settings/#{@parent_site.username}"
|
||||||
page.current_path.must_equal '/' # This could be better
|
_(page.current_path).must_equal '/' # This could be better
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows child site editing from parent' do
|
it 'allows child site editing from parent' do
|
||||||
page.set_rack_session id: @parent_site.id
|
page.set_rack_session id: @parent_site.id
|
||||||
visit "/settings/#{@child_site.username}"
|
visit "/settings/#{@child_site.username}"
|
||||||
page.current_path.must_equal "/settings/#{@child_site.username}"
|
_(page.current_path).must_equal "/settings/#{@child_site.username}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,33 +114,33 @@ describe 'site/settings' do
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Site[username: @site[:username]].wont_equal nil
|
_(Site[username: @site[:username]]).wont_equal nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for blank username' do
|
it 'fails for blank username' do
|
||||||
fill_in 'name', with: ''
|
fill_in 'name', with: ''
|
||||||
click_button 'Change Name'
|
click_button 'Change Name'
|
||||||
page.must_have_content /cannot be blank/i
|
_(page).must_have_content /cannot be blank/i
|
||||||
Site[username: ''].must_be_nil
|
_(Site[username: '']).must_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for subdir periods' do
|
it 'fails for subdir periods' do
|
||||||
fill_in 'name', with: '../hack'
|
fill_in 'name', with: '../hack'
|
||||||
click_button 'Change Name'
|
click_button 'Change Name'
|
||||||
page.must_have_content /Usernames can only contain/i
|
_(page).must_have_content /Usernames can only contain/i
|
||||||
Site[username: '../hack'].must_be_nil
|
_(Site[username: '../hack']).must_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for same username' do
|
it 'fails for same username' do
|
||||||
fill_in 'name', with: @site.username
|
fill_in 'name', with: @site.username
|
||||||
click_button 'Change Name'
|
click_button 'Change Name'
|
||||||
page.must_have_content /You already have this name/
|
_(page).must_have_content /You already have this name/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for same username with DiFfErEnT CaSiNg' do
|
it 'fails for same username with DiFfErEnT CaSiNg' do
|
||||||
fill_in 'name', with: @site.username.upcase
|
fill_in 'name', with: @site.username.upcase
|
||||||
click_button 'Change Name'
|
click_button 'Change Name'
|
||||||
page.must_have_content /You already have this name/
|
_(page).must_have_content /You already have this name/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -163,8 +163,8 @@ describe 'delete' do
|
||||||
fill_in 'username', with: 'NOPE'
|
fill_in 'username', with: 'NOPE'
|
||||||
click_button 'Delete Site'
|
click_button 'Delete Site'
|
||||||
|
|
||||||
page.body.must_match /Site user name and entered user name did not match/i
|
_(page.body).must_match /Site user name and entered user name did not match/i
|
||||||
@site.reload.is_deleted.must_equal false
|
_(@site.reload.is_deleted).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
|
@ -175,19 +175,19 @@ describe 'delete' do
|
||||||
click_button 'Delete Site'
|
click_button 'Delete Site'
|
||||||
|
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.is_deleted.must_equal true
|
_(@site.is_deleted).must_equal true
|
||||||
@site.deleted_reason.must_equal deleted_reason
|
_(@site.deleted_reason).must_equal deleted_reason
|
||||||
page.current_path.must_equal '/'
|
_(page.current_path).must_equal '/'
|
||||||
|
|
||||||
File.exist?(@site.files_path('./index.html')).must_equal false
|
_(File.exist?(@site.files_path('./index.html'))).must_equal false
|
||||||
Dir.exist?(@site.files_path).must_equal false
|
_(Dir.exist?(@site.files_path)).must_equal false
|
||||||
|
|
||||||
path = File.join Site::DELETED_SITES_ROOT, Site.sharding_dir(@site.username), @site.username
|
path = File.join Site::DELETED_SITES_ROOT, Site.sharding_dir(@site.username), @site.username
|
||||||
Dir.exist?(path).must_equal true
|
_(Dir.exist?(path)).must_equal true
|
||||||
File.exist?(File.join(path, 'index.html')).must_equal true
|
_(File.exist?(File.join(path, 'index.html'))).must_equal true
|
||||||
|
|
||||||
visit "/site/#{@site.username}"
|
visit "/site/#{@site.username}"
|
||||||
page.status_code.must_equal 404
|
_(page.status_code).must_equal 404
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'stops charging for supporter account' do
|
it 'stops charging for supporter account' do
|
||||||
|
@ -215,10 +215,10 @@ describe 'delete' do
|
||||||
fill_in 'deleted_reason', with: 'derp'
|
fill_in 'deleted_reason', with: 'derp'
|
||||||
click_button 'Delete Site'
|
click_button 'Delete Site'
|
||||||
|
|
||||||
Stripe::Customer.retrieve(@site.stripe_customer_id).subscriptions.count.must_equal 0
|
_(Stripe::Customer.retrieve(@site.stripe_customer_id).subscriptions.count).must_equal 0
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.stripe_subscription_id.must_be_nil
|
_(@site.stripe_subscription_id).must_be_nil
|
||||||
@site.is_deleted.must_equal true
|
_(@site.is_deleted).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should fail unless owned by current user' do
|
it 'should fail unless owned by current user' do
|
||||||
|
@ -230,16 +230,16 @@ describe 'delete' do
|
||||||
deleted_reason: 'Dade Murphy enters Acid Burns turf'
|
deleted_reason: 'Dade Murphy enters Acid Burns turf'
|
||||||
}
|
}
|
||||||
|
|
||||||
page.driver.status_code.must_equal 302
|
_(page.driver.status_code).must_equal 302
|
||||||
URI.parse(page.driver.response_headers['Location']).path.must_equal '/'
|
_(URI.parse(page.driver.response_headers['Location']).path).must_equal '/'
|
||||||
someone_elses_site.reload
|
someone_elses_site.reload
|
||||||
someone_elses_site.is_deleted.must_equal false
|
_(someone_elses_site.is_deleted).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not show NSFW tab for admin NSFW flag' do
|
it 'should not show NSFW tab for admin NSFW flag' do
|
||||||
owned_site = Fabricate :site, parent_site_id: @site.id, admin_nsfw: true
|
owned_site = Fabricate :site, parent_site_id: @site.id, admin_nsfw: true
|
||||||
visit "/settings/#{owned_site.username}"
|
visit "/settings/#{owned_site.username}"
|
||||||
page.body.wont_match /18\+/
|
_(page.body).wont_match /18\+/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should succeed if you own the site' do
|
it 'should succeed if you own the site' do
|
||||||
|
@ -250,15 +250,15 @@ describe 'delete' do
|
||||||
|
|
||||||
@site.reload
|
@site.reload
|
||||||
owned_site.reload
|
owned_site.reload
|
||||||
owned_site.is_deleted.must_equal true
|
_(owned_site.is_deleted).must_equal true
|
||||||
@site.is_deleted.must_equal false
|
_(@site.is_deleted).must_equal false
|
||||||
|
|
||||||
page.current_path.must_equal "/settings"
|
_(page.current_path).must_equal "/settings"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to delete parent site if children exist' do
|
it 'fails to delete parent site if children exist' do
|
||||||
owned_site = Fabricate :site, parent_site_id: @site.id
|
owned_site = Fabricate :site, parent_site_id: @site.id
|
||||||
visit "/settings/#{@site.username}#delete"
|
visit "/settings/#{@site.username}#delete"
|
||||||
page.body.must_match /You cannot delete the parent site without deleting the children sites first/i
|
_(page.body).must_match /You cannot delete the parent site without deleting the children sites first/i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,26 +17,26 @@ describe 'signin' do
|
||||||
pass = SecureRandom.hex
|
pass = SecureRandom.hex
|
||||||
@site = Fabricate :site, password: pass
|
@site = Fabricate :site, password: pass
|
||||||
@site.destroy
|
@site.destroy
|
||||||
Dir.exist?(@site.files_path).must_equal false
|
_(Dir.exist?(@site.files_path)).must_equal false
|
||||||
Dir.exist?(@site.deleted_files_path).must_equal true
|
_(Dir.exist?(@site.deleted_files_path)).must_equal true
|
||||||
visit '/signin'
|
visit '/signin'
|
||||||
fill_in 'username', with: @site.username
|
fill_in 'username', with: @site.username
|
||||||
fill_in 'password', with: pass
|
fill_in 'password', with: pass
|
||||||
click_button 'Sign In'
|
click_button 'Sign In'
|
||||||
page.must_have_content 'Restore Site'
|
_(page).must_have_content 'Restore Site'
|
||||||
click_button 'Restore Site'
|
click_button 'Restore Site'
|
||||||
Dir.exist?(@site.deleted_files_path).must_equal false
|
_(Dir.exist?(@site.deleted_files_path)).must_equal false
|
||||||
Dir.exist?(@site.files_path).must_equal true
|
_(Dir.exist?(@site.files_path)).must_equal true
|
||||||
@site.reload.is_deleted.must_equal false
|
_(@site.reload.is_deleted).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for invalid signin' do
|
it 'fails for invalid signin' do
|
||||||
visit '/'
|
visit '/'
|
||||||
click_link 'Sign In'
|
click_link 'Sign In'
|
||||||
page.must_have_content 'Welcome Back'
|
_(page).must_have_content 'Welcome Back'
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
click_button 'Sign In'
|
click_button 'Sign In'
|
||||||
page.must_have_content 'Invalid login'
|
_(page).must_have_content 'Invalid login'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for missing signin' do
|
it 'fails for missing signin' do
|
||||||
|
@ -46,7 +46,7 @@ describe 'signin' do
|
||||||
fill_in 'username', with: auth[:username]
|
fill_in 'username', with: auth[:username]
|
||||||
fill_in 'password', with: auth[:password]
|
fill_in 'password', with: auth[:password]
|
||||||
click_button 'Sign In'
|
click_button 'Sign In'
|
||||||
page.must_have_content 'Invalid login'
|
_(page).must_have_content 'Invalid login'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'signs in with proper credentials' do
|
it 'signs in with proper credentials' do
|
||||||
|
@ -57,7 +57,7 @@ describe 'signin' do
|
||||||
fill_in 'username', with: @site.username
|
fill_in 'username', with: @site.username
|
||||||
fill_in 'password', with: pass
|
fill_in 'password', with: pass
|
||||||
click_button 'Sign In'
|
click_button 'Sign In'
|
||||||
page.must_have_content 'Your Feed'
|
_(page).must_have_content 'Your Feed'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'signs in with invalid case username' do
|
it 'signs in with invalid case username' do
|
||||||
|
@ -68,7 +68,7 @@ describe 'signin' do
|
||||||
fill_in 'username', with: @site.username.upcase
|
fill_in 'username', with: @site.username.upcase
|
||||||
fill_in 'password', with: pass
|
fill_in 'password', with: pass
|
||||||
click_button 'Sign In'
|
click_button 'Sign In'
|
||||||
page.must_have_content 'Your Feed'
|
_(page).must_have_content 'Your Feed'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'signs in with email' do
|
it 'signs in with email' do
|
||||||
|
@ -79,7 +79,7 @@ describe 'signin' do
|
||||||
fill_in 'username', with: @site.email
|
fill_in 'username', with: @site.email
|
||||||
fill_in 'password', with: pass
|
fill_in 'password', with: pass
|
||||||
click_button 'Sign In'
|
click_button 'Sign In'
|
||||||
page.must_have_content 'Your Feed'
|
_(page).must_have_content 'Your Feed'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'signs in with invalid case email' do
|
it 'signs in with invalid case email' do
|
||||||
|
@ -90,6 +90,6 @@ describe 'signin' do
|
||||||
fill_in 'username', with: @site.email.upcase
|
fill_in 'username', with: @site.email.upcase
|
||||||
fill_in 'password', with: pass
|
fill_in 'password', with: pass
|
||||||
click_button 'Sign In'
|
click_button 'Sign In'
|
||||||
page.must_have_content 'Your Feed'
|
_(page).must_have_content 'Your Feed'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe 'signup' do
|
||||||
|
|
||||||
def fill_in_valid
|
def fill_in_valid
|
||||||
@site = Fabricate.attributes_for(:site)
|
@site = Fabricate.attributes_for(:site)
|
||||||
page.must_have_content 'Sign up for free'
|
_(page).must_have_content 'Sign up for free'
|
||||||
fill_in 'username', with: @site[:username]
|
fill_in 'username', with: @site[:username]
|
||||||
fill_in 'password', with: @site[:password]
|
fill_in 'password', with: @site[:password]
|
||||||
fill_in 'email', with: @site[:email]
|
fill_in 'email', with: @site[:email]
|
||||||
|
@ -16,7 +16,7 @@ describe 'signup' do
|
||||||
end
|
end
|
||||||
|
|
||||||
def site_created?
|
def site_created?
|
||||||
page.must_have_content 'Welcome to Neocities'
|
_(page).must_have_content 'Welcome to Neocities'
|
||||||
end
|
end
|
||||||
|
|
||||||
def visit_signup
|
def visit_signup
|
||||||
|
@ -41,22 +41,22 @@ describe 'signup' do
|
||||||
site_created?
|
site_created?
|
||||||
|
|
||||||
click_link 'Continue'
|
click_link 'Continue'
|
||||||
page.must_have_content /almost ready!/
|
_(page).must_have_content /almost ready!/
|
||||||
fill_in 'token', with: Site[username: @site[:username]].email_confirmation_token
|
fill_in 'token', with: Site[username: @site[:username]].email_confirmation_token
|
||||||
click_button 'Confirm Email'
|
click_button 'Confirm Email'
|
||||||
current_path.must_equal '/tutorial'
|
_(current_path).must_equal '/tutorial'
|
||||||
page.must_have_content /Let's Get Started/
|
_(page).must_have_content /Let's Get Started/
|
||||||
|
|
||||||
index_file_path = File.join Site::SITE_FILES_ROOT, Site.sharding_dir(@site[:username]), @site[:username], 'index.html'
|
index_file_path = File.join Site::SITE_FILES_ROOT, Site.sharding_dir(@site[:username]), @site[:username], 'index.html'
|
||||||
File.exist?(index_file_path).must_equal true
|
_(File.exist?(index_file_path)).must_equal true
|
||||||
|
|
||||||
site = Site[username: @site[:username]]
|
site = Site[username: @site[:username]]
|
||||||
site.site_files.length.must_equal 4
|
_(site.site_files.length).must_equal 4
|
||||||
site.site_changed.must_equal false
|
_(site.site_changed).must_equal false
|
||||||
site.site_updated_at.must_be_nil
|
_(site.site_updated_at).must_be_nil
|
||||||
site.is_education.must_equal false
|
_(site.is_education).must_equal false
|
||||||
|
|
||||||
site.ip.must_equal '127.0.0.1'
|
_(site.ip).must_equal '127.0.0.1'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if site with same ip has been banned' do
|
it 'fails if site with same ip has been banned' do
|
||||||
|
@ -65,9 +65,9 @@ describe 'signup' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
click_signup_button
|
click_signup_button
|
||||||
site = Site[username: @site[:username]]
|
site = Site[username: @site[:username]]
|
||||||
Site[username: @site[:username]].must_be_nil
|
_(Site[username: @site[:username]]).must_be_nil
|
||||||
current_path.must_equal '/'
|
_(current_path).must_equal '/'
|
||||||
page.wont_have_content 'Welcome to Neocities'
|
_(page).wont_have_content 'Welcome to Neocities'
|
||||||
@banned_site.update ip: nil
|
@banned_site.update ip: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@ describe 'signup' do
|
||||||
DB[:blocked_ips].insert(ip: '127.0.0.1', created_at: Time.now)
|
DB[:blocked_ips].insert(ip: '127.0.0.1', created_at: Time.now)
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
click_signup_button
|
click_signup_button
|
||||||
Site[username: @site[:username]].must_be_nil
|
_(Site[username: @site[:username]]).must_be_nil
|
||||||
current_path.must_equal '/'
|
_(current_path).must_equal '/'
|
||||||
page.wont_have_content 'Welcome to Neocities'
|
_(page).wont_have_content 'Welcome to Neocities'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to create for existing site' do
|
it 'fails to create for existing site' do
|
||||||
|
@ -85,41 +85,41 @@ describe 'signup' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'username', with: @existing_site.username
|
fill_in 'username', with: @existing_site.username
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'already taken'
|
_(page).must_have_content 'already taken'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with missing password' do
|
it 'fails with missing password' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'password', with: ''
|
fill_in 'password', with: ''
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'Password must be at least 5 characters'
|
_(page).must_have_content 'Password must be at least 5 characters'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with short password' do
|
it 'fails with short password' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'password', with: 'derp'
|
fill_in 'password', with: 'derp'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'Password must be at least 5 characters'
|
_(page).must_have_content 'Password must be at least 5 characters'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with invalid hostname for username' do
|
it 'fails with invalid hostname for username' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'username', with: '|\|0p|E'
|
fill_in 'username', with: '|\|0p|E'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'Usernames can only contain'
|
_(page).must_have_content 'Usernames can only contain'
|
||||||
fill_in 'username', with: 'nope-'
|
fill_in 'username', with: 'nope-'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'A valid user/site name is required'
|
_(page).must_have_content 'A valid user/site name is required'
|
||||||
fill_in 'username', with: '-nope'
|
fill_in 'username', with: '-nope'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'A valid user/site name is required'
|
_(page).must_have_content 'A valid user/site name is required'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with username greater than 32 characters' do
|
it 'fails with username greater than 32 characters' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'username', with: SecureRandom.hex+'1'
|
fill_in 'username', with: SecureRandom.hex+'1'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'cannot exceed 32 characters'
|
_(page).must_have_content 'cannot exceed 32 characters'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with existing email' do
|
it 'fails with existing email' do
|
||||||
|
@ -127,13 +127,13 @@ describe 'signup' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'email', with: email
|
fill_in 'email', with: email
|
||||||
click_signup_button
|
click_signup_button
|
||||||
site_created?.must_equal true
|
_(site_created?).must_equal true
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
visit_signup
|
visit_signup
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'email', with: email
|
fill_in 'email', with: email
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content /email.+exists/
|
_(page).must_have_content /email.+exists/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with existing email even if case sensitive' do
|
it 'fails with existing email even if case sensitive' do
|
||||||
|
@ -141,71 +141,71 @@ describe 'signup' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'email', with: email
|
fill_in 'email', with: email
|
||||||
click_signup_button
|
click_signup_button
|
||||||
site_created?.must_equal true
|
_(site_created?).must_equal true
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
visit_signup
|
visit_signup
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'email', with: email.upcase
|
fill_in 'email', with: email.upcase
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content /email.+exists/
|
_(page).must_have_content /email.+exists/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with no tags' do
|
it 'succeeds with no tags' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: ''
|
fill_in 'new_tags_string', with: ''
|
||||||
click_signup_button
|
click_signup_button
|
||||||
site_created?.must_equal true
|
_(site_created?).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with a single tag' do
|
it 'succeeds with a single tag' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: 'derpie'
|
fill_in 'new_tags_string', with: 'derpie'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
site_created?.must_equal true
|
_(site_created?).must_equal true
|
||||||
Site.last.tags.first.name.must_equal 'derpie'
|
_(Site.last.tags.first.name).must_equal 'derpie'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with valid tags' do
|
it 'succeeds with valid tags' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: 'derpie, shoujo'
|
fill_in 'new_tags_string', with: 'derpie, shoujo'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
site_created?.must_equal true
|
_(site_created?).must_equal true
|
||||||
Site.last.tags.collect {|t| t.name}.must_equal ['derpie', 'shoujo']
|
_(Site.last.tags.collect {|t| t.name}).must_equal ['derpie', 'shoujo']
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with invalid tag chars' do
|
it 'fails with invalid tag chars' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: '$POLICE OFFICER$$$$$, derp'
|
fill_in 'new_tags_string', with: '$POLICE OFFICER$$$$$, derp'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content /Tag.+can only contain/
|
_(page).must_have_content /Tag.+can only contain/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for tag with too many spaces' do
|
it 'fails for tag with too many spaces' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: 'police officer, hi'
|
fill_in 'new_tags_string', with: 'police officer, hi'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content /Tag.+cannot have spaces/
|
_(page).must_have_content /Tag.+cannot have spaces/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for tag with too many words' do
|
it 'fails for tag with too many words' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: 'police officer'
|
fill_in 'new_tags_string', with: 'police officer'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content /Tag.+cannot be more than #{Tag::NAME_WORDS_MAX} word/
|
_(page).must_have_content /Tag.+cannot be more than #{Tag::NAME_WORDS_MAX} word/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "fails for tag longer than #{Tag::NAME_LENGTH_MAX} characters" do
|
it "fails for tag longer than #{Tag::NAME_LENGTH_MAX} characters" do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: SecureRandom.hex(Tag::NAME_LENGTH_MAX)
|
fill_in 'new_tags_string', with: SecureRandom.hex(Tag::NAME_LENGTH_MAX)
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content /cannot be longer than #{Tag::NAME_LENGTH_MAX}/
|
_(page).must_have_content /cannot be longer than #{Tag::NAME_LENGTH_MAX}/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for too many tags' do
|
it 'fails for too many tags' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: 'one, two, three, four, five, six'
|
fill_in 'new_tags_string', with: 'one, two, three, four, five, six'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content /Cannot have more than \d tags for your site/
|
_(page).must_have_content /Cannot have more than \d tags for your site/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not duplicate tags' do
|
it 'does not duplicate tags' do
|
||||||
|
@ -213,10 +213,10 @@ describe 'signup' do
|
||||||
fill_in 'new_tags_string', with: 'one, one'
|
fill_in 'new_tags_string', with: 'one, one'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
|
|
||||||
page.must_have_content /Welcome to Neocities/
|
_(page).must_have_content /Welcome to Neocities/
|
||||||
|
|
||||||
site = Site[username: @site[:username]]
|
site = Site[username: @site[:username]]
|
||||||
site.tags.length.must_equal 1
|
_(site.tags.length).must_equal 1
|
||||||
site.tags.first.name.must_equal 'one'
|
_(site.tags.first.name).must_equal 'one'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,18 +19,18 @@ describe 'site page' do
|
||||||
it 'allows commenting' do
|
it 'allows commenting' do
|
||||||
fill_in 'message', with: 'I love your site!'
|
fill_in 'message', with: 'I love your site!'
|
||||||
click_button 'Post'
|
click_button 'Post'
|
||||||
@site.profile_comments.count.must_equal 1
|
_(@site.profile_comments.count).must_equal 1
|
||||||
profile_comment = @site.profile_comments.first
|
profile_comment = @site.profile_comments.first
|
||||||
profile_comment.actioning_site.id.must_equal @commenting_site.id
|
_(profile_comment.actioning_site.id).must_equal @commenting_site.id
|
||||||
profile_comment.message.must_equal 'I love your site!'
|
_(profile_comment.message).must_equal 'I love your site!'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not send comment email if not wished' do
|
it 'does not send comment email if not wished' do
|
||||||
@site.update send_comment_emails: false
|
@site.update send_comment_emails: false
|
||||||
fill_in 'message', with: 'I am annoying'
|
fill_in 'message', with: 'I am annoying'
|
||||||
click_button 'Post'
|
click_button 'Post'
|
||||||
@site.profile_comments.count.must_equal 1
|
_(@site.profile_comments.count).must_equal 1
|
||||||
EmailWorker.jobs.length.must_equal 0
|
_(EmailWorker.jobs.length).must_equal 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not send email if there is none' do
|
it 'does not send email if there is none' do
|
||||||
|
@ -38,7 +38,7 @@ describe 'site page' do
|
||||||
@site.save_changes validate: false
|
@site.save_changes validate: false
|
||||||
fill_in 'message', with: 'DERP'
|
fill_in 'message', with: 'DERP'
|
||||||
click_button 'Post'
|
click_button 'Post'
|
||||||
EmailWorker.jobs.length.must_equal 0
|
_(EmailWorker.jobs.length).must_equal 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,15 +52,15 @@ describe 'site page' do
|
||||||
|
|
||||||
it '404s for missing site' do
|
it '404s for missing site' do
|
||||||
visit '/site/failderp'
|
visit '/site/failderp'
|
||||||
page.status_code.must_equal 404
|
_(page.status_code).must_equal 404
|
||||||
page.must_have_content /not found/i
|
_(page).must_have_content /not found/i
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'loads site page' do
|
it 'loads site page' do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
visit "/site/#{site.username}"
|
visit "/site/#{site.username}"
|
||||||
page.status_code.must_equal 200
|
_(page.status_code).must_equal 200
|
||||||
page.must_have_content /#{site.username}/
|
_(page).must_have_content /#{site.username}/
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -74,7 +74,7 @@ describe 'site page' do
|
||||||
|
|
||||||
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}"
|
||||||
|
|
||||||
|
@ -83,11 +83,11 @@ describe 'site page' do
|
||||||
|
|
||||||
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
|
||||||
end
|
end
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ describe 'site page' do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
site.ban!
|
site.ban!
|
||||||
visit "/site/#{site.username}"
|
visit "/site/#{site.username}"
|
||||||
page.status_code.must_equal 404
|
_(page.status_code).must_equal 404
|
||||||
page.must_have_content /not found/i
|
_(page).must_have_content /not found/i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,9 +10,8 @@ describe '/supporter' do
|
||||||
@site = Fabricate :site
|
@site = Fabricate :site
|
||||||
@stripe_helper = StripeMock.create_test_helper
|
@stripe_helper = StripeMock.create_test_helper
|
||||||
StripeMock.start
|
StripeMock.start
|
||||||
@stripe_helper.create_plan id: 'special', amount: 0
|
@stripe_helper.create_product(id: 'supporter', name: 'Supporter')
|
||||||
@stripe_helper.create_plan id: 'supporter', amount: 500
|
@stripe_helper.create_plan product: 'supporter', amount: 500
|
||||||
@stripe_helper.create_plan id: 'free', amount: 0
|
|
||||||
page.set_rack_session id: @site.id
|
page.set_rack_session id: @site.id
|
||||||
EmailWorker.jobs.clear
|
EmailWorker.jobs.clear
|
||||||
Mail::TestMailer.deliveries.clear
|
Mail::TestMailer.deliveries.clear
|
||||||
|
@ -37,17 +36,17 @@ describe '/supporter' do
|
||||||
find('.cc-cvc').set '123'
|
find('.cc-cvc').set '123'
|
||||||
page.evaluate_script("document.getElementById('stripe_token').value = '#{@stripe_helper.generate_card_token}'")
|
page.evaluate_script("document.getElementById('stripe_token').value = '#{@stripe_helper.generate_card_token}'")
|
||||||
click_link 'Upgrade for $5/mo'
|
click_link 'Upgrade for $5/mo'
|
||||||
page.current_path.must_equal '/supporter/thanks'
|
_(page.current_path).must_equal '/supporter/thanks'
|
||||||
all('.txt-Center')
|
all('.txt-Center')
|
||||||
page.body.must_match /You have become a Neocities Supporter/
|
_(page.body).must_match /You have become a Neocities Supporter/
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.stripe_customer_id.wont_be_nil
|
_(@site.stripe_customer_id).wont_be_nil
|
||||||
@site.stripe_subscription_id.wont_be_nil
|
_(@site.stripe_subscription_id).wont_be_nil
|
||||||
@site.values[:plan_type].must_equal 'supporter'
|
_(@site.values[:plan_type]).must_equal 'supporter'
|
||||||
@site.supporter?.must_equal true
|
_(@site.supporter?).must_equal true
|
||||||
|
|
||||||
EmailWorker.drain
|
EmailWorker.drain
|
||||||
mail = Mail::TestMailer.deliveries.first
|
mail = Mail::TestMailer.deliveries.first
|
||||||
mail.subject.must_match "You've become a supporter"
|
_(mail.subject).must_match "You've become a supporter"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,9 +26,9 @@ describe 'api' do
|
||||||
describe 'not found' do
|
describe 'not found' do
|
||||||
it 'returns json for missing route' do
|
it 'returns json for missing route' do
|
||||||
get '/api/sdlfkjsdlfjds'
|
get '/api/sdlfkjsdlfjds'
|
||||||
last_response.status.must_equal 404
|
_(last_response.status).must_equal 404
|
||||||
res[:result].must_equal 'error'
|
_(res[:result]).must_equal 'error'
|
||||||
res[:error_type].must_equal 'not_found'
|
_(res[:error_type]).must_equal 'not_found'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,15 +38,15 @@ describe 'api' do
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
get '/api/list'
|
get '/api/list'
|
||||||
|
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
res[:files].length.must_equal @site.site_files.length
|
_(res[:files].length).must_equal @site.site_files.length
|
||||||
|
|
||||||
res[:files].each do |file|
|
res[:files].each do |file|
|
||||||
site_file = @site.site_files.select {|s| s[:path] == file[:path]}.first
|
site_file = @site.site_files.select {|s| s[:path] == file[:path]}.first
|
||||||
site_file[:is_directory].must_equal file[:is_directory]
|
_(site_file[:is_directory]).must_equal file[:is_directory]
|
||||||
site_file[:size].must_equal file[:size]
|
_(site_file[:size]).must_equal file[:size]
|
||||||
site_file[:updated_at].rfc2822.must_equal file[:updated_at]
|
_(site_file[:updated_at].rfc2822).must_equal file[:updated_at]
|
||||||
site_file[:sha1_hash].must_equal file[:sha1_hash]
|
_(site_file[:sha1_hash]).must_equal file[:sha1_hash]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ describe 'api' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
get '/api/list', path: '/fail'
|
get '/api/list', path: '/fail'
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
res[:files].must_equal []
|
_(res[:files]).must_equal []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows files in path' do
|
it 'shows files in path' do
|
||||||
|
@ -65,11 +65,11 @@ describe 'api' do
|
||||||
@site.store_files [{filename: '/derp/test.html', tempfile: tempfile}]
|
@site.store_files [{filename: '/derp/test.html', tempfile: tempfile}]
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
get '/api/list', path: '/derp'
|
get '/api/list', path: '/derp'
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
res[:files].length.must_equal 1
|
_(res[:files].length).must_equal 1
|
||||||
file = res[:files].first
|
file = res[:files].first
|
||||||
file[:path].must_equal 'derp/test.html'
|
_(file[:path]).must_equal 'derp/test.html'
|
||||||
file[:updated_at].must_equal @site.site_files.select {|s| s.path == 'derp/test.html'}.first.updated_at.rfc2822
|
_(file[:updated_at]).must_equal @site.site_files.select {|s| s.path == 'derp/test.html'}.first.updated_at.rfc2822
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -83,13 +83,13 @@ describe 'api' do
|
||||||
create_site
|
create_site
|
||||||
@site.update is_banned: true
|
@site.update is_banned: true
|
||||||
get '/api/info', sitename: @site.username
|
get '/api/info', sitename: @site.username
|
||||||
res[:error_type].must_equal 'site_not_found'
|
_(res[:error_type]).must_equal 'site_not_found'
|
||||||
@site.reload.api_calls.must_equal 0
|
_(@site.reload.api_calls).must_equal 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for nonexistent site' do
|
it 'fails for nonexistent site' do
|
||||||
get '/api/info', sitename: 'notexist'
|
get '/api/info', sitename: 'notexist'
|
||||||
res[:error_type].must_equal 'site_not_found'
|
_(res[:error_type]).must_equal 'site_not_found'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds for valid sitename' do
|
it 'succeeds for valid sitename' do
|
||||||
|
@ -97,27 +97,27 @@ describe 'api' do
|
||||||
@site.update hits: 31337, domain: 'derp.com', new_tags_string: 'derpie, man'
|
@site.update hits: 31337, domain: 'derp.com', new_tags_string: 'derpie, man'
|
||||||
@site.add_archive ipfs_hash: 'QmXGTaGWTT1uUtfSb2sBAvArMEVLK4rQEcQg5bv7wwdzwU'
|
@site.add_archive ipfs_hash: 'QmXGTaGWTT1uUtfSb2sBAvArMEVLK4rQEcQg5bv7wwdzwU'
|
||||||
get '/api/info', sitename: @user
|
get '/api/info', sitename: @user
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
res[:info][:sitename].must_equal @site.username
|
_(res[:info][:sitename]).must_equal @site.username
|
||||||
res[:info][:hits].must_equal 31337
|
_(res[:info][:hits]).must_equal 31337
|
||||||
res[:info][:created_at].must_equal @site.created_at.rfc2822
|
_(res[:info][:created_at]).must_equal @site.created_at.rfc2822
|
||||||
res[:info][:last_updated].must_be_nil
|
_(res[:info][:last_updated]).must_be_nil
|
||||||
res[:info][:domain].must_equal 'derp.com'
|
_(res[:info][:domain]).must_equal 'derp.com'
|
||||||
res[:info][:tags].must_equal ['derpie', 'man']
|
_(res[:info][:tags]).must_equal ['derpie', 'man']
|
||||||
res[:info][:latest_ipfs_hash].must_equal 'QmXGTaGWTT1uUtfSb2sBAvArMEVLK4rQEcQg5bv7wwdzwU'
|
_(res[:info][:latest_ipfs_hash]).must_equal 'QmXGTaGWTT1uUtfSb2sBAvArMEVLK4rQEcQg5bv7wwdzwU'
|
||||||
@site.reload.api_calls.must_equal 0
|
_(@site.reload.api_calls).must_equal 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'shows latest ipfs hash as nil when not present' do
|
it 'shows latest ipfs hash as nil when not present' do
|
||||||
create_site
|
create_site
|
||||||
get '/api/info', sitename: @user
|
get '/api/info', sitename: @user
|
||||||
res[:info][:latest_ipfs_hash].must_be_nil
|
_(res[:info][:latest_ipfs_hash]).must_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for bad auth' do
|
it 'fails for bad auth' do
|
||||||
basic_authorize 'derp', 'fake'
|
basic_authorize 'derp', 'fake'
|
||||||
get '/api/info'
|
get '/api/info'
|
||||||
res[:error_type].must_equal 'invalid_auth'
|
_(res[:error_type]).must_equal 'invalid_auth'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds for api auth' do
|
it 'succeeds for api auth' do
|
||||||
|
@ -132,25 +132,25 @@ describe 'api' do
|
||||||
describe 'delete' do
|
describe 'delete' do
|
||||||
it 'fails with no or bad auth' do
|
it 'fails with no or bad auth' do
|
||||||
post '/api/delete', filenames: ['hi.html']
|
post '/api/delete', filenames: ['hi.html']
|
||||||
res[:error_type].must_equal 'invalid_auth'
|
_(res[:error_type]).must_equal 'invalid_auth'
|
||||||
create_site
|
create_site
|
||||||
basic_authorize 'derp', 'fake'
|
basic_authorize 'derp', 'fake'
|
||||||
post '/api/delete', filenames: ['hi.html']
|
post '/api/delete', filenames: ['hi.html']
|
||||||
res[:error_type].must_equal 'invalid_auth'
|
_(res[:error_type]).must_equal 'invalid_auth'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with missing filename argument' do
|
it 'fails with missing filename argument' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/delete'
|
post '/api/delete'
|
||||||
res[:error_type].must_equal 'missing_filenames'
|
_(res[:error_type]).must_equal 'missing_filenames'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to delete index.html' do
|
it 'fails to delete index.html' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/delete', filenames: ['index.html']
|
post '/api/delete', filenames: ['index.html']
|
||||||
res[:error_type].must_equal 'cannot_delete_index'
|
_(res[:error_type]).must_equal 'cannot_delete_index'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with weird filenames' do
|
it 'succeeds with weird filenames' do
|
||||||
|
@ -158,12 +158,12 @@ describe 'api' do
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
@site.store_files [{filename: 't$st.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
@site.store_files [{filename: 't$st.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
||||||
post '/api/delete', filenames: ['t$st.jpg']
|
post '/api/delete', filenames: ['t$st.jpg']
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
|
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/delete', filenames: ['./config.yml']
|
post '/api/delete', filenames: ['./config.yml']
|
||||||
res[:error_type].must_equal 'missing_files'
|
_(res[:error_type]).must_equal 'missing_files'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with missing files' do
|
it 'fails with missing files' do
|
||||||
|
@ -171,15 +171,15 @@ describe 'api' do
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
@site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
@site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
||||||
post '/api/delete', filenames: ['doesntexist.jpg']
|
post '/api/delete', filenames: ['doesntexist.jpg']
|
||||||
res[:error_type].must_equal 'missing_files'
|
_(res[:error_type]).must_equal 'missing_files'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to delete site directory' do
|
it 'fails to delete site directory' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/delete', filenames: ['/']
|
post '/api/delete', filenames: ['/']
|
||||||
res[:error_type].must_equal 'cannot_delete_site_directory'
|
_(res[:error_type]).must_equal 'cannot_delete_site_directory'
|
||||||
File.exist?(@site.files_path).must_equal true
|
_(File.exist?(@site.files_path)).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to delete other directories' do
|
it 'fails to delete other directories' do
|
||||||
|
@ -188,11 +188,11 @@ describe 'api' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/delete', filenames: ["../#{@other_site.username}"]
|
post '/api/delete', filenames: ["../#{@other_site.username}"]
|
||||||
File.exist?(@other_site.base_files_path).must_equal true
|
_(File.exist?(@other_site.base_files_path)).must_equal true
|
||||||
res[:error_type].must_equal 'missing_files'
|
_(res[:error_type]).must_equal 'missing_files'
|
||||||
post '/api/delete', filenames: ["../#{@other_site.username}/index.html"]
|
post '/api/delete', filenames: ["../#{@other_site.username}/index.html"]
|
||||||
File.exist?(@other_site.base_files_path+'/index.html').must_equal true
|
_(File.exist?(@other_site.base_files_path+'/index.html')).must_equal true
|
||||||
res[:error_type].must_equal 'missing_files'
|
_(res[:error_type]).must_equal 'missing_files'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with valid filenames' do
|
it 'succeeds with valid filenames' do
|
||||||
|
@ -201,9 +201,9 @@ describe 'api' do
|
||||||
@site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
@site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
||||||
@site.store_files [{filename: 'test2.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
@site.store_files [{filename: 'test2.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
||||||
post '/api/delete', filenames: ['test.jpg', 'test2.jpg']
|
post '/api/delete', filenames: ['test.jpg', 'test2.jpg']
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
site_file_exists?('test.jpg').must_equal false
|
_(site_file_exists?('test.jpg')).must_equal false
|
||||||
site_file_exists?('test2.jpg').must_equal false
|
_(site_file_exists?('test2.jpg')).must_equal false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ describe 'api' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
get '/api/key'
|
get '/api/key'
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
res[:api_key].must_equal @site.reload.api_key
|
_(res[:api_key]).must_equal @site.reload.api_key
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns existing key' do
|
it 'returns existing key' do
|
||||||
|
@ -221,14 +221,14 @@ describe 'api' do
|
||||||
@site.generate_api_key!
|
@site.generate_api_key!
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
get '/api/key'
|
get '/api/key'
|
||||||
res[:api_key].must_equal @site.api_key
|
_(res[:api_key]).must_equal @site.api_key
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for bad login' do
|
it 'fails for bad login' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize 'zero', 'cool'
|
basic_authorize 'zero', 'cool'
|
||||||
get '/api/key'
|
get '/api/key'
|
||||||
res[:error_type].must_equal 'invalid_auth'
|
_(res[:error_type]).must_equal 'invalid_auth'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -245,9 +245,9 @@ describe 'api' do
|
||||||
|
|
||||||
post '/api/upload_hash', "test.jpg" => test_hash, "test2.jpg" => Digest::SHA1.hexdigest('herpderp')
|
post '/api/upload_hash', "test.jpg" => test_hash, "test2.jpg" => Digest::SHA1.hexdigest('herpderp')
|
||||||
|
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
res[:files][:'test.jpg'].must_equal true
|
_(res[:files][:'test.jpg']).must_equal true
|
||||||
res[:files][:'test2.jpg'].must_equal false
|
_(res[:files][:'test2.jpg']).must_equal false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -262,58 +262,58 @@ describe 'api' do
|
||||||
|
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
post '/api/rename', path: 'testdir/test.jpg', new_path: 'testdir/test2.jpg'
|
post '/api/rename', path: 'testdir/test.jpg', new_path: 'testdir/test2.jpg'
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to overwrite index file' do
|
it 'fails to overwrite index file' do
|
||||||
post '/api/rename', path: 'testdir/test.jpg', new_path: 'index.html'
|
post '/api/rename', path: 'testdir/test.jpg', new_path: 'index.html'
|
||||||
res[:result].must_equal 'error'
|
_(res[:result]).must_equal 'error'
|
||||||
res[:error_type].must_equal 'rename_error'
|
_(res[:error_type]).must_equal 'rename_error'
|
||||||
res[:message].must_equal 'file already exists'
|
_(res[:message]).must_equal 'file already exists'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to overwrite existing file' do
|
it 'fails to overwrite existing file' do
|
||||||
post '/api/rename', path: 'testdir/test.jpg', new_path: 'not_found.html'
|
post '/api/rename', path: 'testdir/test.jpg', new_path: 'not_found.html'
|
||||||
res[:result].must_equal 'error'
|
_(res[:result]).must_equal 'error'
|
||||||
res[:error_type].must_equal 'rename_error'
|
_(res[:error_type]).must_equal 'rename_error'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with directory' do
|
it 'succeeds with directory' do
|
||||||
@site.create_directory 'derpiedir'
|
@site.create_directory 'derpiedir'
|
||||||
post '/api/rename', path: 'derpiedir', new_path: 'notderpiedir'
|
post '/api/rename', path: 'derpiedir', new_path: 'notderpiedir'
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'upload' do
|
describe 'upload' do
|
||||||
it 'fails with no auth' do
|
it 'fails with no auth' do
|
||||||
post '/api/upload'
|
post '/api/upload'
|
||||||
res[:result].must_equal 'error'
|
_(res[:result]).must_equal 'error'
|
||||||
res[:error_type].must_equal 'invalid_auth'
|
_(res[:error_type]).must_equal 'invalid_auth'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for bad auth' do
|
it 'fails for bad auth' do
|
||||||
basic_authorize 'username', 'password'
|
basic_authorize 'username', 'password'
|
||||||
post '/api/upload'
|
post '/api/upload'
|
||||||
res[:error_type].must_equal 'invalid_auth'
|
_(res[:error_type]).must_equal 'invalid_auth'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with missing files' do
|
it 'fails with missing files' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/upload'
|
post '/api/upload'
|
||||||
res[:error_type].must_equal 'missing_files'
|
_(res[:error_type]).must_equal 'missing_files'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with valid api key' do
|
it 'succeeds with valid api key' do
|
||||||
create_site
|
create_site
|
||||||
@site.api_key.must_be_nil
|
_(@site.api_key).must_be_nil
|
||||||
@site.generate_api_key!
|
@site.generate_api_key!
|
||||||
@site.reload.api_key.wont_equal nil
|
_(@site.reload.api_key).wont_equal nil
|
||||||
header 'Authorization', "Bearer #{@site.api_key}"
|
header 'Authorization', "Bearer #{@site.api_key}"
|
||||||
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
site_file_exists?('test.jpg').must_equal true
|
_(site_file_exists?('test.jpg')).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with bad api key' do
|
it 'fails with bad api key' do
|
||||||
|
@ -321,8 +321,8 @@ describe 'api' do
|
||||||
@site.generate_api_key!
|
@site.generate_api_key!
|
||||||
header 'Authorization', "Bearer zerocool"
|
header 'Authorization', "Bearer zerocool"
|
||||||
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
res[:result].must_equal 'error'
|
_(res[:result]).must_equal 'error'
|
||||||
res[:error_type].must_equal 'invalid_auth'
|
_(res[:error_type]).must_equal 'invalid_auth'
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -337,7 +337,7 @@ describe 'api' do
|
||||||
post '/api/upload', {
|
post '/api/upload', {
|
||||||
'/lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'/lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:error_type].must_equal 'too_many_files'
|
_(res[:error_type]).must_equal 'too_many_files'
|
||||||
end
|
end
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -347,9 +347,9 @@ describe 'api' do
|
||||||
post '/api/upload', {
|
post '/api/upload', {
|
||||||
'../lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'../lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
File.exist?(File.join(Site::SITE_FILES_ROOT, Site.sharding_dir(@site.username), @site.username, 'lol.jpg')).must_equal true
|
_(File.exist?(File.join(Site::SITE_FILES_ROOT, Site.sharding_dir(@site.username), @site.username, 'lol.jpg'))).must_equal true
|
||||||
@site.reload.api_calls.must_equal 1
|
_(@site.reload.api_calls).must_equal 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'scrubs root path slash' do
|
it 'scrubs root path slash' do
|
||||||
|
@ -358,8 +358,8 @@ describe 'api' do
|
||||||
post '/api/upload', {
|
post '/api/upload', {
|
||||||
'/lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'/lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
File.exist?(File.join(Site::SITE_FILES_ROOT, Site.sharding_dir(@site.username), @site.username, 'lol.jpg')).must_equal true
|
_(File.exist?(File.join(Site::SITE_FILES_ROOT, Site.sharding_dir(@site.username), @site.username, 'lol.jpg'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for missing file name' do
|
it 'fails for missing file name' do
|
||||||
|
@ -368,7 +368,7 @@ describe 'api' do
|
||||||
post '/api/upload', {
|
post '/api/upload', {
|
||||||
'/' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'/' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:error_type].must_equal 'invalid_file_type'
|
_(res[:error_type]).must_equal 'invalid_file_type'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for file with no extension' do
|
it 'fails for file with no extension' do
|
||||||
|
@ -377,7 +377,7 @@ describe 'api' do
|
||||||
post '/api/upload', {
|
post '/api/upload', {
|
||||||
'derpie' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'derpie' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:error_type].must_equal 'invalid_file_type'
|
_(res[:error_type]).must_equal 'invalid_file_type'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates path for file uploads' do
|
it 'creates path for file uploads' do
|
||||||
|
@ -386,8 +386,8 @@ describe 'api' do
|
||||||
post '/api/upload', {
|
post '/api/upload', {
|
||||||
'derpie/derpingtons/lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'derpie/derpingtons/lol.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
File.exist?(@site.files_path('derpie/derpingtons/lol.jpg')).must_equal true
|
_(File.exist?(@site.files_path('derpie/derpingtons/lol.jpg'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'records api calls that require auth' do
|
it 'records api calls that require auth' do
|
||||||
|
@ -400,7 +400,7 @@ describe 'api' do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@site.reload.api_calls.must_equal 2
|
_(@site.reload.api_calls).must_equal 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for invalid files' do
|
it 'fails for invalid files' do
|
||||||
|
@ -410,17 +410,17 @@ describe 'api' do
|
||||||
'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg'),
|
'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg'),
|
||||||
'nord.avi' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'image/jpeg')
|
'nord.avi' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:error_type].must_equal 'invalid_file_type'
|
_(res[:error_type]).must_equal 'invalid_file_type'
|
||||||
site_file_exists?('test.jpg').must_equal false
|
_(site_file_exists?('test.jpg')).must_equal false
|
||||||
site_file_exists?('nord.avi').must_equal false
|
_(site_file_exists?('nord.avi')).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with single file' do
|
it 'succeeds with single file' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
post '/api/upload', 'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
site_file_exists?('test.jpg').must_equal true
|
_(site_file_exists?('test.jpg')).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with two files' do
|
it 'succeeds with two files' do
|
||||||
|
@ -430,18 +430,18 @@ describe 'api' do
|
||||||
'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg'),
|
'test.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg'),
|
||||||
'test2.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'test2.jpg' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
site_file_exists?('test.jpg').must_equal true
|
_(site_file_exists?('test.jpg')).must_equal true
|
||||||
site_file_exists?('test2.jpg').must_equal true
|
_(site_file_exists?('test2.jpg')).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with unwhitelisted file' do
|
it 'fails with unwhitelisted file' do
|
||||||
create_site
|
create_site
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/upload', 'flowercrime.wav' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
post '/api/upload', 'flowercrime.wav' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
||||||
res[:result].must_equal 'error'
|
_(res[:result]).must_equal 'error'
|
||||||
res[:error_type].must_equal 'invalid_file_type'
|
_(res[:error_type]).must_equal 'invalid_file_type'
|
||||||
site_file_exists?('flowercrime.wav').must_equal false
|
_(site_file_exists?('flowercrime.wav')).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds for unwhitelisted file on supported plans' do
|
it 'succeeds for unwhitelisted file on supported plans' do
|
||||||
|
@ -450,8 +450,8 @@ describe 'api' do
|
||||||
create_site plan_type: plan_type
|
create_site plan_type: plan_type
|
||||||
basic_authorize @user, @pass
|
basic_authorize @user, @pass
|
||||||
post '/api/upload', 'flowercrime.wav' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
post '/api/upload', 'flowercrime.wav' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
||||||
res[:result].must_equal 'success'
|
_(res[:result]).must_equal 'success'
|
||||||
site_file_exists?('flowercrime.wav').must_equal true
|
_(site_file_exists?('flowercrime.wav')).must_equal true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_relative './environment.rb'
|
||||||
describe Time do
|
describe Time do
|
||||||
describe 'ago' do
|
describe 'ago' do
|
||||||
it 'should return the modified value' do
|
it 'should return the modified value' do
|
||||||
Time.now.ago.must_equal 'just now'
|
_(Time.now.ago).must_equal 'just now'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -34,11 +34,11 @@ describe 'site_files' do
|
||||||
upload 'files[]' => uploaded_file
|
upload 'files[]' => uploaded_file
|
||||||
|
|
||||||
testfile = @site.site_files_dataset.where(path: 'test.jpg').first
|
testfile = @site.site_files_dataset.where(path: 'test.jpg').first
|
||||||
testfile.wont_equal nil
|
_(testfile).wont_equal nil
|
||||||
testfile.rename 'derp.jpg'
|
testfile.rename 'derp.jpg'
|
||||||
@site.site_files_dataset.where(path: 'derp.jpg').first.wont_equal nil
|
_(@site.site_files_dataset.where(path: 'derp.jpg').first).wont_equal nil
|
||||||
PurgeCacheWorker.jobs.first['args'].last.must_equal '/test.jpg'
|
_(PurgeCacheWorker.jobs.first['args'].last).must_equal '/test.jpg'
|
||||||
File.exist?(@site.files_path('derp.jpg')).must_equal true
|
_(File.exist?(@site.files_path('derp.jpg'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for bad extension change' do
|
it 'fails for bad extension change' do
|
||||||
|
@ -47,8 +47,8 @@ describe 'site_files' do
|
||||||
|
|
||||||
testfile = @site.site_files_dataset.where(path: 'test.jpg').first
|
testfile = @site.site_files_dataset.where(path: 'test.jpg').first
|
||||||
res = testfile.rename('dasharezone.exe')
|
res = testfile.rename('dasharezone.exe')
|
||||||
res.must_equal [false, 'unsupported file type']
|
_(res).must_equal [false, 'unsupported file type']
|
||||||
@site.site_files_dataset.where(path: 'test.jpg').first.wont_equal nil
|
_(@site.site_files_dataset.where(path: 'test.jpg').first).wont_equal nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renames nonstandard file type for supporters' do
|
it 'renames nonstandard file type for supporters' do
|
||||||
|
@ -58,27 +58,27 @@ describe 'site_files' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
||||||
testfile = @site.site_files_dataset.where(path: 'flowercrime.wav').first
|
testfile = @site.site_files_dataset.where(path: 'flowercrime.wav').first
|
||||||
res = testfile.rename('flowercrime.exe')
|
res = testfile.rename('flowercrime.exe')
|
||||||
res.first.must_equal true
|
_(res.first).must_equal true
|
||||||
File.exists?(@site.files_path('flowercrime.exe')).must_equal true
|
_(File.exists?(@site.files_path('flowercrime.exe'))).must_equal true
|
||||||
@site.site_files_dataset.where(path: 'flowercrime.exe').first.wont_equal nil
|
_(@site.site_files_dataset.where(path: 'flowercrime.exe').first).wont_equal nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'works for directory' do
|
it 'works for directory' do
|
||||||
@site.create_directory 'dirone'
|
@site.create_directory 'dirone'
|
||||||
@site.site_files.select {|sf| sf.path == 'dirone'}.length.must_equal 1
|
_(@site.site_files.select {|sf| sf.path == 'dirone'}.length).must_equal 1
|
||||||
|
|
||||||
dirone = @site.site_files_dataset.where(path: 'dirone').first
|
dirone = @site.site_files_dataset.where(path: 'dirone').first
|
||||||
dirone.wont_equal nil
|
_(dirone).wont_equal nil
|
||||||
dirone.is_directory.must_equal true
|
_(dirone.is_directory).must_equal true
|
||||||
res = dirone.rename('dasharezone')
|
res = dirone.rename('dasharezone')
|
||||||
res.must_equal [true, nil]
|
_(res).must_equal [true, nil]
|
||||||
dasharezone = @site.site_files_dataset.where(path: 'dasharezone').first
|
dasharezone = @site.site_files_dataset.where(path: 'dasharezone').first
|
||||||
dasharezone.wont_equal nil
|
_(dasharezone).wont_equal nil
|
||||||
dasharezone.is_directory.must_equal true
|
_(dasharezone.is_directory).must_equal true
|
||||||
|
|
||||||
PurgeCacheWorker.jobs.first['args'].last.must_equal 'dirone'
|
_(PurgeCacheWorker.jobs.first['args'].last).must_equal 'dirone'
|
||||||
PurgeCacheWorker.jobs.last['args'].last.must_equal 'dasharezone'
|
_(PurgeCacheWorker.jobs.last['args'].last).must_equal 'dasharezone'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'changes path of files and dirs within directory when changed' do
|
it 'changes path of files and dirs within directory when changed' do
|
||||||
|
@ -92,11 +92,11 @@ describe 'site_files' do
|
||||||
)
|
)
|
||||||
|
|
||||||
@site.site_files.select {|s| s.path == 'test'}.first.rename('test2')
|
@site.site_files.select {|s| s.path == 'test'}.first.rename('test2')
|
||||||
@site.site_files.select {|sf| sf.path =~ /test2\/index.html/}.length.must_equal 1
|
_(@site.site_files.select {|sf| sf.path =~ /test2\/index.html/}.length).must_equal 1
|
||||||
@site.site_files.select {|sf| sf.path =~ /test2\/test.jpg/}.length.must_equal 1
|
_(@site.site_files.select {|sf| sf.path =~ /test2\/test.jpg/}.length).must_equal 1
|
||||||
@site.site_files.select {|sf| sf.path =~ /test\/test.jpg/}.length.must_equal 0
|
_(@site.site_files.select {|sf| sf.path =~ /test\/test.jpg/}.length).must_equal 0
|
||||||
|
|
||||||
PurgeCacheWorker.jobs.collect {|p| p['args'].last}.sort.must_equal ["/test/test.jpg", "/test/index.html", "/test/", "test", "test2", "test/test.jpg", "test2/test.jpg", "test/index.html", "test/", "test2/index.html", "test2/"].sort
|
_(PurgeCacheWorker.jobs.collect {|p| p['args'].last}.sort).must_equal ["/test/test.jpg", "/test/index.html", "/test/", "test", "test2", "test/test.jpg", "test2/test.jpg", "test/index.html", "test/", "test2/index.html", "test2/"].sort
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'doesnt wipe out existing file' do
|
it 'doesnt wipe out existing file' do
|
||||||
|
@ -110,35 +110,35 @@ describe 'site_files' do
|
||||||
)
|
)
|
||||||
|
|
||||||
res = @site.site_files_dataset.where(path: 'test/index.html').first.rename('test/test.jpg')
|
res = @site.site_files_dataset.where(path: 'test/index.html').first.rename('test/test.jpg')
|
||||||
res.must_equal [false, 'file already exists']
|
_(res).must_equal [false, 'file already exists']
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'doesnt wipe out existing dir' do
|
it 'doesnt wipe out existing dir' do
|
||||||
@site.create_directory 'dirone'
|
@site.create_directory 'dirone'
|
||||||
@site.create_directory 'dirtwo'
|
@site.create_directory 'dirtwo'
|
||||||
res = @site.site_files.select{|sf| sf.path == 'dirtwo'}.first.rename 'dirone'
|
res = @site.site_files.select{|sf| sf.path == 'dirtwo'}.first.rename 'dirone'
|
||||||
res.must_equal [false, 'directory already exists']
|
_(res).must_equal [false, 'directory already exists']
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'refuses to move index.html' do
|
it 'refuses to move index.html' do
|
||||||
res = @site.site_files.select {|sf| sf.path == 'index.html'}.first.rename('notindex.html')
|
res = @site.site_files.select {|sf| sf.path == 'index.html'}.first.rename('notindex.html')
|
||||||
res.must_equal [false, 'cannot rename or move root index.html']
|
_(res).must_equal [false, 'cannot rename or move root index.html']
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'works with unicode characters' do
|
it 'works with unicode characters' do
|
||||||
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
upload 'files[]' => uploaded_file
|
upload 'files[]' => uploaded_file
|
||||||
@site.site_files_dataset.where(path: 'test.jpg').first.rename("HELL💩؋.jpg")
|
@site.site_files_dataset.where(path: 'test.jpg').first.rename("HELL💩؋.jpg")
|
||||||
@site.site_files_dataset.where(path: "HELL💩؋.jpg").first.wont_equal nil
|
_(@site.site_files_dataset.where(path: "HELL💩؋.jpg").first).wont_equal nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'scrubs weird carriage return shit characters' do
|
it 'scrubs weird carriage return shit characters' do
|
||||||
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
upload 'files[]' => uploaded_file
|
upload 'files[]' => uploaded_file
|
||||||
proc {
|
_(proc {
|
||||||
@site.site_files_dataset.where(path: 'test.jpg').first.rename("\r\n\t.jpg")
|
@site.site_files_dataset.where(path: 'test.jpg').first.rename("\r\n\t.jpg")
|
||||||
}.must_raise ArgumentError
|
}).must_raise ArgumentError
|
||||||
@site.site_files_dataset.where(path: 'test.jpg').first.wont_equal nil
|
_(_(@site.site_files_dataset.where(path: 'test.jpg').first)).wont_equal nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -154,26 +154,26 @@ describe 'site_files' do
|
||||||
|
|
||||||
PurgeCacheWorker.jobs.clear
|
PurgeCacheWorker.jobs.clear
|
||||||
|
|
||||||
@site.reload.space_used.must_equal initial_space_used + uploaded_file.size
|
_(@site.reload.space_used).must_equal initial_space_used + uploaded_file.size
|
||||||
@site.actual_space_used.must_equal @site.space_used
|
_(@site.actual_space_used).must_equal @site.space_used
|
||||||
file_path = @site.files_path 'test.jpg'
|
file_path = @site.files_path 'test.jpg'
|
||||||
File.exists?(file_path).must_equal true
|
_(File.exists?(file_path)).must_equal true
|
||||||
delete_file filename: 'test.jpg'
|
delete_file filename: 'test.jpg'
|
||||||
|
|
||||||
File.exists?(file_path).must_equal false
|
_(File.exists?(file_path)).must_equal false
|
||||||
SiteFile[site_id: @site.id, path: 'test.jpg'].must_be_nil
|
_(SiteFile[site_id: @site.id, path: 'test.jpg']).must_be_nil
|
||||||
@site.reload.space_used.must_equal initial_space_used
|
_(@site.reload.space_used).must_equal initial_space_used
|
||||||
@site.actual_space_used.must_equal @site.space_used
|
_(@site.actual_space_used).must_equal @site.space_used
|
||||||
|
|
||||||
args = PurgeCacheWorker.jobs.first['args']
|
args = PurgeCacheWorker.jobs.first['args']
|
||||||
args[0].must_equal @site.username
|
_(args[0]).must_equal @site.username
|
||||||
args[1].must_equal '/test.jpg'
|
_(args[1]).must_equal '/test.jpg'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'property deletes directories with regexp special chars in them' do
|
it 'property deletes directories with regexp special chars in them' do
|
||||||
upload 'dir' => '8)', 'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
upload 'dir' => '8)', 'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
delete_file filename: '8)'
|
delete_file filename: '8)'
|
||||||
@site.reload.site_files.select {|f| f.path =~ /#{Regexp.quote '8)'}/}.length.must_equal 0
|
_(@site.reload.site_files.select {|f| f.path =~ /#{Regexp.quote '8)'}/}.length).must_equal 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes with escaped apostrophe' do
|
it 'deletes with escaped apostrophe' do
|
||||||
|
@ -181,9 +181,9 @@ describe 'site_files' do
|
||||||
'dir' => "test'ing",
|
'dir' => "test'ing",
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
)
|
)
|
||||||
@site.reload.site_files.select {|s| s.path == "test'ing"}.length.must_equal 1
|
_(@site.reload.site_files.select {|s| s.path == "test'ing"}.length).must_equal 1
|
||||||
delete_file filename: "test'ing"
|
delete_file filename: "test'ing"
|
||||||
@site.reload.site_files.select {|s| s.path == "test'ing"}.length.must_equal 0
|
_(@site.reload.site_files.select {|s| s.path == "test'ing"}.length).must_equal 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes a directory and all files in it' do
|
it 'deletes a directory and all files in it' do
|
||||||
|
@ -199,11 +199,11 @@ describe 'site_files' do
|
||||||
space_used = @site.reload.space_used
|
space_used = @site.reload.space_used
|
||||||
delete_file filename: 'test'
|
delete_file filename: 'test'
|
||||||
|
|
||||||
@site.reload.space_used.must_equal(space_used - File.size('./tests/files/test.jpg'))
|
_(@site.reload.space_used).must_equal(space_used - File.size('./tests/files/test.jpg'))
|
||||||
|
|
||||||
@site.site_files.select {|f| f.path == 'test'}.length.must_equal 0
|
_(@site.site_files.select {|f| f.path == 'test'}.length).must_equal 0
|
||||||
@site.site_files.select {|f| f.path =~ /^test\//}.length.must_equal 0
|
_(@site.site_files.select {|f| f.path =~ /^test\//}.length).must_equal 0
|
||||||
@site.site_files.select {|f| f.path =~ /^test.jpg/}.length.must_equal 1
|
_(@site.site_files.select {|f| f.path =~ /^test.jpg/}.length).must_equal 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes records for nested directories' do
|
it 'deletes records for nested directories' do
|
||||||
|
@ -215,7 +215,7 @@ describe 'site_files' do
|
||||||
expected_site_file_paths = ['derp', 'derp/ing', 'derp/ing/tons', 'derp/ing/tons/test.jpg']
|
expected_site_file_paths = ['derp', 'derp/ing', 'derp/ing/tons', 'derp/ing/tons/test.jpg']
|
||||||
|
|
||||||
expected_site_file_paths.each do |path|
|
expected_site_file_paths.each do |path|
|
||||||
@site.site_files.select {|f| f.path == path}.length.must_equal 1
|
_(@site.site_files.select {|f| f.path == path}.length).must_equal 1
|
||||||
end
|
end
|
||||||
|
|
||||||
delete_file filename: 'derp'
|
delete_file filename: 'derp'
|
||||||
|
@ -223,7 +223,7 @@ describe 'site_files' do
|
||||||
@site.reload
|
@site.reload
|
||||||
|
|
||||||
expected_site_file_paths.each do |path|
|
expected_site_file_paths.each do |path|
|
||||||
@site.site_files.select {|f| f.path == path}.length.must_equal 0
|
_(@site.site_files.select {|f| f.path == path}.length).must_equal 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -233,71 +233,71 @@ describe 'site_files' do
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
)
|
)
|
||||||
delete_file filename: 'test/test.jpg'
|
delete_file filename: 'test/test.jpg'
|
||||||
last_response.headers['Location'].must_equal "http://example.org/dashboard?dir=test"
|
_(last_response.headers['Location']).must_equal "http://example.org/dashboard?dir=test"
|
||||||
|
|
||||||
upload(
|
upload(
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
)
|
)
|
||||||
delete_file filename: 'test.jpg'
|
delete_file filename: 'test.jpg'
|
||||||
last_response.headers['Location'].must_equal "http://example.org/dashboard"
|
_(last_response.headers['Location']).must_equal "http://example.org/dashboard"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'upload' do
|
describe 'upload' do
|
||||||
it 'works with empty files' do
|
it 'works with empty files' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/empty.js', 'text/javascript')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/empty.js', 'text/javascript')
|
||||||
File.exists?(@site.files_path('empty.js')).must_equal true
|
_(File.exists?(@site.files_path('empty.js'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'manages files with invalid UTF8' do
|
it 'manages files with invalid UTF8' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/invalidutf8.html', 'text/html')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/invalidutf8.html', 'text/html')
|
||||||
File.exists?(@site.files_path('invalidutf8.html')).must_equal true
|
_(File.exists?(@site.files_path('invalidutf8.html'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'works with manifest files' do
|
it 'works with manifest files' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/cache.manifest', 'text/cache-manifest')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/cache.manifest', 'text/cache-manifest')
|
||||||
File.exists?(@site.files_path('cache.manifest')).must_equal true
|
_(File.exists?(@site.files_path('cache.manifest'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'works with otf fonts' do
|
it 'works with otf fonts' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/chunkfive.otf', 'application/vnd.ms-opentype')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/chunkfive.otf', 'application/vnd.ms-opentype')
|
||||||
File.exists?(@site.files_path('chunkfive.otf')).must_equal true
|
_(File.exists?(@site.files_path('chunkfive.otf'))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with index.html file' do
|
it 'succeeds with index.html file' do
|
||||||
@site.site_changed.must_equal false
|
_(@site.site_changed).must_equal false
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||||
last_response.body.must_match /successfully uploaded/i
|
_(last_response.body).must_match /successfully uploaded/i
|
||||||
File.exists?(@site.files_path('index.html')).must_equal true
|
_(File.exists?(@site.files_path('index.html'))).must_equal true
|
||||||
|
|
||||||
args = ScreenshotWorker.jobs.first['args']
|
args = ScreenshotWorker.jobs.first['args']
|
||||||
args.first.must_equal @site.username
|
_(args.first).must_equal @site.username
|
||||||
args.last.must_equal 'index.html'
|
_(args.last).must_equal 'index.html'
|
||||||
@site.title.must_equal "The web site of #{@site.username}"
|
_(@site.title).must_equal "The web site of #{@site.username}"
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.site_changed.must_equal true
|
_(@site.site_changed).must_equal true
|
||||||
@site.title.must_equal 'Hello?'
|
_(@site.title).must_equal 'Hello?'
|
||||||
|
|
||||||
# Purge cache needs to flush / and index.html for either scenario.
|
# Purge cache needs to flush / and index.html for either scenario.
|
||||||
PurgeCacheWorker.jobs.length.must_equal 3
|
_(PurgeCacheWorker.jobs.length).must_equal 3
|
||||||
first_purge = PurgeCacheWorker.jobs.first
|
first_purge = PurgeCacheWorker.jobs.first
|
||||||
surf_purge = PurgeCacheWorker.jobs[1]
|
surf_purge = PurgeCacheWorker.jobs[1]
|
||||||
dirname_purge = PurgeCacheWorker.jobs.last
|
dirname_purge = PurgeCacheWorker.jobs.last
|
||||||
|
|
||||||
username, pathname = first_purge['args']
|
username, pathname = first_purge['args']
|
||||||
username.must_equal @site.username
|
_(username).must_equal @site.username
|
||||||
pathname.must_equal '/index.html'
|
_(pathname).must_equal '/index.html'
|
||||||
|
|
||||||
surf_purge['args'].last.must_equal '/?surf=1'
|
_(surf_purge['args'].last).must_equal '/?surf=1'
|
||||||
|
|
||||||
username, pathame = nil
|
username, pathame = nil
|
||||||
username, pathname = dirname_purge['args']
|
username, pathname = dirname_purge['args']
|
||||||
username.must_equal @site.username
|
_(username).must_equal @site.username
|
||||||
pathname.must_equal '/'
|
_(pathname).must_equal '/'
|
||||||
|
|
||||||
@site.space_used.must_equal @site.actual_space_used
|
_(@site.space_used).must_equal @site.actual_space_used
|
||||||
|
|
||||||
(@site.space_used > 0).must_equal true
|
_((@site.space_used > 0)).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'provides the correct space used after overwriting an existing file' do
|
it 'provides the correct space used after overwriting an existing file' do
|
||||||
|
@ -306,8 +306,8 @@ describe 'site_files' do
|
||||||
upload 'files[]' => uploaded_file
|
upload 'files[]' => uploaded_file
|
||||||
second_uploaded_file = Rack::Test::UploadedFile.new('./tests/files/img/test.jpg', 'image/jpeg')
|
second_uploaded_file = Rack::Test::UploadedFile.new('./tests/files/img/test.jpg', 'image/jpeg')
|
||||||
upload 'files[]' => second_uploaded_file
|
upload 'files[]' => second_uploaded_file
|
||||||
@site.reload.space_used.must_equal initial_space_used + second_uploaded_file.size
|
_(@site.reload.space_used).must_equal initial_space_used + second_uploaded_file.size
|
||||||
@site.space_used.must_equal @site.actual_space_used
|
_(@site.space_used).must_equal @site.actual_space_used
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not change title for subdir index.html' do
|
it 'does not change title for subdir index.html' do
|
||||||
|
@ -316,7 +316,7 @@ describe 'site_files' do
|
||||||
'dir' => 'derpie',
|
'dir' => 'derpie',
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||||
)
|
)
|
||||||
@site.reload.title.must_equal title
|
_(@site.reload.title).must_equal title
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'purges cache for /subdir/' do # (not /subdir which is just a redirect to /subdir/)
|
it 'purges cache for /subdir/' do # (not /subdir which is just a redirect to /subdir/)
|
||||||
|
@ -324,7 +324,7 @@ describe 'site_files' do
|
||||||
'dir' => 'subdir',
|
'dir' => 'subdir',
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||||
)
|
)
|
||||||
PurgeCacheWorker.jobs.select {|j| j['args'].last == '/subdir/'}.length.must_equal 1
|
_(PurgeCacheWorker.jobs.select {|j| j['args'].last == '/subdir/'}.length).must_equal 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with multiple files' do
|
it 'succeeds with multiple files' do
|
||||||
|
@ -336,51 +336,51 @@ describe 'site_files' do
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@site.site_files.select {|s| s.path == 'one'}.length.must_equal 1
|
_(@site.site_files.select {|s| s.path == 'one'}.length).must_equal 1
|
||||||
@site.site_files.select {|s| s.path == 'one/test.jpg'}.length.must_equal 1
|
_(@site.site_files.select {|s| s.path == 'one/test.jpg'}.length).must_equal 1
|
||||||
@site.site_files.select {|s| s.path == 'two'}.length.must_equal 1
|
_(@site.site_files.select {|s| s.path == 'two'}.length).must_equal 1
|
||||||
@site.site_files.select {|s| s.path == 'two/test.jpg'}.length.must_equal 1
|
_(@site.site_files.select {|s| s.path == 'two/test.jpg'}.length).must_equal 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds with valid file' do
|
it 'succeeds with valid file' do
|
||||||
initial_space_used = @site.space_used
|
initial_space_used = @site.space_used
|
||||||
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
upload 'files[]' => uploaded_file
|
upload 'files[]' => uploaded_file
|
||||||
last_response.body.must_match /successfully uploaded/i
|
_(last_response.body).must_match /successfully uploaded/i
|
||||||
File.exists?(@site.files_path('test.jpg')).must_equal true
|
_(File.exists?(@site.files_path('test.jpg'))).must_equal true
|
||||||
|
|
||||||
username, path = PurgeCacheWorker.jobs.first['args']
|
username, path = PurgeCacheWorker.jobs.first['args']
|
||||||
username.must_equal @site.username
|
_(username).must_equal @site.username
|
||||||
path.must_equal '/test.jpg'
|
_(path).must_equal '/test.jpg'
|
||||||
|
|
||||||
@site.reload
|
@site.reload
|
||||||
@site.space_used.wont_equal 0
|
_(@site.space_used).wont_equal 0
|
||||||
@site.space_used.must_equal initial_space_used + uploaded_file.size
|
_(@site.space_used).must_equal initial_space_used + uploaded_file.size
|
||||||
@site.space_used.must_equal @site.actual_space_used
|
_(@site.space_used).must_equal @site.actual_space_used
|
||||||
|
|
||||||
ThumbnailWorker.jobs.length.must_equal 1
|
_(ThumbnailWorker.jobs.length).must_equal 1
|
||||||
ThumbnailWorker.drain
|
ThumbnailWorker.drain
|
||||||
|
|
||||||
Site::THUMBNAIL_RESOLUTIONS.each do |resolution|
|
Site::THUMBNAIL_RESOLUTIONS.each do |resolution|
|
||||||
File.exists?(@site.thumbnail_path('test.jpg', resolution)).must_equal true
|
_(File.exists?(@site.thumbnail_path('test.jpg', resolution))).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
@site.site_changed.must_equal false
|
_(@site.site_changed).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets site changed to false if index is empty' do
|
it 'sets site changed to false if index is empty' do
|
||||||
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/blankindex/index.html', 'text/html')
|
uploaded_file = Rack::Test::UploadedFile.new('./tests/files/blankindex/index.html', 'text/html')
|
||||||
upload 'files[]' => uploaded_file
|
upload 'files[]' => uploaded_file
|
||||||
last_response.body.must_match /successfully uploaded/i
|
_(last_response.body).must_match /successfully uploaded/i
|
||||||
@site.empty_index?.must_equal true
|
_(@site.empty_index?).must_equal true
|
||||||
@site.site_changed.must_equal false
|
_(@site.site_changed).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails with unsupported file' do
|
it 'fails with unsupported file' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
||||||
last_response.body.must_match /only supported by.+supporter account/i
|
_(last_response.body).must_match /only supported by.+supporter account/i
|
||||||
File.exists?(@site.files_path('flowercrime.wav')).must_equal false
|
_(File.exists?(@site.files_path('flowercrime.wav'))).must_equal false
|
||||||
@site.site_changed.must_equal false
|
_(@site.site_changed).must_equal false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'succeeds for unwhitelisted file on supporter plans' do
|
it 'succeeds for unwhitelisted file on supporter plans' do
|
||||||
|
@ -388,20 +388,20 @@ describe 'site_files' do
|
||||||
no_file_restriction_plans.each do |plan_type,hash|
|
no_file_restriction_plans.each do |plan_type,hash|
|
||||||
@site = Fabricate :site, plan_type: plan_type
|
@site = Fabricate :site, plan_type: plan_type
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
||||||
last_response.body.must_match /successfully uploaded/i
|
_(last_response.body).must_match /successfully uploaded/i
|
||||||
File.exists?(@site.files_path('flowercrime.wav')).must_equal true
|
_(File.exists?(@site.files_path('flowercrime.wav'))).must_equal true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'overwrites existing file with new file' do
|
it 'overwrites existing file with new file' do
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
last_response.body.must_match /successfully uploaded/i
|
_(last_response.body).must_match /successfully uploaded/i
|
||||||
digest = @site.reload.site_files.first.sha1_hash
|
digest = @site.reload.site_files.first.sha1_hash
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/img/test.jpg', 'image/jpeg')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/img/test.jpg', 'image/jpeg')
|
||||||
last_response.body.must_match /successfully uploaded/i
|
_(last_response.body).must_match /successfully uploaded/i
|
||||||
@site.reload.changed_count.must_equal 2
|
_(@site.reload.changed_count).must_equal 2
|
||||||
@site.site_files.select {|f| f.path == 'test.jpg'}.length.must_equal 1
|
_(@site.site_files.select {|f| f.path == 'test.jpg'}.length).must_equal 1
|
||||||
digest.wont_equal @site.site_files_dataset.where(path: 'test.jpg').first.sha1_hash
|
_(digest).wont_equal @site.site_files_dataset.where(path: 'test.jpg').first.sha1_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'works with directory path' do
|
it 'works with directory path' do
|
||||||
|
@ -409,24 +409,24 @@ describe 'site_files' do
|
||||||
'dir' => 'derpie/derptest',
|
'dir' => 'derpie/derptest',
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
)
|
)
|
||||||
last_response.body.must_match /successfully uploaded/i
|
_(last_response.body).must_match /successfully uploaded/i
|
||||||
File.exists?(@site.files_path('derpie/derptest/test.jpg')).must_equal true
|
_(File.exists?(@site.files_path('derpie/derptest/test.jpg'))).must_equal true
|
||||||
|
|
||||||
PurgeCacheWorker.jobs.length.must_equal 1
|
_(PurgeCacheWorker.jobs.length).must_equal 1
|
||||||
username, path = PurgeCacheWorker.jobs.first['args']
|
username, path = PurgeCacheWorker.jobs.first['args']
|
||||||
username.must_equal @site.username
|
_(username).must_equal @site.username
|
||||||
path.must_equal '/derpie/derptest/test.jpg'
|
_(path).must_equal '/derpie/derptest/test.jpg'
|
||||||
|
|
||||||
ThumbnailWorker.jobs.length.must_equal 1
|
_(ThumbnailWorker.jobs.length).must_equal 1
|
||||||
ThumbnailWorker.drain
|
ThumbnailWorker.drain
|
||||||
|
|
||||||
@site.site_files_dataset.where(path: 'derpie').count.must_equal 1
|
_(@site.site_files_dataset.where(path: 'derpie').count).must_equal 1
|
||||||
@site.site_files_dataset.where(path: 'derpie/derptest').count.must_equal 1
|
_(@site.site_files_dataset.where(path: 'derpie/derptest').count).must_equal 1
|
||||||
@site.site_files_dataset.where(path: 'derpie/derptest/test.jpg').count.must_equal 1
|
_(@site.site_files_dataset.where(path: 'derpie/derptest/test.jpg').count).must_equal 1
|
||||||
|
|
||||||
Site::THUMBNAIL_RESOLUTIONS.each do |resolution|
|
Site::THUMBNAIL_RESOLUTIONS.each do |resolution|
|
||||||
File.exists?(@site.thumbnail_path('derpie/derptest/test.jpg', resolution)).must_equal true
|
_(File.exists?(@site.thumbnail_path('derpie/derptest/test.jpg', resolution))).must_equal true
|
||||||
@site.thumbnail_url('derpie/derptest/test.jpg', resolution).must_equal(
|
_(@site.thumbnail_url('derpie/derptest/test.jpg', resolution)).must_equal(
|
||||||
File.join "#{Site::THUMBNAILS_URL_ROOT}", Site.sharding_dir(@site.username), @site.username, "/derpie/derptest/test.jpg.#{resolution}.jpg"
|
File.join "#{Site::THUMBNAILS_URL_ROOT}", Site.sharding_dir(@site.username), @site.username, "/derpie/derptest/test.jpg.#{resolution}.jpg"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -437,13 +437,13 @@ describe 'site_files' do
|
||||||
'dir' => 'derpie/derptest',
|
'dir' => 'derpie/derptest',
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
)
|
)
|
||||||
@site.reload.site_changed.must_equal false
|
_(@site.reload.site_changed).must_equal false
|
||||||
|
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||||
@site.reload.site_changed.must_equal true
|
_(@site.reload.site_changed).must_equal true
|
||||||
|
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/chunkfive.otf', 'application/vnd.ms-opentype')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/chunkfive.otf', 'application/vnd.ms-opentype')
|
||||||
@site.reload.site_changed.must_equal true
|
_(@site.reload.site_changed).must_equal true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not store new file if hash matches' do
|
it 'does not store new file if hash matches' do
|
||||||
|
@ -451,22 +451,22 @@ describe 'site_files' do
|
||||||
'dir' => 'derpie/derptest',
|
'dir' => 'derpie/derptest',
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
)
|
)
|
||||||
@site.reload.changed_count.must_equal 1
|
_(@site.reload.changed_count).must_equal 1
|
||||||
|
|
||||||
upload(
|
upload(
|
||||||
'dir' => 'derpie/derptest',
|
'dir' => 'derpie/derptest',
|
||||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
)
|
)
|
||||||
@site.reload.changed_count.must_equal 1
|
_(@site.reload.changed_count).must_equal 1
|
||||||
|
|
||||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/index.html', 'text/html')
|
||||||
@site.reload.changed_count.must_equal 2
|
_(@site.reload.changed_count).must_equal 2
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'directory create' do
|
describe 'directory create' do
|
||||||
it 'scrubs ../ from directory' do
|
it 'scrubs ../ from directory' do
|
||||||
@site.create_directory '../../test'
|
@site.create_directory '../../test'
|
||||||
@site.site_files.select {|site_file| site_file.path =~ /\.\./}.length.must_equal 0
|
_(@site.site_files.select {|site_file| site_file.path =~ /\.\./}.length).must_equal 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -485,9 +485,9 @@ describe 'site_files' do
|
||||||
@site.train 'spam.html', 'spam'
|
@site.train 'spam.html', 'spam'
|
||||||
@site.train 'phishing.html', 'phishing'
|
@site.train 'phishing.html', 'phishing'
|
||||||
|
|
||||||
@site.classify('ham.html').must_equal 'ham'
|
_(@site.classify('ham.html')).must_equal 'ham'
|
||||||
@site.classify('spam.html').must_equal 'spam'
|
_(@site.classify('spam.html')).must_equal 'spam'
|
||||||
@site.classify('phishing.html').must_equal 'phishing'
|
_(@site.classify('phishing.html')).must_equal 'phishing'
|
||||||
end
|
end
|
||||||
=end
|
=end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,8 @@ describe Site do
|
||||||
it 'still makes files available' do
|
it 'still makes files available' do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
site.ban!
|
site.ban!
|
||||||
File.exist?(site.current_files_path('index.html')).must_equal true
|
_(File.exist?(site.current_files_path('index.html'))).must_equal true
|
||||||
site.current_files_path('index.html').must_equal File.join(Site::DELETED_SITES_ROOT, Site.sharding_dir(site.username), site.username, 'index.html')
|
_(site.current_files_path('index.html')).must_equal File.join(Site::DELETED_SITES_ROOT, Site.sharding_dir(site.username), site.username, 'index.html')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,13 +19,13 @@ describe Site do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
index_path = File.join site.base_files_path, 'index.html'
|
index_path = File.join site.base_files_path, 'index.html'
|
||||||
site.ban!
|
site.ban!
|
||||||
File.exist?(index_path).must_equal false
|
_(File.exist?(index_path)).must_equal false
|
||||||
site.unban!
|
site.unban!
|
||||||
site.reload
|
site.reload
|
||||||
site.is_banned.must_equal false
|
_(site.is_banned).must_equal false
|
||||||
site.banned_at.must_be_nil
|
_(site.banned_at).must_be_nil
|
||||||
site.blackbox_whitelisted.must_equal true
|
_(site.blackbox_whitelisted).must_equal true
|
||||||
File.exist?(index_path).must_equal true
|
_(File.exist?(index_path)).must_equal true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ describe Site do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
site_file_count = site.site_files_dataset.count
|
site_file_count = site.site_files_dataset.count
|
||||||
site.create_directory path
|
site.create_directory path
|
||||||
site.site_files.select {|s| s.path == '' || s.path == '.'}.length.must_equal 0
|
_(site.site_files.select {|s| s.path == '' || s.path == '.'}.length).must_equal 0
|
||||||
site.site_files.select {|s| s.path == path.gsub('/', '')}.first.wont_be_nil
|
_(site.site_files.select {|s| s.path == path.gsub('/', '')}.first).wont_be_nil
|
||||||
site.site_files_dataset.count.must_equal site_file_count+1
|
_(site.site_files_dataset.count).must_equal site_file_count+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,24 +45,24 @@ describe Site do
|
||||||
describe 'custom_max_space' do
|
describe 'custom_max_space' do
|
||||||
it 'should use the custom max space if it is more' do
|
it 'should use the custom max space if it is more' do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
site.maximum_space.must_equal Site::PLAN_FEATURES[:free][:space]
|
_(site.maximum_space).must_equal Site::PLAN_FEATURES[:free][:space]
|
||||||
site.custom_max_space = 10**9
|
site.custom_max_space = 10**9
|
||||||
site.save_changes
|
site.save_changes
|
||||||
site.maximum_space.must_equal 10**9
|
_(site.maximum_space).must_equal 10**9
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'can_email' do
|
describe 'can_email' do
|
||||||
it 'should fail if send_emails is false' do
|
it 'should fail if send_emails is false' do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
site.can_email?.must_equal true
|
_(site.can_email?).must_equal true
|
||||||
site.update send_emails: false
|
site.update send_emails: false
|
||||||
site.can_email?.must_equal false
|
_(site.can_email?).must_equal false
|
||||||
site.can_email?(:send_comment_emails).must_equal false
|
_(site.can_email?(:send_comment_emails)).must_equal false
|
||||||
site.update send_emails: true
|
site.update send_emails: true
|
||||||
site.can_email?(:send_comment_emails).must_equal true
|
_(site.can_email?(:send_comment_emails)).must_equal true
|
||||||
site.update send_comment_emails: false
|
site.update send_comment_emails: false
|
||||||
site.can_email?(:send_comment_emails).must_equal false
|
_(site.can_email?(:send_comment_emails)).must_equal false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -74,12 +74,12 @@ describe Site do
|
||||||
|
|
||||||
it 'works' do
|
it 'works' do
|
||||||
@site.send_email(subject: 'Subject', body: 'Body')
|
@site.send_email(subject: 'Subject', body: 'Body')
|
||||||
EmailWorker.jobs.length.must_equal 1
|
_(EmailWorker.jobs.length).must_equal 1
|
||||||
args = EmailWorker.jobs.first['args'].first
|
args = EmailWorker.jobs.first['args'].first
|
||||||
args['from'].must_equal Site::FROM_EMAIL
|
_(args['from']).must_equal Site::FROM_EMAIL
|
||||||
args['to'].must_equal @site.email
|
_(args['to']).must_equal @site.email
|
||||||
args['subject'].must_equal 'Subject'
|
_(args['subject']).must_equal 'Subject'
|
||||||
args['body'].must_equal 'Body'
|
_(args['body']).must_equal 'Body'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails if send_emails is false' do
|
it 'fails if send_emails is false' do
|
||||||
|
@ -91,21 +91,21 @@ describe Site do
|
||||||
describe 'plan_name' do
|
describe 'plan_name' do
|
||||||
it 'should set to free for missing stripe_customer_id' do
|
it 'should set to free for missing stripe_customer_id' do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
site.reload.plan_type.must_equal 'free'
|
_(site.reload.plan_type).must_equal 'free'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be free for no plan_type entry' do
|
it 'should be free for no plan_type entry' do
|
||||||
site = Fabricate :site, stripe_customer_id: 'cust_derp'
|
site = Fabricate :site, stripe_customer_id: 'cust_derp'
|
||||||
site.plan_type.must_equal 'free'
|
_(site.plan_type).must_equal 'free'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should match plan_type' do
|
it 'should match plan_type' do
|
||||||
%w{supporter free}.each do |plan_type|
|
%w{supporter free}.each do |plan_type|
|
||||||
site = Fabricate :site, plan_type: plan_type
|
site = Fabricate :site, plan_type: plan_type
|
||||||
site.plan_type.must_equal plan_type
|
_(site.plan_type).must_equal plan_type
|
||||||
end
|
end
|
||||||
site = Fabricate :site, plan_type: nil
|
site = Fabricate :site, plan_type: nil
|
||||||
site.plan_type.must_equal 'free'
|
_(site.plan_type).must_equal 'free'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,16 +114,18 @@ describe Site do
|
||||||
site = Fabricate :site, new_tags_string: 'vegetables'
|
site = Fabricate :site, new_tags_string: 'vegetables'
|
||||||
Site::SUGGESTIONS_LIMIT.times { Fabricate :site, new_tags_string: 'vegetables' }
|
Site::SUGGESTIONS_LIMIT.times { Fabricate :site, new_tags_string: 'vegetables' }
|
||||||
|
|
||||||
site.suggestions.length.must_equal Site::SUGGESTIONS_LIMIT
|
_(site.suggestions.length).must_equal Site::SUGGESTIONS_LIMIT
|
||||||
|
|
||||||
site.suggestions.each {|s| s.tags.first.name.must_equal 'vegetables'}
|
site.suggestions.each do |suggestion|
|
||||||
|
_(suggestion.tags.first.name).must_equal 'vegetables'
|
||||||
|
end
|
||||||
|
|
||||||
site = Fabricate :site, new_tags_string: 'gardening'
|
site = Fabricate :site, new_tags_string: 'gardening'
|
||||||
(Site::SUGGESTIONS_LIMIT-5).times {
|
(Site::SUGGESTIONS_LIMIT-5).times {
|
||||||
Fabricate :site, new_tags_string: 'gardening', views: Site::SUGGESTIONS_VIEWS_MIN
|
Fabricate :site, new_tags_string: 'gardening', views: Site::SUGGESTIONS_VIEWS_MIN
|
||||||
}
|
}
|
||||||
|
|
||||||
site.suggestions.length.must_equal(Site::SUGGESTIONS_LIMIT - 5)
|
_(site.suggestions.length).must_equal(Site::SUGGESTIONS_LIMIT - 5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,9 +33,9 @@ describe 'stats' do
|
||||||
end
|
end
|
||||||
Stat.parse_logfiles STAT_LOGS_PATH
|
Stat.parse_logfiles STAT_LOGS_PATH
|
||||||
stat = @site_one.stats.first
|
stat = @site_one.stats.first
|
||||||
stat.hits.must_equal 8
|
_(stat.hits).must_equal 8
|
||||||
stat.bandwidth.must_equal 40000
|
_(stat.bandwidth).must_equal 40000
|
||||||
stat.views.must_equal 2
|
_(stat.views).must_equal 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deals with spaces in paths' do
|
it 'deals with spaces in paths' do
|
||||||
|
@ -48,9 +48,9 @@ describe 'stats' do
|
||||||
|
|
||||||
Stat.parse_logfiles STAT_LOGS_PATH
|
Stat.parse_logfiles STAT_LOGS_PATH
|
||||||
|
|
||||||
@site.stats.first.bandwidth.must_equal 612917*2
|
_(@site.stats.first.bandwidth).must_equal 612917*2
|
||||||
#@site.stat_referrers.first.url.must_equal 'http://derp.com'
|
#_(@site.stat_referrers.first.url).must_equal 'http://derp.com'
|
||||||
#@site.stat_locations.first.city_name.must_equal 'Menlo Park'
|
#_(@site.stat_locations.first.city_name).must_equal 'Menlo Park'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'takes accout for log hit time' do
|
it 'takes accout for log hit time' do
|
||||||
|
@ -63,15 +63,15 @@ describe 'stats' do
|
||||||
|
|
||||||
Stat.parse_logfiles STAT_LOGS_PATH
|
Stat.parse_logfiles STAT_LOGS_PATH
|
||||||
|
|
||||||
@site.stats.length.must_equal 2
|
_(@site.stats.length).must_equal 2
|
||||||
|
|
||||||
[Date.new(2015, 5, 2), Date.new(2015, 5, 1)].each do |date|
|
[Date.new(2015, 5, 2), Date.new(2015, 5, 1)].each do |date|
|
||||||
stats = @site.stats.select {|stat| stat.created_at == date}
|
stats = @site.stats.select {|stat| stat.created_at == date}
|
||||||
stats.length.must_equal 1
|
_(stats.length).must_equal 1
|
||||||
stat = stats.first
|
stat = stats.first
|
||||||
stat.hits.must_equal 1
|
_(stat.hits).must_equal 1
|
||||||
stat.views.must_equal 1
|
_(stat.views).must_equal 1
|
||||||
stat.bandwidth.must_equal 612917
|
_(stat.bandwidth).must_equal 612917
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -101,20 +101,20 @@ describe 'stats' do
|
||||||
count_site_ids = [@free_site.id, @supporter_site.id]
|
count_site_ids = [@free_site.id, @supporter_site.id]
|
||||||
expected_stat_count = (Stat::FREE_RETAINMENT_DAYS+1)*2
|
expected_stat_count = (Stat::FREE_RETAINMENT_DAYS+1)*2
|
||||||
|
|
||||||
Stat.where(site_id: count_site_ids).count.must_equal expected_stat_count
|
_(Stat.where(site_id: count_site_ids).count).must_equal expected_stat_count
|
||||||
Stat.prune!
|
Stat.prune!
|
||||||
Stat.where(site_id: count_site_ids).count.must_equal expected_stat_count-1
|
_(Stat.where(site_id: count_site_ids).count).must_equal expected_stat_count-1
|
||||||
Stat.where(site_id: @supporter_site.id).count.must_equal expected_stat_count/2
|
_(Stat.where(site_id: @supporter_site.id).count).must_equal expected_stat_count/2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prunes referrers' do
|
it 'prunes referrers' do
|
||||||
stat_referrer_now = @site_one.add_stat_referrer created_at: Date.today, url: 'http://example.com/now'
|
stat_referrer_now = @site_one.add_stat_referrer created_at: Date.today, url: 'http://example.com/now'
|
||||||
stat_referrer = @site_one.add_stat_referrer created_at: (StatReferrer::RETAINMENT_DAYS-1).days.ago, url: 'http://example.com'
|
stat_referrer = @site_one.add_stat_referrer created_at: (StatReferrer::RETAINMENT_DAYS-1).days.ago, url: 'http://example.com'
|
||||||
StatReferrer[stat_referrer.id].wont_be_nil
|
_(StatReferrer[stat_referrer.id]).wont_be_nil
|
||||||
@site_one.stat_referrers_dataset.count.must_equal 2
|
_(@site_one.stat_referrers_dataset.count).must_equal 2
|
||||||
StatReferrer.prune!
|
StatReferrer.prune!
|
||||||
@site_one.stat_referrers_dataset.count.must_equal 1
|
_(@site_one.stat_referrers_dataset.count).must_equal 1
|
||||||
StatReferrer[stat_referrer.id].must_be_nil
|
_(StatReferrer[stat_referrer.id]).must_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prunes locations' do
|
it 'prunes locations' do
|
||||||
|
@ -124,9 +124,9 @@ describe 'stats' do
|
||||||
region_name: 'Minnesota',
|
region_name: 'Minnesota',
|
||||||
city_name: 'Minneapolis'
|
city_name: 'Minneapolis'
|
||||||
)
|
)
|
||||||
StatLocation[stat_location.id].wont_be_nil
|
_(StatLocation[stat_location.id]).wont_be_nil
|
||||||
StatLocation.prune!
|
StatLocation.prune!
|
||||||
StatLocation[stat_location.id].must_be_nil
|
_(StatLocation[stat_location.id]).must_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prunes paths' do
|
it 'prunes paths' do
|
||||||
|
@ -134,9 +134,9 @@ describe 'stats' do
|
||||||
created_at: (StatPath::RETAINMENT_DAYS-1).days.ago,
|
created_at: (StatPath::RETAINMENT_DAYS-1).days.ago,
|
||||||
name: '/derpie.html'
|
name: '/derpie.html'
|
||||||
)
|
)
|
||||||
StatPath[stat_path.id].wont_be_nil
|
_(StatPath[stat_path.id]).wont_be_nil
|
||||||
StatPath.prune!
|
StatPath.prune!
|
||||||
StatPath[stat_path.id].must_be_nil
|
_(StatPath[stat_path.id]).must_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'parses logfile' do
|
it 'parses logfile' do
|
||||||
|
@ -144,57 +144,57 @@ describe 'stats' do
|
||||||
Stat.parse_logfiles STAT_LOGS_PATH
|
Stat.parse_logfiles STAT_LOGS_PATH
|
||||||
|
|
||||||
@site_one.reload
|
@site_one.reload
|
||||||
@site_one.hits.must_equal 4
|
_(@site_one.hits).must_equal 4
|
||||||
@site_one.views.must_equal 2
|
_(@site_one.views).must_equal 2
|
||||||
stat = @site_one.stats.first
|
stat = @site_one.stats.first
|
||||||
stat.hits.must_equal 4
|
_(stat.hits).must_equal 4
|
||||||
stat.views.must_equal 2
|
_(stat.views).must_equal 2
|
||||||
stat.bandwidth.must_equal 20_000
|
_(stat.bandwidth).must_equal 20_000
|
||||||
|
|
||||||
#@site_one.stat_referrers.count.must_equal 1
|
#@site_one.stat_referrers.count).must_equal 1
|
||||||
#stat_referrer = @site_one.stat_referrers.first
|
#stat_referrer = @site_one.stat_referrers.first
|
||||||
#stat_referrer.url.must_equal 'http://example.com'
|
#stat_referrer.url).must_equal 'http://example.com'
|
||||||
#stat_referrer.created_at.must_equal @time.to_date
|
#stat_referrer.created_at).must_equal @time.to_date
|
||||||
#stat_referrer.views.must_equal 2
|
#stat_referrer.views).must_equal 2
|
||||||
|
|
||||||
#@site_one.stat_paths.length.must_equal 1
|
#@site_one.stat_paths.length).must_equal 1
|
||||||
#stat_path = @site_one.stat_paths.first
|
#stat_path = @site_one.stat_paths.first
|
||||||
#stat_path.name.must_equal '/'
|
#stat_path.name).must_equal '/'
|
||||||
#stat_path.views.must_equal 4
|
#stat_path.views).must_equal 4
|
||||||
|
|
||||||
#@site_one.stat_locations.length.must_equal 2
|
#@site_one.stat_locations.length).must_equal 2
|
||||||
#stat_location = @site_one.stat_locations.first
|
#stat_location = @site_one.stat_locations.first
|
||||||
#stat_location.country_code2.must_equal 'US'
|
#stat_location.country_code2).must_equal 'US'
|
||||||
#stat_location.region_name.must_equal 'CA'
|
#stat_location.region_name).must_equal 'CA'
|
||||||
#stat_location.city_name.must_equal 'Menlo Park'
|
#stat_location.city_name).must_equal 'Menlo Park'
|
||||||
#stat_location.views.must_equal 1
|
#stat_location.views).must_equal 1
|
||||||
|
|
||||||
@site_two.reload
|
@site_two.reload
|
||||||
@site_two.hits.must_equal 3
|
_(@site_two.hits).must_equal 3
|
||||||
@site_two.views.must_equal 3
|
_(@site_two.views).must_equal 3
|
||||||
stat = @site_two.stats.first
|
stat = @site_two.stats.first
|
||||||
stat.hits.must_equal 3
|
_(stat.hits).must_equal 3
|
||||||
stat.views.must_equal 3
|
_(stat.views).must_equal 3
|
||||||
stat.bandwidth.must_equal 15_000
|
_(stat.bandwidth).must_equal 15_000
|
||||||
#@site_two.stat_referrers.count.must_equal 2
|
#@site_two.stat_referrers.count).must_equal 2
|
||||||
#stat_referrer = @site_two.stat_referrers.first
|
#stat_referrer = @site_two.stat_referrers.first
|
||||||
#stat_referrer.url.must_equal 'http://example.com'
|
#stat_referrer.url).must_equal 'http://example.com'
|
||||||
#stat_referrer.views.must_equal 2
|
#stat_referrer.views).must_equal 2
|
||||||
|
|
||||||
#stat_paths = @site_two.stat_paths
|
#stat_paths = @site_two.stat_paths
|
||||||
#stat_paths.length.must_equal 2
|
#stat_paths.length).must_equal 2
|
||||||
#stat_paths.first.name.must_equal '/'
|
#stat_paths.first.name).must_equal '/'
|
||||||
#stat_paths.last.name.must_equal '/derp.html'
|
#stat_paths.last.name).must_equal '/derp.html'
|
||||||
|
|
||||||
# [geoip.city('67.180.75.140'), geoip.city('172.56.16.152')]
|
# [geoip.city('67.180.75.140'), geoip.city('172.56.16.152')]
|
||||||
|
|
||||||
# Saves to daily_site_stats
|
# Saves to daily_site_stats
|
||||||
|
|
||||||
DailySiteStat.count.must_equal 1
|
_(DailySiteStat.count).must_equal 1
|
||||||
d = DailySiteStat.first
|
d = DailySiteStat.first
|
||||||
d.created_at.must_equal Date.new(@time.year, @time.month, @time.day)
|
_(d.created_at).must_equal Date.new(@time.year, @time.month, @time.day)
|
||||||
d.hits.must_equal 7
|
_(d.hits).must_equal 7
|
||||||
d.views.must_equal 5
|
_(d.views).must_equal 5
|
||||||
d.bandwidth.must_equal 35000
|
_(d.bandwidth).must_equal 35000
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,30 +5,30 @@ describe Tag do
|
||||||
it 'should force downcase' do
|
it 'should force downcase' do
|
||||||
Tag.where(name: 'derp').delete
|
Tag.where(name: 'derp').delete
|
||||||
Tag.create_unless_exists 'derp'
|
Tag.create_unless_exists 'derp'
|
||||||
Tag[name: 'derp'].wont_be_nil
|
_(Tag[name: 'derp']).wont_be_nil
|
||||||
Tag.create_unless_exists 'DERP'
|
Tag.create_unless_exists 'DERP'
|
||||||
Tag.filter(name: 'DERP').count.must_equal 0
|
_(Tag.filter(name: 'DERP').count).must_equal 0
|
||||||
Tag.filter(name: 'derp').count.must_equal 1
|
_(Tag.filter(name: 'derp').count).must_equal 1
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prohibits junk tags' do
|
it 'prohibits junk tags' do
|
||||||
Tag.where(name: '').delete
|
Tag.where(name: '').delete
|
||||||
tag = Tag.create_unless_exists ''
|
tag = Tag.create_unless_exists ''
|
||||||
Tag.where(name: '').count.must_equal 0
|
_(Tag.where(name: '').count).must_equal 0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'strips tags' do
|
it 'strips tags' do
|
||||||
badname = ' derp '
|
badname = ' derp '
|
||||||
Tag.where(name: 'derp').delete
|
Tag.where(name: 'derp').delete
|
||||||
Tag.create_unless_exists badname
|
Tag.create_unless_exists badname
|
||||||
Tag[name: badname].must_be_nil
|
_(Tag[name: badname]).must_be_nil
|
||||||
Tag[name: badname.strip].wont_be_nil
|
_(Tag[name: badname.strip]).wont_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not duplicate' do
|
it 'does not duplicate' do
|
||||||
2.times { Tag.create_unless_exists 'DERP' }
|
2.times { Tag.create_unless_exists 'DERP' }
|
||||||
Tag.where(name: 'DERP').count.must_equal 0
|
_(Tag.where(name: 'DERP').count).must_equal 0
|
||||||
Tag.where(name: 'derp').count.must_equal 1
|
_(Tag.where(name: 'derp').count).must_equal 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -5,6 +5,6 @@ describe Tempfile do
|
||||||
tmp = Tempfile.new
|
tmp = Tempfile.new
|
||||||
tmp.write ''
|
tmp.write ''
|
||||||
tmp.close
|
tmp.close
|
||||||
tmp.size.must_equal 0
|
_(tmp.size).must_equal 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,20 +28,20 @@ describe 'tipping' do
|
||||||
|
|
||||||
post '/webhooks/paypal/tipping_notify', paypal_hash
|
post '/webhooks/paypal/tipping_notify', paypal_hash
|
||||||
|
|
||||||
@site.tips.length.must_equal 1
|
_(@site.tips.length).must_equal 1
|
||||||
tip = @site.tips.first
|
tip = @site.tips.first
|
||||||
tip.site.id.must_equal @site.id
|
_(tip.site.id).must_equal @site.id
|
||||||
tip.actioning_site.id.must_equal @actioning_site.id
|
_(tip.actioning_site.id).must_equal @actioning_site.id
|
||||||
tip.currency.must_equal 'USD'
|
_(tip.currency).must_equal 'USD'
|
||||||
tip.amount_string.must_equal '$5.00'
|
_(tip.amount_string).must_equal '$5.00'
|
||||||
tip.fee_string.must_equal '$0.45'
|
_(tip.fee_string).must_equal '$0.45'
|
||||||
tip.message.must_equal 'I like your site'
|
_(tip.message).must_equal 'I like your site'
|
||||||
tip.paypal_payer_email.must_equal @actioning_site.email
|
_(tip.paypal_payer_email).must_equal @actioning_site.email
|
||||||
tip.paypal_receiver_email.must_equal @site.email
|
_(tip.paypal_receiver_email).must_equal @site.email
|
||||||
tip.paypal_txn_id.must_equal 'TXID'
|
_(tip.paypal_txn_id).must_equal 'TXID'
|
||||||
tip.created_at.must_equal Time.parse("2017-02-03 21:39:51 -0800")
|
_(tip.created_at).must_equal Time.parse("2017-02-03 21:39:51 -0800")
|
||||||
|
|
||||||
EmailWorker.jobs.length.must_equal 2
|
_(EmailWorker.jobs.length).must_equal 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds a tip even if there is no actioning site id' do
|
it 'adds a tip even if there is no actioning site id' do
|
||||||
|
@ -60,8 +60,8 @@ describe 'tipping' do
|
||||||
|
|
||||||
post '/webhooks/paypal/tipping_notify', paypal_hash
|
post '/webhooks/paypal/tipping_notify', paypal_hash
|
||||||
|
|
||||||
@site.tips.length.must_equal 1
|
_(@site.tips.length).must_equal 1
|
||||||
@site.tips.first.actioning_site_id.must_be_nil
|
_(@site.tips.first.actioning_site_id).must_be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,23 +6,23 @@ describe ArchiveWorker do
|
||||||
site = Fabricate :site
|
site = Fabricate :site
|
||||||
ipfs_hash = site.add_to_ipfs
|
ipfs_hash = site.add_to_ipfs
|
||||||
ArchiveWorker.new.perform site.id
|
ArchiveWorker.new.perform site.id
|
||||||
site.archives.length.must_equal 1
|
_(site.archives.length).must_equal 1
|
||||||
archive_one = site.archives.first
|
archive_one = site.archives.first
|
||||||
archive_one.ipfs_hash.must_equal ipfs_hash
|
_(archive_one.ipfs_hash).must_equal ipfs_hash
|
||||||
archive_one.updated_at.wont_be_nil
|
_(archive_one.updated_at).wont_be_nil
|
||||||
|
|
||||||
new_updated_at = Time.now - 500
|
new_updated_at = Time.now - 500
|
||||||
archive_one.update updated_at: new_updated_at
|
archive_one.update updated_at: new_updated_at
|
||||||
|
|
||||||
ArchiveWorker.new.perform site.id
|
ArchiveWorker.new.perform site.id
|
||||||
archive_one.reload.updated_at.wont_equal new_updated_at
|
_(archive_one.reload.updated_at).wont_equal new_updated_at
|
||||||
|
|
||||||
site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
||||||
ArchiveWorker.new.perform site.id
|
ArchiveWorker.new.perform site.id
|
||||||
|
|
||||||
site.reload
|
site.reload
|
||||||
site.archives.length.must_equal 2
|
_(site.archives.length).must_equal 2
|
||||||
archive_two = site.archives_dataset.exclude(ipfs_hash: archive_one.ipfs_hash).first
|
archive_two = site.archives_dataset.exclude(ipfs_hash: archive_one.ipfs_hash).first
|
||||||
archive_two.ipfs_hash.wont_be_nil
|
_(archive_two.ipfs_hash).wont_be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,12 +15,12 @@ describe EmailWorker do
|
||||||
})
|
})
|
||||||
|
|
||||||
mail = Mail::TestMailer.deliveries.first
|
mail = Mail::TestMailer.deliveries.first
|
||||||
mail.from.first.must_equal 'from@example.com'
|
_(mail.from.first).must_equal 'from@example.com'
|
||||||
mail.to.first.must_equal 'to@example.com'
|
_(mail.to.first).must_equal 'to@example.com'
|
||||||
mail.subject.must_equal 'Hello World'
|
_(mail.subject).must_equal 'Hello World'
|
||||||
body = mail.body.to_s
|
body = mail.body.to_s
|
||||||
body.must_match /testing/
|
_(body).must_match /testing/
|
||||||
body.must_match /unsubscribe/
|
_(body).must_match /unsubscribe/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends an email without a footer' do
|
it 'sends an email without a footer' do
|
||||||
|
@ -33,7 +33,7 @@ describe EmailWorker do
|
||||||
'body' => 'testing'
|
'body' => 'testing'
|
||||||
})
|
})
|
||||||
body = Mail::TestMailer.deliveries.first.body.to_s
|
body = Mail::TestMailer.deliveries.first.body.to_s
|
||||||
body.must_match /testing/
|
_(body).must_match /testing/
|
||||||
body.wont_match /unsubscribe/
|
_(body).wont_match /unsubscribe/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe ScreenshotWorker do
|
||||||
ScreenshotWorker.new.perform site.username, path
|
ScreenshotWorker.new.perform site.username, path
|
||||||
|
|
||||||
Site::SCREENSHOT_RESOLUTIONS.each do |r|
|
Site::SCREENSHOT_RESOLUTIONS.each do |r|
|
||||||
File.exists?(File.join(Site::SCREENSHOTS_ROOT, Site.sharding_dir(site.username), site.username, "#{path}.#{r}.jpg")).must_equal true
|
_(File.exists?(File.join(Site::SCREENSHOTS_ROOT, Site.sharding_dir(site.username), site.username, "#{path}.#{r}.jpg"))).must_equal true
|
||||||
site.screenshot_url(path, r).must_equal(
|
_(site.screenshot_url(path, r)).must_equal(
|
||||||
File.join(Site::SCREENSHOTS_URL_ROOT, Site.sharding_dir(site.username), site.username, "#{path}.#{r}.jpg")
|
File.join(Site::SCREENSHOTS_URL_ROOT, Site.sharding_dir(site.username), site.username, "#{path}.#{r}.jpg")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -50,14 +50,14 @@ class ScreenshotWorker
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
img_list.new_image(img_list.first.columns, img_list.first.rows) { self.background_color = "white" }
|
img_list.new_image(img_list.first.columns, img_list.first.rows) {|i| i.background_color = "white" }
|
||||||
img = img_list.reverse.flatten_images
|
img = img_list.reverse.flatten_images
|
||||||
img_list.destroy!
|
img_list.destroy!
|
||||||
|
|
||||||
user_screenshots_path = File.join SCREENSHOTS_PATH, Site.sharding_dir(username), username
|
user_screenshots_path = File.join SCREENSHOTS_PATH, Site.sharding_dir(username), username
|
||||||
screenshot_path = File.join user_screenshots_path, File.dirname(path)
|
screenshot_path = File.join user_screenshots_path, File.dirname(path)
|
||||||
|
|
||||||
FileUtils.mkdir_p screenshot_path unless Dir.exists?(screenshot_path)
|
FileUtils.mkdir_p screenshot_path unless Dir.exist?(screenshot_path)
|
||||||
|
|
||||||
Site::SCREENSHOT_RESOLUTIONS.each do |res|
|
Site::SCREENSHOT_RESOLUTIONS.each do |res|
|
||||||
width, height = res.split('x').collect {|r| r.to_i}
|
width, height = res.split('x').collect {|r| r.to_i}
|
||||||
|
@ -72,7 +72,7 @@ class ScreenshotWorker
|
||||||
tmpfile_path = "/tmp/#{SecureRandom.uuid}.jpg"
|
tmpfile_path = "/tmp/#{SecureRandom.uuid}.jpg"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
new_img.write(tmpfile_path) { self.quality = 92 }
|
new_img.write(tmpfile_path) { |i| i.quality = 92 }
|
||||||
new_img.destroy!
|
new_img.destroy!
|
||||||
$image_optim.optimize_image! tmpfile_path
|
$image_optim.optimize_image! tmpfile_path
|
||||||
File.open(full_screenshot_path, 'wb') {|file| file.write File.read(tmpfile_path)}
|
File.open(full_screenshot_path, 'wb') {|file| file.write File.read(tmpfile_path)}
|
||||||
|
|
|
@ -43,8 +43,8 @@ class ThumbnailWorker
|
||||||
|
|
||||||
full_thumbnail_path = File.join(user_thumbnails_path, "#{path}.#{res}.#{save_ext}")
|
full_thumbnail_path = File.join(user_thumbnails_path, "#{path}.#{res}.#{save_ext}")
|
||||||
|
|
||||||
resimg.write(full_thumbnail_path) {
|
resimg.write(full_thumbnail_path) { |i|
|
||||||
self.quality = 75
|
i.quality = 75
|
||||||
}
|
}
|
||||||
resimg.destroy!
|
resimg.destroy!
|
||||||
#$image_optim.optimize_image! full_thumbnail_path
|
#$image_optim.optimize_image! full_thumbnail_path
|
||||||
|
|
Loading…
Add table
Reference in a new issue