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.

Tracking changes<br />

Awesome! Now let’s try rerunning rake cucumber:ok spec. That should be the last<br />

thing you need to fix. You should see the following output:<br />

49 scenarios (49 passed)<br />

515 steps (515 passed)<br />

# and<br />

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

Excellent, everything’s fixed. Let’s commit these changes now:<br />

git add .<br />

git commit -m "When updating a comment's status, it also updates<br />

➥the ticket's status"<br />

git push<br />

It’s great that you’ve now got the ticket status updating along with the comment status,<br />

but it would be handy to know what the timeline of a status change looks like. You can<br />

display this on the comment by showing a little indication of whether the state has<br />

changed during that comment. Let’s work on adding this tidbit of information to the<br />

comments right now.<br />

10.3 Tracking changes<br />

When a person posts a comment that changes the state of a ticket, you’d like this<br />

information displayed on the page next to the comment, as shown in figure 10.10.<br />

By visually tracking this state change, along with the text of the<br />

comment, you can provide context as to why the state was changed.<br />

At the moment, you only track the state of the comment and then<br />

don’t even display it alongside the comment’s text; you only use it to<br />

update the ticket’s status.<br />

10.3.1 Ch-ch-changes<br />

What you need now is some way of making sure that, when changing a ticket’s state by<br />

way of a comment, the “State: Open” text appears. A scenario would fit this bill, and<br />

luckily you wrote one that fits almost perfectly. This scenario is the final scenario<br />

(“Changing a ticket’s state”) in features/creating_comments.feature.<br />

To check for the state change text in your “Changing a ticket’s state” scenario, you<br />

add this single line to the bottom of it:<br />

Then I should see "State: Open" within "#comments"<br />

If the ticket was assigned the New state, this text would say “State: New ?' Open,” but<br />

because your tickets don’t have default states assigned to them the previous state for<br />

the first comment will be nil. When you run this scenario by using bin/cucumber<br />

features/creating_comments.feature:33, it will fail:<br />

Then I should see "State: Open" within "#comments"<br />

expected there to be content "State: Open"<br />

in "\n \n user@ticketee.com (User)\n<br />

This is a real issue\n\n"<br />

263<br />

Figure 10.10<br />

State transitions

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

Saved successfully!

Ooh no, something went wrong!