summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/support/test/integration/create_ticket_test.rb9
-rw-r--r--test/integration/api/cert_test.rb1
-rw-r--r--test/integration/api/smtp_cert_test.rb12
-rw-r--r--test/integration/api/srp_test.rb7
-rw-r--r--test/support/api_integration_test.rb7
-rw-r--r--test/support/browser_integration_test.rb5
6 files changed, 32 insertions, 9 deletions
diff --git a/engines/support/test/integration/create_ticket_test.rb b/engines/support/test/integration/create_ticket_test.rb
index 90e9a8a..00f9a6b 100644
--- a/engines/support/test/integration/create_ticket_test.rb
+++ b/engines/support/test/integration/create_ticket_test.rb
@@ -2,6 +2,11 @@ require 'test_helper'
class CreateTicketTest < BrowserIntegrationTest
+ setup do
+ @testcode = InviteCode.new
+ @testcode.save!
+ end
+
test "can submit ticket anonymously" do
visit '/'
click_on 'Get Help'
@@ -29,7 +34,7 @@ class CreateTicketTest < BrowserIntegrationTest
end
test "prefills fields" do
- login FactoryGirl.create(:premium_user)
+ login FactoryGirl.create(:premium_user, :invite_code => @testcode.invite_code)
visit '/'
click_on "Support Tickets"
click_on "New Ticket"
@@ -48,7 +53,7 @@ class CreateTicketTest < BrowserIntegrationTest
end
test "cleared email field should remain clear" do
- login FactoryGirl.create(:premium_user)
+ login FactoryGirl.create(:premium_user, :invite_code => @testcode.invite_code)
visit '/'
click_on "Support Tickets"
click_on "New Ticket"
diff --git a/test/integration/api/cert_test.rb b/test/integration/api/cert_test.rb
index 118fb9f..772901d 100644
--- a/test/integration/api/cert_test.rb
+++ b/test/integration/api/cert_test.rb
@@ -2,6 +2,7 @@ require 'test_helper'
class CertTest < ApiIntegrationTest
+
test "retrieve eip cert" do
login
get '/1/cert', {}, RACK_ENV
diff --git a/test/integration/api/smtp_cert_test.rb b/test/integration/api/smtp_cert_test.rb
index 2f50ef3..681d509 100644
--- a/test/integration/api/smtp_cert_test.rb
+++ b/test/integration/api/smtp_cert_test.rb
@@ -3,8 +3,13 @@ require 'openssl'
class SmtpCertTest < ApiIntegrationTest
+ setup do
+ @testcode = InviteCode.new
+ @testcode.save!
+ end
+
test "retrieve smtp cert" do
- @user = FactoryGirl.create :user, effective_service_level_code: 2
+ @user = FactoryGirl.create :user, effective_service_level_code: 2, :invite_code => @testcode.invite_code
login
post '/1/smtp_cert', {}, RACK_ENV
assert_text_response
@@ -15,7 +20,7 @@ class SmtpCertTest < ApiIntegrationTest
end
test "cert and key" do
- @user = FactoryGirl.create :user, effective_service_level_code: 2
+ @user = FactoryGirl.create :user, effective_service_level_code: 2, :invite_code => @testcode.invite_code
login
post '/1/smtp_cert', {}, RACK_ENV
assert_text_response
@@ -27,7 +32,7 @@ class SmtpCertTest < ApiIntegrationTest
end
test "fingerprint is stored with identity" do
- @user = FactoryGirl.create :user, effective_service_level_code: 2
+ @user = FactoryGirl.create :user, effective_service_level_code: 2, :invite_code => @testcode.invite_code
login
post '/1/smtp_cert', {}, RACK_ENV
assert_text_response
@@ -41,6 +46,7 @@ class SmtpCertTest < ApiIntegrationTest
end
test "fetching smtp certs requires email account" do
+
login
post '/1/smtp_cert', {}, RACK_ENV
assert_access_denied
diff --git a/test/integration/api/srp_test.rb b/test/integration/api/srp_test.rb
index ea06cde..463abcd 100644
--- a/test/integration/api/srp_test.rb
+++ b/test/integration/api/srp_test.rb
@@ -1,5 +1,10 @@
class SrpTest < RackTest
+ setup do
+ @testcode = InviteCode.new
+ @testcode.save!
+ end
+
teardown do
if @user
cleanup_user
@@ -32,7 +37,7 @@ class SrpTest < RackTest
attr_reader :server_auth
- def register_user(login = "integration_test", password = 'srp, verify me!', invite_code = "testcode")
+ def register_user(login = "integration_test", password = 'srp, verify me!', invite_code = @testcode.invite_code)
cleanup_user(login)
post 'http://api.lvh.me:3000/1/users.json',
user_params(login: login, password: password, invite_code: invite_code)
diff --git a/test/support/api_integration_test.rb b/test/support/api_integration_test.rb
index bd10f11..4077920 100644
--- a/test/support/api_integration_test.rb
+++ b/test/support/api_integration_test.rb
@@ -3,8 +3,13 @@ class ApiIntegrationTest < ActionDispatch::IntegrationTest
DUMMY_TOKEN = Token.new
RACK_ENV = {'HTTP_AUTHORIZATION' => %Q(Token token="#{DUMMY_TOKEN.to_s}")}
+ setup do
+ @testcode = InviteCode.new
+ @testcode.save!
+ end
+
def login(user = nil)
- @user ||= user ||= FactoryGirl.create(:user)
+ @user ||= user ||= FactoryGirl.create(:user, :invite_code => @testcode.invite_code)
# DUMMY_TOKEN will be frozen. So let's use a dup
@token ||= DUMMY_TOKEN.dup
# make sure @token is up to date if it already exists
diff --git a/test/support/browser_integration_test.rb b/test/support/browser_integration_test.rb
index f20421d..34ec9a6 100644
--- a/test/support/browser_integration_test.rb
+++ b/test/support/browser_integration_test.rb
@@ -37,7 +37,8 @@ class BrowserIntegrationTest < ActionDispatch::IntegrationTest
setup do
Capybara.current_driver = Capybara.javascript_driver
page.driver.add_headers 'ACCEPT-LANGUAGE' => 'en-EN'
- @invite_code = InviteCode.create(invite_code: "testcode")
+ @testcode = InviteCode.new
+ @testcode.save!
end
teardown do
@@ -51,7 +52,7 @@ class BrowserIntegrationTest < ActionDispatch::IntegrationTest
visit '/users/new'
fill_in 'Username', with: username
fill_in 'Password', with: password
- fill_in 'Invite code', with: "testcode"
+ fill_in 'Invite code', with: @testcode.invite_code
fill_in 'Password confirmation', with: password
click_on 'Sign Up'
return username, password