<commit_before>require 'spec_helper'

describe TracksController do
  include TracksHelper
  fixtures :all
  
  before do
    @event = stub_current_event!(event: events(:open))
    @controller.stub(assign_events: [])
    @track = create(:track, event: @event)
  end
    
  describe "responding to GET index" do

    it "should redirect to the tracks for the current event if none is given" do
      get :index
      response.should redirect_to(event_tracks_path(@event))
    end

    it "should expose all tracks from the current event as @tracks" do
      @event.should_receive(:tracks).and_return([@track])
      get :index, event_id: @event.to_param
      assigns(:tracks).should == [@track]
    end

    describe "with mime type of xml" do
      it "should render all tracks from the current event as xml" do
        request.env["HTTP_ACCEPT"] = "application/xml"
        @event.should_receive(:tracks).and_return(tracks = double("Array of Tracks"))
        tracks.should_receive(:to_xml).and_return("generated XML")
        get :index
        response.body.should == "generated XML"
      end
    end
    
  end
<commit_msg>Duct tape around brittle TracksControllerSpec<commit_after>require 'spec_helper'

describe TracksController do
  include TracksHelper
  fixtures :all
  
  before do
    @event = stub_current_event!(event: events(:open))
    @controller.stub(assign_events: [])
    @track = create(:track, event: @event)
    @tracks_double = double("Array of Tracks")
    @tracks_scope_double = double("Tracks Scope", order: @tracks_double)
  end
    
  describe "responding to GET index" do

    it "should redirect to the tracks for the current event if none is given" do
      get :index
      response.should redirect_to(event_tracks_path(@event))
    end

    it "should expose all tracks from the current event as @tracks" do
      @event.should_receive(:tracks).and_return(@tracks_scope_double)
      get :index, event_id: @event.to_param
      assigns(:tracks).should == @tracks_double
    end

    describe "with mime type of xml" do
      it "should render all tracks from the current event as xml" do
        request.env["HTTP_ACCEPT"] = "application/xml"
        @event.should_receive(:tracks).and_return(@tracks_scope_double)
        @tracks_double.should_receive(:to_xml).and_return("generated XML")
        get :index
        response.body.should == "generated XML"
      end
    end
    
  end

{'fraction_non_alphanumeric': 0.09504132231404959, 'fraction_numerical': 0.0, 'mean_word_length': 3.338709677419355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1357792', 'n_tokens_mistral': 736, 'n_tokens_neox': 702, 'n_words': 212}