<commit_before>require 'rails_helper'

RSpec.describe ParcelsController, type: :controller do
  let(:user) { FactoryGirl.create :user }
  before :each do
    allow(controller).to receive(:current_user) { user}
  end

  context "#create" do
    it "redirects to the users profile" do
      p_params = FactoryGirl.attributes_for(:parcel)
      o_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      d_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      expect {post :create, origin_address:o_params, destination_address:d_params, parcel:p_params}.to change{Parcel.count}.by(1)
      expect(response).to redirect_to profile_path
    end

    it "creates a parcels with valid params" do
      p_params = FactoryGirl.attributes_for(:parcel)
      o_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      d_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      expect {post :create, origin_address:o_params, destination_address:d_params, parcel:p_params}.to change{Parcel.count}.by(1)<commit_msg>pass render show template test<commit_after>require 'rails_helper'

RSpec.describe ParcelsController, type: :controller do
  let(:user) { FactoryGirl.create :user }
  before :each do
    allow(controller).to receive(:current_user) { user}
  end

  context "GET #show" do
    it "assigns the requested parcel to @parcel" do
      allow(controller).to receive(:current_user) { user}
      p_params = FactoryGirl.attributes_for(:parcel)
      o_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      d_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      post :create, origin_address:o_params, destination_address:d_params, parcel:p_params
      @parcel = Parcel.last
      get :show, id: @parcel
      expect(assigns(:parcel)).to eq @parcel
    end

    it "renders the :show template" do
      allow(controller).to receive(:current_user) { user}
      p_params = FactoryGirl.attributes_for(:parcel)
      o_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      d_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      post :create, origin_address:o_params, destination_address:d_params, parcel:p_params
      @parcel = Parcel.last
      get :show, id: @parcel
      expect(response).to render_template :show
    end
  end

  context "#create" do
    it "redirects to the users profile" do
      p_params = FactoryGirl.attributes_for(:parcel)
      o_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      d_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      expect {post :create, origin_address:o_params, destination_address:d_params, parcel:p_params}.to change{Parcel.count}.by(1)
      expect(response).to redirect_to profile_path
    end

    it "creates a parcels with valid params" do
      p_params = FactoryGirl.attributes_for(:parcel)
      o_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      d_params = FactoryGirl.attributes_for(:address, user_id: user.id)
      expect {post :create, origin_address:o_params, destination_address:d_params, parcel:p_params}.to change{Parcel.count}.by(1)
{'fraction_non_alphanumeric': 0.10227272727272728, 'fraction_numerical': 0.0012626262626262627, 'mean_word_length': 4.389455782312925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6709386', 'n_tokens_mistral': 1018, 'n_tokens_neox': 977, 'n_words': 224}