I&#39;ve written a story and I run into a snag.<br>I&#39;ve written the create_forum method and told it to set the id to 1<br>but when it creates the forum the id is autoincremented. <br>My forums table is empty but the id keeps incrementing the newest record on creation.
<br>When I run the story it comes out as something like 59 which fails my story because I&#39;m asking it to look at /forums/1<br><br>I thought of using my named routes instead of specifying the path as a string.<br>That worked up until the point when I reached:
<br><br>When &quot;creating a new topic titled&quot;, &quot;Nicks Mom&quot; do |title|<br>&nbsp; post topics(@forum, ??? ), :topic =&gt; { :title =&gt; title, :body =&gt; &quot;She is teh hotZ!&quot; }<br>end<br><br>The problem was since its a nested routed I couldn&#39;t complete the post request without specifying the topic_id.
<br>But since the topic hasn&#39;t been created yet their is no way (that I know of) to pass the id since I don&#39;t know what it will be.<br><br>I would think the better practice is to state the paths as strings instead of using the nested routes.
<br><br><br><br>require File.join(File.dirname(__FILE__), &quot;helper&quot;)<br><br>Story &quot;User creates a new topic&quot;, %{<br>&nbsp;&nbsp;&nbsp; As a user<br>&nbsp;&nbsp;&nbsp; I want to create a new topic<br>&nbsp;&nbsp;&nbsp; So that I can dicuss Nick&#39;s Mom
<br>&nbsp; }, :type =&gt; RailsStory do<br>&nbsp;&nbsp;&nbsp; <br>&nbsp; Scenario &quot;Successfully create a new topic in the &#39;General&#39; forum&quot; do<br>&nbsp; <br>&nbsp;&nbsp;&nbsp; Given &quot;a user named&quot;, &quot;Jon&quot; do |login| <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @user = create_user login
<br>&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; Given &quot;a forum named&quot;, &quot;General&quot; do |name|<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @forum = create_forum name<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts @<a href="http://forum.id">forum.id</a><br>&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; And &quot;user logged in successfully and was redirect to&quot;, &quot;/&quot; do |path|
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; post &quot;/session/create&quot;, :login =&gt; &quot;Jon&quot;, :password =&gt; &quot;your_momma&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response.should redirect_to(&quot;/&quot;)<br>&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; And &quot;user is looking at&quot;, &quot;/forums/1&quot; do |path|
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get path<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response.should be_success<br>&nbsp;&nbsp;&nbsp; end<br>&nbsp; <br>&nbsp;&nbsp;&nbsp; When &quot;creating a new topic titled&quot;, &quot;Nicks Mom&quot; do |title|<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; post &quot;/forums/1/topics/1/create&quot;, :topic =&gt; { :id =&gt; 1, :title =&gt; title, :body =&gt; &quot;She is teh hotZ!&quot; }
<br>&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; Then &quot;user should be redirected to&quot;, &quot;/forums/1/topics/1&quot; do |path|<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get path <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response.should be_success<br>&nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; <br>&nbsp; end<br>&nbsp; <br>&nbsp; Scenario &quot;Failed creating a new topic due to blank fields&quot; do; end
<br>&nbsp; Scenario &quot;Sticky a new thread&quot; do; end<br>&nbsp; Scenario &quot;Annoucment as a new thread&quot; do; end<br>end<br>&nbsp; <br>def create_user(login)<br>&nbsp; user = User.create!(<br>&nbsp;&nbsp;&nbsp; :login =&gt; login, <br>&nbsp;&nbsp;&nbsp; :email =&gt; &quot;
<a href="mailto:your@momma.com">your@momma.com</a>&quot;, <br>&nbsp;&nbsp;&nbsp; :password =&gt; &quot;your_momma&quot;,<br>&nbsp;&nbsp;&nbsp; :password_confirmation =&gt; &quot;your_momma&quot;,<br>&nbsp;&nbsp;&nbsp; :display_name =&gt; &quot;Jon&quot;)<br>&nbsp; user<br>
end<br><br>def create_forum(name)<br>&nbsp; forum = Forum.create!(<br>&nbsp;&nbsp;&nbsp; :id =&gt; 1,<br>&nbsp;&nbsp;&nbsp; :name =&gt; name,<br>&nbsp;&nbsp;&nbsp; :description =&gt; &quot;Everything from the latest gossip to the coolest youtube videos.&quot;)<br>&nbsp; forum
<br>end<br><br><br>How do I stop the incrementing?<br>