<commit_before>require 'spec_helper'

describe InquiriesController do
  let (:test_organization) { Fabricate(:organization)}
  let (:member) { Fabricate(:member, organization: test_organization)}
  let (:another_member) { Fabricate(:member, organization: test_organization)}
  let! (:inquiry) { Fabricate(:inquiry, user: member.user)}

  describe "GET #index" do
    context "with a logged user" do
      it "populates and array of inquiries" do
        login(another_member.user)

        get :index
        expect(assigns(:inquiries)).to eq([inquiry])
      end
    end
  end

  describe "GET #show" do
    context "with a logged user" do
      it "assigns the requested inquiry to @inquiry" do
        login(another_member.user)

        get :show, id: inquiry.id
        expect(assigns(:inquiry)).to eq(inquiry)
      end
    end
  end
end<commit_msg>New tests for inquiries_controller.<commit_after>require 'spec_helper'

describe InquiriesController do
  let (:test_organization) { Fabricate(:organization)}
  let (:member) { Fabricate(:member, organization: test_organization)}
  let (:another_member) { Fabricate(:member, organization: test_organization)}
  let! (:inquiry) { Fabricate(:inquiry, user: member.user)}

  describe "GET #index" do
    context "with a logged user" do
      it "populates and array of inquiries" do
        login(another_member.user)

        get 'index'
        expect(assigns(:inquiries)).to eq([inquiry])
      end
    end
  end


  describe "GET #show" do
    context "with valid params" do
      context "with a logged user" do
        it "assigns the requested inquiry to @inquiry" do
          login(another_member.user)

          get 'show', id: inquiry.id
          expect(assigns(:inquiry)).to eq(inquiry)
        end
      end
    end
  end

  describe "POST #create" do
    context "with valid params" do
      context "with a logged user" do
        it "creates a new inquiry" do
          login(another_member.user)

          expect {
            post 'create', inquiry: Fabricate.to_params(:inquiry)
          }.to change(Inquiry,:count).by(1)
        end
      end
    end
  end

  describe "PUT #update" do
    context "with valid params" do
      context "with a logged user" do
        it "located the requested @inquiry" do
          login(member.user)

          put 'update', id: inquiry.id, inquiry: Fabricate.to_params(:inquiry)
          expect(assigns(:inquiry)).to eq(inquiry)
        end

        it "changes @inquiry's attributes" do
          login(member.user)

          put 'update', id: inquiry.id, inquiry: Fabricate.to_params(:inquiry, user: member, title: "New title", description: "New description")

          inquiry.reload
          expect(inquiry.title).to eq("New title")
          expect(inquiry.description).to eq("New description")
        end
      end
    end

    context "with invalid params" do
      context "with a logged user" do
        it "does not change @inquiry's attributes" do
          login(member.user)

          put :update, id: inquiry.id, inquiry: Fabricate.to_params(:inquiry, user: nil, title: "New title", description: "New description")

          expect(inquiry.title).not_to eq("New title")
          expect(inquiry.description).not_to eq("New description")
        end
      end
    end
  end

end
{'fraction_non_alphanumeric': 0.10181268882175226, 'fraction_numerical': 0.00030211480362537764, 'mean_word_length': 2.7202247191011235, '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': '3097984', 'n_tokens_mistral': 1018, 'n_tokens_neox': 949, 'n_words': 299}