<commit_before>require "rails_helper"

RSpec.describe Notebook do
  describe "validations" do
    before do
      @params = { name: "My notebook", description: "summary of my notebook" }
    end

    it "requires name" do
      notebook = Notebook.new(@params.merge(name: ""))
      expect(notebook).not_to be_valid
    end

    it "name should should be unique on user scope" do
      user1 = create(:user)
      user2 = create(:user)
      notebook_for_user1 = create(:notebook, name: "Notebook 1", user: user1)

      notebook = Notebook.new(@params.merge(name: "Notebook 1", user: user2))
      expect(notebook).to be_valid
    end

    it "does not require description" do
      notebook = Notebook.new(@params.merge(description: ""))
      expect(notebook).to be_valid
    end
  end
end
<commit_msg>New scenario to test the uniqueness of name per user<commit_after>require "rails_helper"

RSpec.describe Notebook do
  describe "validations" do
    before do
      @params = { name: "My notebook", description: "summary of my notebook" }
    end

    it "requires name" do
      notebook = Notebook.new(@params.merge(name: ""))
      expect(notebook).not_to be_valid
    end

    it "name should not be unique on different users" do
      user1 = create(:user)
      user2 = create(:user)
      notebook_for_user1 = create(:notebook, name: "Notebook 1", user: user1)

      notebook = Notebook.new(@params.merge(name: "Notebook 1", user: user2))
      expect(notebook).to be_valid
    end

    it "name should be unique per user" do
      user = create(:user)
      notebook = create(:notebook, name: "This is a notebook", user: user)

      notebook = Notebook.new(@params.merge(name: "This is a notebook", user: user))
      expect(notebook).not_to be_valid
    end

    it "does not require description" do
      notebook = Notebook.new(@params.merge(description: ""))
      expect(notebook).to be_valid
    end
  end
end

{'fraction_non_alphanumeric': 0.10673575129533679, 'fraction_numerical': 0.007253886010362694, 'mean_word_length': 3.126068376068376, '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': '1755407', 'n_tokens_mistral': 601, 'n_tokens_neox': 589, 'n_words': 183}