Skip to content

Commit

Permalink
Add basic integration test for signup form on the example static site.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Jun 16, 2017
1 parent 96862e0 commit 50b4a1a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/static_site/test_signup.rb
Original file line number Diff line number Diff line change
@@ -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 => "[email protected]"
check "I have read and agree to the terms and conditions."
click_button "Signup"

assert_text("Your API key for [email protected] is:")

user = ApiUser.order_by(:created_at.asc).last
assert(user)
assert(user.api_key)
assert_equal("[email protected]", user.email)
assert_text(user.api_key)

messages = delayed_job_sent_messages
assert_equal(1, messages.length)
end
end

0 comments on commit 50b4a1a

Please sign in to comment.