27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

182 CHAPTER 8 More authorization<br />

This line ensures that you’re always taken to the correct page upon sign-up. Now<br />

replace the code inside app/views/users/confirmation.html.erb with the following<br />

code to make this feature pass again:<br />

You have signed up successfully.<br />

Please confirm your account before signing in.<br />

When users sign up, rather than seeing a confusing page telling them they must be<br />

signed in, they’ll instead see the page shown in figure 8.4.<br />

The Signing Up feature is probably fixed now, but the only true way to make sure<br />

it’s working is to test it manually or to run the feature. Running the feature is easier, so<br />

let’s do that with bin/cucumber features/signing_up.feature:<br />

1 scenario (1 passed)<br />

7 steps (7 passed)<br />

Everything is green. Awesome! This feature is passing again. Let’s make a commit for<br />

that:<br />

git add .<br />

git commit -m "Fix signing up feature,<br />

take user to alternative confirmation page"<br />

Is everything else working, though? Let’s check with rake cucumber:ok spec:<br />

31 scenarios (31 passed)<br />

285 steps (285 passed)<br />

# and<br />

19 examples, 0 failures, 10 pending<br />

Now everything’s working! Let’s push those changes to GitHub:<br />

git push<br />

You’ve limited the ability of users to take action on things inside the Projects-<br />

Controller and fixed the Signing Up feature that broke because of the changes you<br />

made. But you haven’t protected the TicketsController. This is a problem because<br />

users who can’t view a project will still be able to view its tickets, which could pose a<br />

security risk. A project’s most vital assets (for now) are the tickets associated with it,<br />

and users who don’t have permission to see the project shouldn’t be able to see the<br />

associated tickets. Let’s add this restriction next.<br />

Figure 8.4 “Please confirm<br />

your account”

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!