diff options
author | Azul <azul@leap.se> | 2014-05-15 10:40:21 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-05-19 14:24:47 +0200 |
commit | 1241cb8f13e6d0752b67521e8385b62d7fbcc882 (patch) | |
tree | 0fbec07bd9f22e052840df93a927265bdb073542 /test/support/api_integration_test.rb | |
parent | e94b9471c0bc30cd6a1a5bf5b6b22b746d242e31 (diff) |
basic integration test for cert API
Diffstat (limited to 'test/support/api_integration_test.rb')
-rw-r--r-- | test/support/api_integration_test.rb | 23 |
1 files changed, 23 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..50c528b --- /dev/null +++ b/test/support/api_integration_test.rb @@ -0,0 +1,23 @@ +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) + @token ||= DUMMY_TOKEN + @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 |