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.

Fixing what you broke<br />

When you run bin/cucumber features/editing_tickets.feature, both scenarios<br />

should pass:<br />

2 scenarios (2 passed)<br />

26 steps (26 passed)<br />

Great! You fixed another feature. The one remaining feature that fails is Viewing Tickets,<br />

which you fix in the same way as you fixed the previous features. Add this line<br />

again underneath where you create the TextMate 2 project, this time in features/<br />

viewing_tickets.feature:<br />

And "user@ticketee.com" can view the "TextMate 2" project<br />

You also need to add one for the Internet Explorer project:<br />

And "user@ticketee.com" can view the "Internet Explorer" project<br />

Also in this feature, you’re not signing in as the user who has these permissions, so<br />

directly underneath the first step in your Background, add the following step:<br />

And I am signed in as them<br />

Running bin/cucumber features/viewing_tickets.feature, you’ll see that this feature<br />

is passing:<br />

1 scenario (1 passed)<br />

23 steps (23 passed)<br />

That was fast! All four failing features are fixed. Well, so we hope. You independently<br />

verified them, but run rake cucumber:ok spec to make sure nothing else is broken:<br />

33 scenarios (33 passed)<br />

287 steps (287 passed)<br />

# and<br />

16 examples, 0 failures, 8 pending<br />

Great! Everything’s working again! Let’s commit that:<br />

git add .<br />

git commit -m "Made projects only visible to users with<br />

permission to see them"<br />

git push<br />

In these first two sections, you added the restriction on the ProjectsController that<br />

projects should be accessible only to users with Permission records with the action<br />

set to view. In the process, you broke a couple of features, but fixing them was really<br />

simple.<br />

However, these changes only protect the actions in the ProjectsController that<br />

use the find_project method and not those in the TicketsController. Before you<br />

make changes in the TicketsController, note that the links to all projects are still visible<br />

to all users through the ProjectsController’s index, which is definitely something<br />

you should fix first.<br />

175

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

Saved successfully!

Ooh no, something went wrong!