diff --git a/Gemfile b/Gemfile index f9d91bfb..9ce0f998 100644 --- a/Gemfile +++ b/Gemfile @@ -87,7 +87,7 @@ group :test do gem 'rake', require: nil gem 'poltergeist' 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 'webmock', require: nil gem 'stripe-ruby-mock', '2.0.1', require: 'stripe_mock' diff --git a/Gemfile.lock b/Gemfile.lock index 94996c99..041a0009 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,8 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.4.0) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) ago (0.1.5) annoy (0.5.6) highline (>= 1.5.0) @@ -19,7 +20,7 @@ GEM blankslate (3.1.3) builder (3.2.2) byebug (8.2.4) - capybara (2.6.2) + capybara (2.10.1) addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -103,8 +104,8 @@ GEM mime-types (>= 1.16, < 4) metaclass (0.0.4) method_source (0.8.2) - mime-types (2.99.1) - mini_portile2 (2.0.0) + mime-types (2.99.3) + mini_portile2 (2.1.0) minitest (5.8.4) minitest-reporters (1.1.8) ansi @@ -115,22 +116,21 @@ GEM metaclass (~> 0.0.1) mock_redis (0.16.1) msgpack (0.7.5) - multi_json (1.11.2) + multi_json (1.12.1) multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (3.1.1) netrc (0.11.0) - nokogiri (1.6.7.2) - mini_portile2 (~> 2.0.0.rc2) + nokogiri (1.6.8.1) + mini_portile2 (~> 2.1.0) nokogumbo (1.4.7) nokogiri paypal-recurring (1.1.0) pg (0.18.4) - poltergeist (1.9.0) + poltergeist (1.11.0) capybara (~> 2.1) cliver (~> 0.3.1) - multi_json (~> 1.0) websocket-driver (>= 0.2.0) posix-spawn (0.3.11) pry (0.10.3) @@ -140,8 +140,9 @@ GEM pry-byebug (3.3.0) byebug (~> 8.0) pry (~> 0.10) + public_suffix (2.0.4) puma (3.4.0) - rack (1.6.4) + rack (1.6.5) rack-cache (1.6.1) rack (>= 0.4) rack-protection (1.5.3) @@ -235,7 +236,7 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - websocket-driver (0.6.3) + websocket-driver (0.6.4) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) will_paginate (3.1.0) @@ -252,7 +253,7 @@ DEPENDENCIES ago base32 bcrypt - capybara (= 2.6.2) + capybara (= 2.10.1) capybara_minitest_spec certified cocaine diff --git a/app/create.rb b/app/create.rb index c74f15a9..52f6e61b 100644 --- a/app/create.rb +++ b/app/create.rb @@ -1,5 +1,7 @@ def new_recaptcha_valid? + return true if session[:captcha_valid] == true return session[:captcha_valid] = true if ENV['RACK_ENV'] == 'test' || ENV['TRAVIS'] + return false unless params[:'g-recaptcha-response'] resp = Net::HTTP.get URI( 'https://www.google.com/recaptcha/api/siteverify?'+ Rack::Utils.build_query( @@ -84,6 +86,7 @@ post '/create' do if education_whitelisted? @site.email_confirmed = true else + new_recaptcha_valid? if session[:captcha_valid] != true flash[:error] = 'The captcha was not valid, please try again.' return {result: 'error'}.to_json diff --git a/app/supporter.rb b/app/supporter.rb index cc259344..39a5fa24 100644 --- a/app/supporter.rb +++ b/app/supporter.rb @@ -14,7 +14,6 @@ end post '/supporter/update' do require_login - plan_type = 'supporter' if is_special_upgrade diff --git a/tests/acceptance/signup_tests.rb b/tests/acceptance/signup_tests.rb index 591f60dc..cf25ffba 100644 --- a/tests/acceptance/signup_tests.rb +++ b/tests/acceptance/signup_tests.rb @@ -9,19 +9,9 @@ describe 'signup' do def fill_in_valid @site = Fabricate.attributes_for(:site) - - time = Time.now - begin - 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 + fill_in 'username', with: @site[:username] + fill_in 'password', with: @site[:password] + fill_in 'email', with: @site[:email] end def click_signup_button diff --git a/tests/acceptance/supporter_tests.rb b/tests/acceptance/supporter_tests.rb index 42fe8f7b..949c4b21 100644 --- a/tests/acceptance/supporter_tests.rb +++ b/tests/acceptance/supporter_tests.rb @@ -1,9 +1,16 @@ require_relative './environment.rb' +Capybara.register_driver :poltergeist do |app| + Capybara::Poltergeist::Driver.new(app, js_errors: false) +end + describe '/supporter' do include Capybara::DSL before do + Capybara.default_driver = :poltergeist + Capybara.reset_sessions! + @site = Fabricate :site @stripe_helper = StripeMock.create_test_helper StripeMock.start @@ -17,6 +24,7 @@ describe '/supporter' do after do StripeMock.stop + Capybara.default_driver = :rack_test end it 'should work for paypal' do @@ -25,16 +33,15 @@ describe '/supporter' do it 'should work for fresh signup' do visit '/supporter' - fill_in 'Card Number', with: '4242424242424242' - fill_in 'Expiration Month', with: '01' - fill_in 'Expiration Year', with: Date.today.next_year - fill_in 'Cardholder\'s Name', with: 'Penelope' - fill_in 'Card Validation Code', with: '123' - find('#stripe_token').set @stripe_helper.generate_card_token - #find('#upgradePlanType').set 'supporter' - click_link 'Upgrade for' + find('#cc_number', visible: false).set '4242424242424242' + find('#cc_exp_month', visible: false).set '01' + find('#cc_exp_year', visible: false).set Date.today.next_year.year.to_s[2..3] + find('#cc_name', visible: false).set 'Penelope' + find('#cc_cvc', visible: false).set '123' + find('#stripe_token', visible: false).set @stripe_helper.generate_card_token + click_link 'Upgrade for $5/mo' 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.stripe_customer_id.wont_be_nil @site.stripe_subscription_id.wont_be_nil diff --git a/views/supporter/index.erb b/views/supporter/index.erb deleted file mode 100644 index 8ca9203e..00000000 --- a/views/supporter/index.erb +++ /dev/null @@ -1 +0,0 @@ -<%== erb :'plan/_pricing' %> \ No newline at end of file