<commit_before>require File.dirname(__FILE__) + '/../spec_helper'

describe RequestController, "when listing all requests" do
    integrate_views
    fixtures :info_requests, :outgoing_messages, :info_request_events
  
    it "should be successful" do
        get :list
        response.should be_success
    end

    it "should render with 'list' template" do
        get :list
        response.should render_template('list')
    end

    it "should assign the first page of results" do
        # XXX probably should load more than one page of requests into db here :)
        ActsAsXapian.update_index
        
        get :list

        # reverse-chronological order
        assigns[:xapian_object].matches_estimated.should == 2
        assigns[:xapian_object].results.size.should == 2
        assigns[:xapian_object].results[0][:model].should == info_request_events(:silly_outgoing_message_event)
        assigns[:xapian_object].results[1][:model].should == info_request_events(:useless_outgoing_message_event)
    end
end

describe RequestController, "when showing one request" do
    integrate_views
    fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
  
    it "should be successful" do
        get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
        response.should be_success
    end

    it "should render with 'show' template" do
        get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
        response.should render_template('show')<commit_msg>Update with new list page defaults.<commit_after>require File.dirname(__FILE__) + '/../spec_helper'

describe RequestController, "when listing recent requests" do
    integrate_views
    fixtures :info_requests, :outgoing_messages, :info_request_events
  
    it "should be successful" do
        get :list, :view => 'recent'
        response.should be_success
    end

    it "should render with 'list' template" do
        get :list, :view => 'recent'
        response.should render_template('list')
    end

    it "should assign the first page of results" do
        # XXX probably should load more than one page of requests into db here :)
        ActsAsXapian.update_index
        
        get :list, :view => 'recent'

        # reverse-chronological order
        assigns[:xapian_object].matches_estimated.should == 2
        assigns[:xapian_object].results.size.should == 2
        assigns[:xapian_object].results[0][:model].should == info_request_events(:silly_outgoing_message_event)
        assigns[:xapian_object].results[1][:model].should == info_request_events(:useless_outgoing_message_event)
    end
end

describe RequestController, "when showing one request" do
    integrate_views
    fixtures :info_requests, :info_request_events, :public_bodies, :users, :incoming_messages, :raw_emails, :outgoing_messages # all needed as integrating views
  
    it "should be successful" do
        get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
        response.should be_success
    end

    it "should render with 'show' template" do
        get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
        response.should render_template('show')
{'fraction_non_alphanumeric': 0.08680981595092024, 'fraction_numerical': 0.00245398773006135, 'mean_word_length': 3.5417827298050137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7310100', 'n_tokens_mistral': 972, 'n_tokens_neox': 952, 'n_words': 250}