mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
fixes for broken/flaky tests and remove unused template
This commit is contained in:
parent
a8a83c434e
commit
4fca52e03d
7 changed files with 36 additions and 37 deletions
2
Gemfile
2
Gemfile
|
@ -87,7 +87,7 @@ group :test do
|
||||||
gem 'rake', require: nil
|
gem 'rake', require: nil
|
||||||
gem 'poltergeist'
|
gem 'poltergeist'
|
||||||
gem 'capybara_minitest_spec'
|
gem 'capybara_minitest_spec'
|
||||||
gem 'capybara', '2.6.2', require: nil
|
gem 'capybara', '2.10.1', require: nil
|
||||||
gem 'rack_session_access', require: nil
|
gem 'rack_session_access', require: nil
|
||||||
gem 'webmock', require: nil
|
gem 'webmock', require: nil
|
||||||
gem 'stripe-ruby-mock', '2.0.1', require: 'stripe_mock'
|
gem 'stripe-ruby-mock', '2.0.1', require: 'stripe_mock'
|
||||||
|
|
25
Gemfile.lock
25
Gemfile.lock
|
@ -9,7 +9,8 @@ GEM
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
thread_safe (~> 0.3, >= 0.3.4)
|
thread_safe (~> 0.3, >= 0.3.4)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
addressable (2.4.0)
|
addressable (2.5.0)
|
||||||
|
public_suffix (~> 2.0, >= 2.0.2)
|
||||||
ago (0.1.5)
|
ago (0.1.5)
|
||||||
annoy (0.5.6)
|
annoy (0.5.6)
|
||||||
highline (>= 1.5.0)
|
highline (>= 1.5.0)
|
||||||
|
@ -19,7 +20,7 @@ GEM
|
||||||
blankslate (3.1.3)
|
blankslate (3.1.3)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
byebug (8.2.4)
|
byebug (8.2.4)
|
||||||
capybara (2.6.2)
|
capybara (2.10.1)
|
||||||
addressable
|
addressable
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
|
@ -103,8 +104,8 @@ GEM
|
||||||
mime-types (>= 1.16, < 4)
|
mime-types (>= 1.16, < 4)
|
||||||
metaclass (0.0.4)
|
metaclass (0.0.4)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (2.99.1)
|
mime-types (2.99.3)
|
||||||
mini_portile2 (2.0.0)
|
mini_portile2 (2.1.0)
|
||||||
minitest (5.8.4)
|
minitest (5.8.4)
|
||||||
minitest-reporters (1.1.8)
|
minitest-reporters (1.1.8)
|
||||||
ansi
|
ansi
|
||||||
|
@ -115,22 +116,21 @@ GEM
|
||||||
metaclass (~> 0.0.1)
|
metaclass (~> 0.0.1)
|
||||||
mock_redis (0.16.1)
|
mock_redis (0.16.1)
|
||||||
msgpack (0.7.5)
|
msgpack (0.7.5)
|
||||||
multi_json (1.11.2)
|
multi_json (1.12.1)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
net-scp (1.2.1)
|
net-scp (1.2.1)
|
||||||
net-ssh (>= 2.6.5)
|
net-ssh (>= 2.6.5)
|
||||||
net-ssh (3.1.1)
|
net-ssh (3.1.1)
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
nokogiri (1.6.7.2)
|
nokogiri (1.6.8.1)
|
||||||
mini_portile2 (~> 2.0.0.rc2)
|
mini_portile2 (~> 2.1.0)
|
||||||
nokogumbo (1.4.7)
|
nokogumbo (1.4.7)
|
||||||
nokogiri
|
nokogiri
|
||||||
paypal-recurring (1.1.0)
|
paypal-recurring (1.1.0)
|
||||||
pg (0.18.4)
|
pg (0.18.4)
|
||||||
poltergeist (1.9.0)
|
poltergeist (1.11.0)
|
||||||
capybara (~> 2.1)
|
capybara (~> 2.1)
|
||||||
cliver (~> 0.3.1)
|
cliver (~> 0.3.1)
|
||||||
multi_json (~> 1.0)
|
|
||||||
websocket-driver (>= 0.2.0)
|
websocket-driver (>= 0.2.0)
|
||||||
posix-spawn (0.3.11)
|
posix-spawn (0.3.11)
|
||||||
pry (0.10.3)
|
pry (0.10.3)
|
||||||
|
@ -140,8 +140,9 @@ GEM
|
||||||
pry-byebug (3.3.0)
|
pry-byebug (3.3.0)
|
||||||
byebug (~> 8.0)
|
byebug (~> 8.0)
|
||||||
pry (~> 0.10)
|
pry (~> 0.10)
|
||||||
|
public_suffix (2.0.4)
|
||||||
puma (3.4.0)
|
puma (3.4.0)
|
||||||
rack (1.6.4)
|
rack (1.6.5)
|
||||||
rack-cache (1.6.1)
|
rack-cache (1.6.1)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
rack-protection (1.5.3)
|
rack-protection (1.5.3)
|
||||||
|
@ -235,7 +236,7 @@ GEM
|
||||||
addressable (>= 2.3.6)
|
addressable (>= 2.3.6)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff
|
hashdiff
|
||||||
websocket-driver (0.6.3)
|
websocket-driver (0.6.4)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.2)
|
websocket-extensions (0.1.2)
|
||||||
will_paginate (3.1.0)
|
will_paginate (3.1.0)
|
||||||
|
@ -252,7 +253,7 @@ DEPENDENCIES
|
||||||
ago
|
ago
|
||||||
base32
|
base32
|
||||||
bcrypt
|
bcrypt
|
||||||
capybara (= 2.6.2)
|
capybara (= 2.10.1)
|
||||||
capybara_minitest_spec
|
capybara_minitest_spec
|
||||||
certified
|
certified
|
||||||
cocaine
|
cocaine
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
def new_recaptcha_valid?
|
def new_recaptcha_valid?
|
||||||
|
return true if session[:captcha_valid] == true
|
||||||
return session[:captcha_valid] = true if ENV['RACK_ENV'] == 'test' || ENV['TRAVIS']
|
return session[:captcha_valid] = true if ENV['RACK_ENV'] == 'test' || ENV['TRAVIS']
|
||||||
|
return false unless params[:'g-recaptcha-response']
|
||||||
resp = Net::HTTP.get URI(
|
resp = Net::HTTP.get URI(
|
||||||
'https://www.google.com/recaptcha/api/siteverify?'+
|
'https://www.google.com/recaptcha/api/siteverify?'+
|
||||||
Rack::Utils.build_query(
|
Rack::Utils.build_query(
|
||||||
|
@ -84,6 +86,7 @@ post '/create' do
|
||||||
if education_whitelisted?
|
if education_whitelisted?
|
||||||
@site.email_confirmed = true
|
@site.email_confirmed = true
|
||||||
else
|
else
|
||||||
|
new_recaptcha_valid?
|
||||||
if session[:captcha_valid] != true
|
if session[:captcha_valid] != true
|
||||||
flash[:error] = 'The captcha was not valid, please try again.'
|
flash[:error] = 'The captcha was not valid, please try again.'
|
||||||
return {result: 'error'}.to_json
|
return {result: 'error'}.to_json
|
||||||
|
|
|
@ -14,7 +14,6 @@ end
|
||||||
|
|
||||||
post '/supporter/update' do
|
post '/supporter/update' do
|
||||||
require_login
|
require_login
|
||||||
|
|
||||||
plan_type = 'supporter'
|
plan_type = 'supporter'
|
||||||
|
|
||||||
if is_special_upgrade
|
if is_special_upgrade
|
||||||
|
|
|
@ -9,19 +9,9 @@ describe 'signup' do
|
||||||
|
|
||||||
def fill_in_valid
|
def fill_in_valid
|
||||||
@site = Fabricate.attributes_for(:site)
|
@site = Fabricate.attributes_for(:site)
|
||||||
|
fill_in 'username', with: @site[:username]
|
||||||
time = Time.now
|
fill_in 'password', with: @site[:password]
|
||||||
begin
|
fill_in 'email', with: @site[:email]
|
||||||
fill_in 'username', with: @site[:username]
|
|
||||||
fill_in 'password', with: @site[:password]
|
|
||||||
fill_in 'email', with: @site[:email]
|
|
||||||
rescue Capybara::ElementNotFound
|
|
||||||
puts "Waiting on fill_in #{Time.now - time} seconds"
|
|
||||||
raise if Time.now - time > 30
|
|
||||||
visit_signup
|
|
||||||
sleep 0.5
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def click_signup_button
|
def click_signup_button
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
require_relative './environment.rb'
|
require_relative './environment.rb'
|
||||||
|
|
||||||
|
Capybara.register_driver :poltergeist do |app|
|
||||||
|
Capybara::Poltergeist::Driver.new(app, js_errors: false)
|
||||||
|
end
|
||||||
|
|
||||||
describe '/supporter' do
|
describe '/supporter' do
|
||||||
include Capybara::DSL
|
include Capybara::DSL
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
Capybara.default_driver = :poltergeist
|
||||||
|
Capybara.reset_sessions!
|
||||||
|
|
||||||
@site = Fabricate :site
|
@site = Fabricate :site
|
||||||
@stripe_helper = StripeMock.create_test_helper
|
@stripe_helper = StripeMock.create_test_helper
|
||||||
StripeMock.start
|
StripeMock.start
|
||||||
|
@ -17,6 +24,7 @@ describe '/supporter' do
|
||||||
|
|
||||||
after do
|
after do
|
||||||
StripeMock.stop
|
StripeMock.stop
|
||||||
|
Capybara.default_driver = :rack_test
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should work for paypal' do
|
it 'should work for paypal' do
|
||||||
|
@ -25,16 +33,15 @@ describe '/supporter' do
|
||||||
|
|
||||||
it 'should work for fresh signup' do
|
it 'should work for fresh signup' do
|
||||||
visit '/supporter'
|
visit '/supporter'
|
||||||
fill_in 'Card Number', with: '4242424242424242'
|
find('#cc_number', visible: false).set '4242424242424242'
|
||||||
fill_in 'Expiration Month', with: '01'
|
find('#cc_exp_month', visible: false).set '01'
|
||||||
fill_in 'Expiration Year', with: Date.today.next_year
|
find('#cc_exp_year', visible: false).set Date.today.next_year.year.to_s[2..3]
|
||||||
fill_in 'Cardholder\'s Name', with: 'Penelope'
|
find('#cc_name', visible: false).set 'Penelope'
|
||||||
fill_in 'Card Validation Code', with: '123'
|
find('#cc_cvc', visible: false).set '123'
|
||||||
find('#stripe_token').set @stripe_helper.generate_card_token
|
find('#stripe_token', visible: false).set @stripe_helper.generate_card_token
|
||||||
#find('#upgradePlanType').set 'supporter'
|
click_link 'Upgrade for $5/mo'
|
||||||
click_link 'Upgrade for'
|
|
||||||
page.current_path.must_equal '/supporter/thanks'
|
page.current_path.must_equal '/supporter/thanks'
|
||||||
page.body.must_match /You now have the Supporter plan./
|
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
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
<%== erb :'plan/_pricing' %>
|
|
Loading…
Add table
Reference in a new issue