summaryrefslogtreecommitdiff
path: root/tests/helpers/bonafide_helper.rb
diff options
context:
space:
mode:
authorkwadronaut <kwadronaut@leap.se>2015-11-12 10:00:27 +0100
committerkwadronaut <kwadronaut@leap.se>2015-11-12 10:00:27 +0100
commit92cc2b1118e98a4fb086d7c62a140dbfc845f4b0 (patch)
tree92896619c0cf4ace177cecfbdea6cbbbb9bc8419 /tests/helpers/bonafide_helper.rb
parent81467100826ad95266a4c29b11a2ecef759dd782 (diff)
parent7d0b6b25e49a1ccb70c4f502f7dfc58878b900cc (diff)
Merge remote-tracking branch 'origin/develop' into HEAD
Diffstat (limited to 'tests/helpers/bonafide_helper.rb')
-rw-r--r--tests/helpers/bonafide_helper.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/helpers/bonafide_helper.rb b/tests/helpers/bonafide_helper.rb
index 9b26eaaf..82db3973 100644
--- a/tests/helpers/bonafide_helper.rb
+++ b/tests/helpers/bonafide_helper.rb
@@ -32,7 +32,15 @@ class LeapTest
def assert_create_user
user = SRP::User.new
url = api_url("/1/users.json")
- assert_post(url, user.to_params) do |body|
+
+ params = user.to_params
+
+ if property('webapp.invite_required')
+ @invite_code = generate_invite_code
+ params['user[invite_code]'] = @invite_code
+ end
+
+ assert_post(url, params) do |body|
assert response = JSON.parse(body), 'response should be JSON'
assert response['ok'], "Creating a user should be successful, got #{response.inspect} instead."
end
@@ -40,6 +48,11 @@ class LeapTest
return user
end
+ def generate_invite_code
+ `cd /srv/leap/webapp/ && sudo -u leap-webapp RAILS_ENV=production bundle exec rake generate_invites[1]`.gsub(/\n/, "")
+ end
+
+
#
# attempts to authenticate user. if successful,
# user object is updated with id and session token.