summaryrefslogtreecommitdiff
path: root/tests/helpers/bonafide_helper.rb
diff options
context:
space:
mode:
authorankonym <ankonym@gmail.com>2015-10-07 11:19:26 +0200
committerankonym <ankonym@gmail.com>2015-10-07 11:19:26 +0200
commitb53bd889d5407fb357329b414bcae929176c0690 (patch)
treee1a57b909548525b2786b7449eac425be5a5bedd /tests/helpers/bonafide_helper.rb
parent3224a73ec6b2f06cf4c43f86d5b7673e442043dd (diff)
Change webapp tests to work with enabled invite codes
This will generate an invite code so test_05_Can_create_and_authenticate_and_delete_user_via_API? will work correctly (when invite codes are required for signups).
Diffstat (limited to 'tests/helpers/bonafide_helper.rb')
-rw-r--r--tests/helpers/bonafide_helper.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/helpers/bonafide_helper.rb b/tests/helpers/bonafide_helper.rb
index 9b26eaaf..39f761fe 100644
--- a/tests/helpers/bonafide_helper.rb
+++ b/tests/helpers/bonafide_helper.rb
@@ -32,7 +32,11 @@ 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
+ params['user[invite_code]'] = generate_invite_code
+
+ 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 +44,13 @@ class LeapTest
return user
end
+ def generate_invite_code
+ if property('webapp.invite_required')
+ `cd /srv/leap/webapp/ && sudo RAILS_ENV=production bundle exec rake generate_invites[1]`.gsub(/\n/, "")
+ end
+ end
+
+
#
# attempts to authenticate user. if successful,
# user object is updated with id and session token.