2015-10-05 12:40:08 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
feature 'Support announcement' do
|
|
|
|
|
scenario 'User announces support' do
|
|
|
|
|
visit root_path
|
|
|
|
|
|
|
|
|
|
fill_in 'Vorname', with: 'Christoph'
|
|
|
|
|
fill_in 'Nachname', with: 'Blocher'
|
2015-10-05 14:10:07 +02:00
|
|
|
fill_in 'Strasse/Nr.', with: 'Wängirain 53'
|
2015-10-05 12:40:08 +02:00
|
|
|
fill_in 'Postleitzahl', with: '8704'
|
2015-10-06 13:07:01 +02:00
|
|
|
fill_in 'Ort', with: 'Herrliberg'
|
2015-10-05 12:40:08 +02:00
|
|
|
fill_in 'E-Mail', with: 'blocher@blocher.ch'
|
2015-11-01 11:03:54 +01:00
|
|
|
fill_in 'Kommentar / Feedback', with: 'Test text'
|
2015-10-05 12:40:08 +02:00
|
|
|
|
2016-04-18 21:16:42 +02:00
|
|
|
choose 'Ich würde eine Volksinitiative für die Legalisierung von Cannabis unterschreiben und helfe aktiv Unterschriften in meiner Umgebung zu sammeln.'
|
2015-10-05 12:40:08 +02:00
|
|
|
|
|
|
|
|
choose 'Ich bin über 64 Jahre alt'
|
|
|
|
|
|
2016-03-29 21:57:14 +02:00
|
|
|
check 'Ich bin interessiert an einer Mitgliedschaft beim Verein Legalize it! (50 Franken pro Jahr)'
|
|
|
|
|
|
2016-03-29 22:19:48 +02:00
|
|
|
sleep 5 # Do a real sleep to have a real integration test
|
|
|
|
|
|
2016-04-08 15:22:31 +02:00
|
|
|
expect(ActionMailer::Base.deliveries.count).to eq 0
|
2016-11-15 10:05:53 +01:00
|
|
|
expect_any_instance_of(SupportersController).to receive(:mailchimp_registration).and_return(true)
|
|
|
|
|
|
2015-10-05 12:40:08 +02:00
|
|
|
expect { click_button 'Unterstützung zusichern' }.to change { Supporter.count }.by(1)
|
2016-04-21 21:05:45 +02:00
|
|
|
# expect(ActionMailer::Base.deliveries.count).to eq 1
|
2015-11-01 11:03:54 +01:00
|
|
|
supporter = Supporter.find_by(email: 'blocher@blocher.ch')
|
|
|
|
|
expect(supporter.coordinates).to eq [8.618589100000001, 47.2926304]
|
|
|
|
|
expect(supporter.comments).to eq 'Test text'
|
2015-11-09 10:33:26 +01:00
|
|
|
expect(supporter.language).to eq 'de'
|
2016-03-29 21:57:14 +02:00
|
|
|
expect(supporter.li_membership).to eq true
|
2015-10-05 12:40:08 +02:00
|
|
|
end
|
2015-10-06 09:16:07 +02:00
|
|
|
|
|
|
|
|
scenario 'A bot tries to enter data' do
|
2016-03-29 22:26:43 +02:00
|
|
|
stub_const('ApplicationController::INPUT_TIMEOUT', 600.seconds)
|
|
|
|
|
|
2015-10-06 09:16:07 +02:00
|
|
|
visit root_path
|
|
|
|
|
|
|
|
|
|
click_button 'Unterstützung zusichern'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content 'Ihre Eingabe war zu schnell.'
|
2015-10-06 09:30:35 +02:00
|
|
|
|
2015-10-06 09:16:07 +02:00
|
|
|
# Test twice just to be sure that it's not become an update action
|
|
|
|
|
click_button 'Unterstützung zusichern'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content 'Ihre Eingabe war zu schnell.'
|
|
|
|
|
end
|
2015-10-05 12:40:08 +02:00
|
|
|
end
|