<commit_before>require 'spec_helper'

describe PermitsController do
  before(:all) do 
    @cosa = FactoryGirl.create(:cosa_boundary)
  end

  describe "GET #new" do

    context "when addition is selected as true" do
      subject { get :create, :format => 'html', :permit => FactoryGirl.attributes_for(:permit, 
                                                                                      owner_address: nil,
                                                                                      house_area: nil,
                                                                                      addition_area: nil,
                                                                                      ac: nil,
                                                                                      contractor: nil,
                                                                                      contractor_name: nil,
                                                                                      contractor_id: nil,
                                                                                      escrow: nil,
                                                                                      license_holder: nil,
                                                                                      license_num: nil,
                                                                                      agent_name: nil,
                                                                                      contact_id: nil,
                                                                                      other_contact_id: nil,
                                                                                      phone: nil,
                                                                                      fax: nil,
                                                                                      email: nil,
                                                                                      work_summary: nil,
                                                                                      job_cost: nil,
                                                                                      status: nil) }
        

      it { expect(subject).to redirect_to(permit_steps_path) }


      # it { should respond_with 200 }
    end

    context "when addition is selected as false" do
      subject { get :create, :format => 'html', :permit => FactoryGirl.attributes_for(:permit, 
                                                                                      addition: false,
                                                                                      owner_address: nil,
                                                                                      house_area: nil,
                                                                                      addition_area: nil,
                                                                                      ac: nil,
                                                                                      contractor: nil,
                                                                                      contractor_name: nil,
                                                                                      contractor_id: nil,
                                                                                      escrow: nil,
                                                                                      license_holder: nil,
                                                                                      license_num: nil,
                                                                                      agent_name: nil,
                                                                                      contact_id: nil,
                                                                                      other_contact_id: nil,
                                                                                      phone: nil,
                                                                                      fax: nil,
                                                                                      email: nil,
                                                                                      work_summary: nil,
                                                                                      job_cost: nil,
                                                                                      status: nil) }
        

      it { expect(subject).to render_template("new") }


      # it { should respond_with 200 }      
    end

    context "when addition is not selected" do
      subject { get :create, :format=> 'html', :permit => FactoryGirl.attributes_for( :permit,
                                                                                      addition: nil,
                                                                                      owner_address: nil,
                                                                                      house_area: nil,
                                                                                      addition_area: nil,
                                                                                      ac: nil,
                                                                                      contractor: nil,
                                                                                      contractor_name: nil,
                                                                                      contractor_id: nil,
                                                                                      escrow: nil,
                                                                                      license_holder: nil,
                                                                                      license_num: nil,
                                                                                      agent_name: nil,
                                                                                      contact_id: nil,
                                                                                      other_contact_id: nil,
                                                                                      phone: nil,
                                                                                      fax: nil,
                                                                                      email: nil,
                                                                                      work_summary: nil,
                                                                                      job_cost: nil,
                                                                                      status: nil) }

      it { expect(subject).to render_template("new") }
    end
  end

end<commit_msg>Add form checking<commit_after>require 'spec_helper'

describe PermitsController do
  before(:all) do 
    @cosa = FactoryGirl.create(:cosa_boundary)
  end

  describe "GET #new" do

    context "when addition is selected as true" do
      subject { get :create, :format => 'html', :permit => FactoryGirl.attributes_for(:permit, 
                                                                                      owner_address: nil,
                                                                                      house_area: nil,
                                                                                      addition_area: nil,
                                                                                      ac: nil,
                                                                                      contractor: nil,
                                                                                      contractor_name: nil,
                                                                                      contractor_id: nil,
                                                                                      escrow: nil,
                                                                                      license_holder: nil,
                                                                                      license_num: nil,
                                                                                      agent_name: nil,
                                                                                      contact_id: nil,
                                                                                      other_contact_id: nil,
                                                                                      phone: nil,
                                                                                      fax: nil,
                                                                                      email: nil,
                                                                                      work_summary: nil,
                                                                                      job_cost: nil,
                                                                                      status: nil) }
        

      it { expect(subject).to redirect_to(permit_steps_path) }


      # it { should respond_with 200 }
    end

    context "when addition is selected as false" do
      subject { get :create, :format => 'html', :permit => FactoryGirl.attributes_for(:permit, 
                                                                                      addition: false,
                                                                                      owner_address: nil,
                                                                                      house_area: nil,
                                                                                      addition_area: nil,
                                                                                      ac: nil,
                                                                                      contractor: nil,
                                                                                      contractor_name: nil,
                                                                                      contractor_id: nil,
                                                                                      escrow: nil,
                                                                                      license_holder: nil,
                                                                                      license_num: nil,
                                                                                      agent_name: nil,
                                                                                      contact_id: nil,
                                                                                      other_contact_id: nil,
                                                                                      phone: nil,
                                                                                      fax: nil,
                                                                                      email: nil,
                                                                                      work_summary: nil,
                                                                                      job_cost: nil,
                                                                                      status: nil) }
        

      it { expect(subject).to render_template("new") }


      # it { should respond_with 200 }      
    end

    context "when addition is not selected" do
      subject { get :create, :format=> 'html', :permit => FactoryGirl.attributes_for( :permit,
                                                                                      addition: nil,
                                                                                      owner_address: nil,
                                                                                      house_area: nil,
                                                                                      addition_area: nil,
                                                                                      ac: nil,
                                                                                      contractor: nil,
                                                                                      contractor_name: nil,
                                                                                      contractor_id: nil,
                                                                                      escrow: nil,
                                                                                      license_holder: nil,
                                                                                      license_num: nil,
                                                                                      agent_name: nil,
                                                                                      contact_id: nil,
                                                                                      other_contact_id: nil,
                                                                                      phone: nil,
                                                                                      fax: nil,
                                                                                      email: nil,
                                                                                      work_summary: nil,
                                                                                      job_cost: nil,
                                                                                      status: nil) }

      it { expect(subject).to render_template("new") }
    end
  end

  describe "new" do

    before { visit permits_new_path }

    let(:submit) { "Submit" }

    # describe "with invalid information" do
    #   it "should not create a user" do
    #     expect { click_button submit }.not_to change(User, :count)
    #   end
    # end

    describe "with valid information" do
      before do
        fill_in "Addition",         with: true
      end

      it "should create a user" do
        expect { click_button submit }.to redirect_to(permit_steps_path)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.033510308212094046, 'fraction_numerical': 0.0008274150175825692, 'mean_word_length': 0.31543624161073824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 472, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7238938', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1454, 'n_words': 453}