Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#162575779 Fix Bug in Profiles App #20

Merged
merged 1 commit into from
Dec 11, 2018

Conversation

ghost
Copy link

@ghost ghost commented Dec 11, 2018

What does this PR do?

This PR adds functionality for auto-populating the username filed on the Profile model when a user signs up.

Description of Task to be completed?

How should this be manually tested?

It can be tested on Postman as below:

  1. Run the following commands in Terminal
git clone git@github.com:andela/ah-jumanji.git
git checkout fix-bug-in-profiles-app-162575779
virtualenv venv && source venv/bin/activate
pip install -r requirements.txt
touch .env

Update the .env file as follows:

DATABASE_URL=postgres://{postgres-db-username}:{postgres-db-password}@localhost/ah_jumanji
export PROTOCOL="http://"
export EMAIL_HOST_USER="jumanjidevs32@gmail.com"
export EMAIL_HOST_PASSWORD="jumanji@32"

Continue in Terminal

python manage.py makemigrations && python manage.py migrate
python manage.py makemigrations profiles && python manage.py migrate profiles
python manage.py runserver
  1. Send a POST {your-server-root}:8000/api/users/register request with a payload similar to:
{"user": {
   "username": "cmithamo",
   "email": "cmithamo@mymail.com",
   "password": "Strong#3-password"
   }
}

to register a User and generate an auth token
3. Activate the account by clicking on the link sent in the activation email.
4. With the auth token generated, send a GET {your-server-root}:8000/api/users/profiles request to view the auto-generated profile for the user just now created.
[See screenshot for sample response]

  1. Run the tests using pytest with the command pytest [or pytest -v for verbose output].

Any background context you want to provide?

Previously, on user account creation, the first_name field on the Profile was populated with the username of the registered user. This PR changes that, because there is functionality which depends on querying the profiles table by username.

What are the relevant pivotal tracker stories?

#162575779

Screenshots (if appropriate)

View on GET /api/users/profiles with logged in user
image

Questions:

Checklist:

  • My code follows the style guidelines of this project
  • At least 2 people have reviewed my PR
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • My PR has one commit.

@ghost ghost requested review from GransonO, mashafrancis and fabzer0 December 11, 2018 12:00
@ghost ghost changed the title # Fix Bug: Auto-populate username Field in Profile on User Account Creation #162575779 Fix Bug in Profiles App Dec 11, 2018
Copy link
Contributor

@GransonO GransonO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good step to resolving the bug. Can be merged so that other users can implement the recent changes.

Copy link
Contributor

@GransonO GransonO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I noticed the Coverage has decreased? why would this be so?

Copy link
Contributor

@mashafrancis mashafrancis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good step in resolving the error in the code.

- autopopulate username field on user registration
[Delivers #162575779]
@ghost ghost force-pushed the fix-bug-in-profiles-app-162575779 branch from e8138f7 to 0b84ef3 Compare December 11, 2018 13:39
@mirr254 mirr254 merged commit fde9892 into develop Dec 11, 2018
@ghost ghost deleted the fix-bug-in-profiles-app-162575779 branch December 17, 2018 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants