From 7d4a9efb5d1559d10c531998de7c009197d3e6bb Mon Sep 17 00:00:00 2001 From: Son NK Date: Fri, 20 Mar 2020 12:29:11 +0100 Subject: [PATCH] set user_id when creating AliasUsedOn --- app/api/views/new_custom_alias.py | 2 +- app/api/views/new_random_alias.py | 2 +- tests/api/test_alias_options.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/api/views/new_custom_alias.py b/app/api/views/new_custom_alias.py index 6fb6bd66..c097bc1a 100644 --- a/app/api/views/new_custom_alias.py +++ b/app/api/views/new_custom_alias.py @@ -72,7 +72,7 @@ def new_custom_alias(): db.session.commit() if hostname: - AliasUsedOn.create(alias_id=alias.id, hostname=hostname) + AliasUsedOn.create(alias_id=alias.id, hostname=hostname, user_id=alias.user_id) db.session.commit() return jsonify(alias=full_alias), 201 diff --git a/app/api/views/new_random_alias.py b/app/api/views/new_random_alias.py index b023b210..62dd175a 100644 --- a/app/api/views/new_random_alias.py +++ b/app/api/views/new_random_alias.py @@ -52,7 +52,7 @@ def new_random_alias(): hostname = request.args.get("hostname") if hostname: - AliasUsedOn.create(alias_id=alias.id, hostname=hostname) + AliasUsedOn.create(alias_id=alias.id, hostname=hostname, user_id=alias.user_id) db.session.commit() return jsonify(alias=alias.email), 201 diff --git a/tests/api/test_alias_options.py b/tests/api/test_alias_options.py index 418380a7..e84fc448 100644 --- a/tests/api/test_alias_options.py +++ b/tests/api/test_alias_options.py @@ -42,7 +42,7 @@ def test_different_scenarios(flask_client): # <<< with recommendation >>> alias = Alias.create_new(user, prefix="test") db.session.commit() - AliasUsedOn.create(alias_id=alias.id, hostname="www.test.com") + AliasUsedOn.create(alias_id=alias.id, hostname="www.test.com", user_id=user.id) db.session.commit() r = flask_client.get( @@ -87,7 +87,9 @@ def test_different_scenarios_v2(flask_client): # <<< with recommendation >>> alias = Alias.create_new(user, prefix="test") db.session.commit() - AliasUsedOn.create(alias_id=alias.id, hostname="www.test.com") + AliasUsedOn.create( + alias_id=alias.id, hostname="www.test.com", user_id=alias.user_id + ) db.session.commit() r = flask_client.get(