summaryrefslogtreecommitdiff
path: root/test/support
diff options
context:
space:
mode:
Diffstat (limited to 'test/support')
-rw-r--r--test/support/browser_integration_test.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/support/browser_integration_test.rb b/test/support/browser_integration_test.rb
index 9cae8cb..836eb63 100644
--- a/test/support/browser_integration_test.rb
+++ b/test/support/browser_integration_test.rb
@@ -53,6 +53,22 @@ class BrowserIntegrationTest < ActionDispatch::IntegrationTest
return username, password
end
+ # currently this only works for tests with poltergeist.
+ def login(user = nil)
+ user ||= @user ||= FactoryGirl.create(:user)
+ token = Token.create user_id: user.id
+ page.driver.add_header "Authorization",
+ 'Token token="' + token.to_s + '"'
+ visit '/'
+ end
+
+ teardown do
+ if @user && @user.reload
+ Identity.destroy_all_for @user
+ @user.destroy
+ end
+ end
+
add_teardown_hook do |testcase|
unless testcase.passed?
testcase.save_state