mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
acceptance tests for supporter upgrade
This commit is contained in:
parent
81c9a4c94c
commit
779b44c121
1 changed files with 50 additions and 0 deletions
50
tests/acceptance/plan_tests.rb
Normal file
50
tests/acceptance/plan_tests.rb
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
require_relative './environment.rb'
|
||||||
|
|
||||||
|
include Rack::Test::Methods
|
||||||
|
|
||||||
|
def app
|
||||||
|
Sinatra::Application
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '/plan' do
|
||||||
|
include Capybara::DSL
|
||||||
|
|
||||||
|
before do
|
||||||
|
@site = Fabricate :site
|
||||||
|
@stripe_helper = StripeMock.create_test_helper
|
||||||
|
StripeMock.start
|
||||||
|
@stripe_helper.create_plan id: 'special', amount: 0
|
||||||
|
@stripe_helper.create_plan id: 'supporter', amount: 500
|
||||||
|
@stripe_helper.create_plan id: 'free', amount: 0
|
||||||
|
page.set_rack_session id: @site.id
|
||||||
|
EmailWorker.jobs.clear
|
||||||
|
Mail::TestMailer.deliveries.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
StripeMock.stop
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should work for fresh signup' do
|
||||||
|
visit '/plan'
|
||||||
|
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_button 'Upgrade'
|
||||||
|
page.current_path.must_equal '/plan/thanks'
|
||||||
|
page.body.must_match /You now have the Supporter plan./
|
||||||
|
@site.reload
|
||||||
|
@site.stripe_customer_id.wont_be_nil
|
||||||
|
@site.stripe_subscription_id.wont_be_nil
|
||||||
|
@site.values[:plan_type].must_equal 'supporter'
|
||||||
|
@site.supporter?.must_equal true
|
||||||
|
|
||||||
|
EmailWorker.drain
|
||||||
|
mail = Mail::TestMailer.deliveries.first
|
||||||
|
mail.subject.must_match "You've become a supporter"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue