<commit_before>require 'spec_helper'

describe BaseController, :type => :controller do
  let(:oc)    { instance_double(OrderCycle, id: 1) }
  let(:order) { instance_double(Spree::Order) }
  controller(BaseController) do
    def index
      render text: ""
    end
  end

  it "redirects to home with message if order cycle is expired" do
    controller.stub(:current_order_cycle).and_return(oc)
    controller.stub(:current_order).and_return(order)
    oc.stub(:closed?).and_return(true)

    order.should_receive(:empty!)
    order.should_receive(:set_order_cycle!).with(nil)

    get :index

    session[:expired_order_cycle_id].should == oc.id
    response.should redirect_to root_url
    flash[:info].should == "The order cycle you've selected has just closed. Please try again!"
  end<commit_msg>Refactor base controller with new rspec syntax<commit_after>require 'spec_helper'

describe BaseController, :type => :controller do
  let(:oc)    { instance_double(OrderCycle, id: 1) }
  let(:order) { instance_double(Spree::Order) }
  controller(BaseController) do
    def index
      render text: ""
    end
  end

  it "redirects to home with message if order cycle is expired" do
    expect(controller).to receive(:current_order_cycle).and_return(oc).twice
    expect(controller).to receive(:current_order).and_return(order).twice
    expect(oc).to receive(:closed?).and_return(true)
    expect(order).to receive(:empty!)
    expect(order).to receive(:set_order_cycle!).with(nil)

    get :index

    expect(session[:expired_order_cycle_id]).to eq oc.id
    expect(response).to redirect_to root_url
    expect(flash[:info]).to eq "The order cycle you've selected has just closed. Please try again!"
  end
{'fraction_non_alphanumeric': 0.11358313817330211, 'fraction_numerical': 0.00117096018735363, 'mean_word_length': 4.495176848874598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3420201', 'n_tokens_mistral': 533, 'n_tokens_neox': 514, 'n_words': 128}