[MUSIC] In this lecture, we will discuss user registration and how we're going to create a user account through the API. We'll also talk about devise strong parameters and what we need to do to whitelist any custom parameters we have in our registrations and we'll build our first real factory, something besides and foo and a bar. We'll build a factory that represents the properties of the user. A good place to start with any test is obviously taking care of our database clean up. So we're going to include context, db_cleanup and we're going to go ahead and clean up after each test. And I'm going to go ahead and use transactions not because I have to, because yeah, I can. All we're using is the relational database at this point and let's focus in on the sign up. In order to sign up, I'm going to need some user properties and I'll store that into the user props variable and I'll create a let clause with the user props. So, let's take a look at signing up successfully. What I'll need to do is post to the user_registration_path, a set of registration parameters like user_props for that and then response for that should come back okay. And since it's early, I'm starting out by putting some debug. We could execute this now. However, they refer to a factory that doesn't quite exist yet, user. So in order to run this, we really need to create that factory first. So I'll just go ahead and start it, manually. And when we sign up, we're going to need name, email, and password. And we're going to generate a value, a unique value, each time. So we're going to be executing a block and inside of here, I'll go ahead and create some fake names emails. Those are probably all the passwords you don't want to use. We have our sample user. Let's go ahead and run this, and see what we're missing. Hey, everything looks good. We submitted a document with name, email and password and we created an account. Account number one, it's authentication type is email. It's going to do a uid across all of its providers. It's going to use email and you'll notice name is nil, that's not quite right. We can fix that, although not horrible. And then specifically, here's our email and when we were created. So, we happen to notice through inspection that name wasn't echoed back. So, we don't want to be inspecting things all the time. We want to actually have our test tell us that. To speed things up, let me go ahead and bring in a block of inspectors that looks at that payload. We expect the status to be successful. We expect to have a data payload and data information. And now when we rerun, it fails, because our name wasn't supplied. So, why is that? Through your familiarity with rails, you should be familiar with something called strong parameters and wait listing. Well, we're talking to the devise infrastructure and the devise infrastructure out of the box comes by allowing certain things through. Email, obviously, and password were allowed through. So, what we need to do is head over to the application controller and add a white list entry for our name. So we're going to say, hey, devise sanitizer permit during sign up that we pass in name. And of course, that goes nowhere until we wire it in. And say, if you're the devise_controller, then what we'd like for you to do is run this method which will configure your white listing. Now if we rerun the test, everything passes and we don't have to look at anything. Sign-up, looks like it's working. We can get an account. Our account registration primarily takes email and password. That's all white listed by devise. Name was added in as a custom parameter out of the box by Devise Token off, but still required for it to be white listed for it to be accepted at registration time. We could add more parameters like phone number, points of contact, things like that. We'll just stick with some of the basics and then we took a look at whitelisting. Anything beyond email and password needs to be explicitly allowed through a configuration command, then we build a factory that represented a user, something more than just a food. We had name, email and password. What's next? Account Sign-Up Failures and Error Payloads. Let's look at some of the failure scenarios and understand the error payloads coming back from devise, so that when we move over to the UI, we know how to handle them.