summaryrefslogtreecommitdiff
path: root/test/support/browser_integration_test.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-13 09:51:36 +0200
committerAzul <azul@leap.se>2014-05-13 09:51:41 +0200
commit86eb9062f1e81302647bf18ce0f5fd981202b68a (patch)
treea1d63177b67c11e71f53c400cd9424588be1a7ec /test/support/browser_integration_test.rb
parent726244f1c6bb72fb53a257c084dfbdf7b9c2b03c (diff)
allow for usernames with dots
preparing for #5664 with some test improvements i ran into this issue This commit includes a fix and the test improvements. In particular it adds BrowserIntegrationTest#login - so there is no need to go through the signup procedure everytime you want a user to be logged in.
Diffstat (limited to 'test/support/browser_integration_test.rb')
-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