concept new user in category rails

This is an excerpt from Manning's book Rails 4 in Action: Revised Edition of Rails 3 in Action.
This factory can be used to create new users in your tests. The sequence method will generate sequential email addresses for your users, such as test1@example.com and test2@example.com. You do this so that each user has a unique email address, and that will keep Devise’s unique email validation happy.
Why do it in a before_action? Because this User management form is used in multiple places: when creating a new user (new action), when rerendering the form if creating a user fails (create action), when editing a user (edit action), and when re-rendering the form if editing a user fails (update action). You’ll need the same data loaded for all four of those actions to render the view successfully, and instead of repeating the same code four times, you can just put it in a before_action to define it once. So far so good.
But what about new users? This roles section will appear on the new-user form too, but you haven’t written any code to save roles that you assign when you create a new user. You can add a spec for that to managing_roles_spec.rb, and see if it passes.
Listing 8.84. Another scenario, for assigning roles when creating a new user
scenario "when assigning roles to a new user" do visit new_admin_user_path fill_in "Email", with: "newuser@ticketee.com" fill_in "Password", with: "password" select "Editor", from: "Internet Explorer" click_button "Create User" click_link "newuser@ticketee.com" expect(page).to have_content "Internet Explorer: Editor" expect(page).not_to have_content "Sublime Text 3" end