<commit_before>require 'spec_helper'

describe RoomsController do
  include RoomsHelper
  fixtures :all

  def mock_room(stubs={})
    stubs = stubs.merge({
      :name => 'Room',
      :event= => true,
      :event => events(:open)
    })
    return @mock_room ||= mock_model(Room, stubs)
  end
  
  before do
    @event = stub_current_event!(:event => events(:open))
  end
    
  describe "responding to GET index" do

    it "should expose all rooms from the current event as @rooms" do
      @event.should_receive(:rooms).and_return([mock_room])
      get :index
      assigns(:rooms).should == [mock_room]
    end

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

  describe "responding to GET show" do

    it "should expose the requested room as @room" do<commit_msg>Fix RoomsControllerSpec to be aware of redirects<commit_after>require 'spec_helper'

describe RoomsController do
  include RoomsHelper
  fixtures :all

  def mock_room(stubs={})
    stubs = stubs.merge({
      :name => 'Room',
      :event= => true,
      :event => events(:open)
    })
    return @mock_room ||= mock_model(Room, stubs)
  end
  
  before do
    @event = stub_current_event!(:event => events(:open))
  end
    
  describe "responding to GET index" do

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

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

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

  describe "responding to GET show" do

    it "should expose the requested room as @room" do
{'fraction_non_alphanumeric': 0.10444177671068428, 'fraction_numerical': 0.0, 'mean_word_length': 2.97456279809221, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '5616876', 'n_tokens_mistral': 770, 'n_tokens_neox': 746, 'n_words': 235}