From 50b4a1a48f9f62335baf9be0eb1fcb15c4091bd8 Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Fri, 16 Jun 2017 09:39:55 -0600 Subject: [PATCH] Add basic integration test for signup form on the example static site. --- test/static_site/test_signup.rb | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/static_site/test_signup.rb diff --git a/test/static_site/test_signup.rb b/test/static_site/test_signup.rb new file mode 100644 index 000000000..1e9c2c038 --- /dev/null +++ b/test/static_site/test_signup.rb @@ -0,0 +1,38 @@ +require_relative "../test_helper" + +class Test::StaticSite::TestSignup < Minitest::Capybara::Test + include Capybara::Screenshot::MiniTestPlugin + include ApiUmbrellaTestHelpers::Setup + include ApiUmbrellaTestHelpers::DelayedJob + + def setup + super + setup_server + ApiUser.where(:registration_source.ne => "seed").delete_all + + response = Typhoeus.delete("http://127.0.0.1:#{$config["mailhog"]["api_port"]}/api/v1/messages") + assert_response_code(200, response) + end + + def test_submission + visit "/signup/" + assert_text("API Key Signup") + + fill_in "First Name", :with => "Foo" + fill_in "Last Name", :with => "Bar" + fill_in "Email", :with => "foo@example.com" + check "I have read and agree to the terms and conditions." + click_button "Signup" + + assert_text("Your API key for foo@example.com is:") + + user = ApiUser.order_by(:created_at.asc).last + assert(user) + assert(user.api_key) + assert_equal("foo@example.com", user.email) + assert_text(user.api_key) + + messages = delayed_job_sent_messages + assert_equal(1, messages.length) + end +end