title: Functional Testing Rails, No route matches error
body: <p>I am trying to fix the following rails functional test:</p>
  
  <pre><code>test "should create broadcast" do
    login_as(:one_details)
    assert_difference('Broadcast.count') do
      post :create, feeds: [:twitter, {alumni_email: 'test@email.com'}], broadcast: {id: 2, content: @broadcast.content, user: @user_details.user_id}
    end
    assert_redirected_to "#{broadcast_path}?page=1"
  end
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>1) Error:
  BroadcastsControllerTest#test_should_create_broadcast:
  ActionController::UrlGenerationError: No route matches {:action=&gt;"show", :controller=&gt;"broadcasts"} missing required keys: [:id]
      test/controllers/broadcasts_controller_test.rb:35:in `block in &lt;class:BroadcastsControllerTest&gt;'
  </code></pre>
  
  <p>I have this in the routes file:</p>
  
  <pre><code>resources :broadcasts, except: [:edit, :update]
  </code></pre>
  
  <p>In the broadcasts_controller the show method looks like this:</p>
  
  <pre><code>def show
    if is_admin?
      respond_to do |format|
  
        format.js { render partial: 'show_local',
                         locals: {broadcast: @broadcast, current_page: @current_page},
                         layout: false }
        format.html # show.html.erb
        format.json # show.json.builder
      end
    else
      indicate_illegal_request I18n.t('not allowed to view this')
    end
  end
  </code></pre>
  
  <p>The broadcast controller create method:</p>
  
  <p>def create</p>
  
  <pre><code>  @broadcast = Broadcast.new(broadcast_params)
  
    # Wire up broadcast with the current user (an administrator)
    # Will be an admin user (see before_filter)
    # Note the current_user is a user_detail object so we need
    # to navigate to its user object
    @broadcast.user = current_user.user
  
    # Doing the next line forces a save automatically. I want to defer this
    # until the "if" statement
    #current_user.user.broadcasts &lt;&lt; @broadcast
  
    no_errors = false
    respond_to do |format|
      if @broadcast.save
  
        # Only after saving do we try and do the real broadcast. Could have been
        # done using an observer, but I wanted this to be more explicit
  
        results = BroadcastService.broadcast(@broadcast, params[:feeds])
        if results.length &gt; 0
          # Something went wrong when trying to broadcast to one or more of the
          # feeds.
          @broadcast.errors[:base] &lt;&lt; ("#{I18n.t('broadcasts.unable-message')}: #{results.inspect}")
          flash[:error] = I18n.t('broadcasts.saved-but-message')
        else
          flash[:notice] = I18n.t('broadcasts.saved-message')
          no_errors = true
        end
        if no_errors
          format.html { redirect_to(broadcasts_url(page: @current_page)) }
          format.json { render json: @broadcast, status: :created, location: @broadcast }
        else
          format.html { render :new }
          format.xml {
            # Either say it partly worked but send back the errors or else send
            # back complete failure indicator (couldn't even save)
            if results
              render json: @broadcast.errors, status: :created, location: @broadcast
            else
              render json: @broadcast.errors, status: :unprocessable_entity
            end
          }
        end
      end
    end
  end
  </code></pre>