summaryrefslogtreecommitdiff
path: root/test/support/api_integration_test.rb
diff options
context:
space:
mode:
authorazul <azul@leap.se>2014-05-26 10:08:07 +0200
committerazul <azul@leap.se>2014-05-26 10:08:07 +0200
commitdf298887221cffc8cacc8965d73a0d7850118849 (patch)
treee13fc7c05956b10ca051377b89487d97e659528d /test/support/api_integration_test.rb
parent0f686b1256b4190522bcb101ba06cd2c7406eb36 (diff)
parentf221e5313fe54a2efa127b547916c7c812110449 (diff)
Merge pull request #165 from azul/feature/cert-fingerprints
Feature/cert fingerprints
Diffstat (limited to 'test/support/api_integration_test.rb')
-rw-r--r--test/support/api_integration_test.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/support/api_integration_test.rb b/test/support/api_integration_test.rb
new file mode 100644
index 0000000..bd10f11
--- /dev/null
+++ b/test/support/api_integration_test.rb
@@ -0,0 +1,26 @@
+class ApiIntegrationTest < ActionDispatch::IntegrationTest
+
+ DUMMY_TOKEN = Token.new
+ RACK_ENV = {'HTTP_AUTHORIZATION' => %Q(Token token="#{DUMMY_TOKEN.to_s}")}
+
+ def login(user = nil)
+ @user ||= user ||= FactoryGirl.create(:user)
+ # 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
+ @token.reload if @token.persisted?
+ @token.user_id = @user.id
+ @token.last_seen_at = Time.now
+ @token.save
+ end
+
+ teardown do
+ if @user && @user.persisted?
+ Identity.destroy_all_for @user
+ @user.reload.destroy
+ end
+ if @token && @token.persisted?
+ @token.reload.destroy
+ end
+ end
+end