27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

108 CHAPTER 5 Nested resources<br />

Great! Everything’s still working. Push the changes!<br />

git add .<br />

git commit -m "Implemented creating tickets for a project"<br />

git push<br />

This section covered how to create tickets and link them to a specific project through<br />

the foreign key called project_id on records in the tickets table.<br />

The next section shows how easily you can list tickets for individual projects.<br />

5.2 Viewing tickets<br />

Now that you have the ability to create tickets, you use the show action to create the<br />

functionality to view them individually.<br />

When displaying a list of projects, you use the index action of the Projects-<br />

Controller. For tickets, however, you use the show action because this page is currently<br />

not being used for anything else in particular. To test it, put a new feature at<br />

features/viewing_tickets.feature using the code from the following listing.<br />

Listing 5.8 features/viewing_tickets.feature<br />

Feature: Viewing tickets<br />

In order to view the tickets for a project<br />

As a user<br />

I want to see them on that project's page<br />

Background:<br />

Given there is a project called "TextMate 2"<br />

And that project has a ticket:<br />

| title | description |<br />

| Make it shiny! | Gradients! Starbursts! Oh my! |<br />

And there is a project called "Internet Explorer"<br />

And that project has a ticket:<br />

| title | description |<br />

| Standards compliance | Isn’t a joke. |<br />

And I am on the homepage<br />

Scenario: Viewing tickets for a given project<br />

When I follow "TextMate 2"<br />

Then I should see "Make it shiny!"<br />

And I should not see "Standards compliance"<br />

When I follow "Make it shiny!"<br />

Then I should see "Make it shiny" within "#ticket h2"<br />

And I should see "Gradients! Starbursts! Oh my!"<br />

When I follow "Ticketee"<br />

And I follow "Internet Explorer"<br />

Then I should see "Standards compliance"<br />

And I should not see "Make it shiny!"<br />

When I follow "Standards compliance"<br />

Then I should see "Standards compliance" within "#ticket h2"<br />

And I should see "Isn't a joke."<br />

B<br />

Check element<br />

using CSS<br />

selector

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

Saved successfully!

Ooh no, something went wrong!