<commit_before>require 'spec_helper'

describe User do
  before do
    @user = FactoryGirl.create(:user)
  end

  it "has a unique name" do
    other = User.new(name: @user.name)
    other.should_not be_valid
    other.errors.keys.should == [:name]
    other.errors[:name].should == [I18n.t("mongoid.errors.messages.taken")]
  end

  it "has a contextual datacenter" do
    Datacenter.destroy_all
    Datacenter.count.should == 0
    @user.reload.preferred_datacenter.name.should == "Datacenter"
    Datacenter.count.should == 1
  end

  it "has a unique provider+uid" do

    
  end

  describe "#settings" do
    it "alwayss be a hash" do
      User.new.settings.should eq Hash.new
    end

    it "serializes settings" do
      hsh = { "a" => "b" }
      @user.settings = hsh
      @user.save
      @user.reload.settings.should eq hsh<commit_msg>Fixed failing spec ; a bit ugly tho<commit_after>require 'spec_helper'

describe User do
  before do
    @user = FactoryGirl.create(:user)
  end

  it "has a unique name" do
    other = User.new(name: @user.name)
    other.should_not be_valid
    other.errors.keys.should == [:name]
    other.errors[:name].should == [I18n.t("mongoid.errors.messages.taken")]
  end

  it "has a contextual datacenter" do
    Datacenter.destroy_all
    User.destroy_all
    Datacenter.count.should == 0

    FactoryGirl.create(:user).preferred_datacenter.name.should == "Datacenter"
    Datacenter.count.should == 1
  end

  it "has a unique provider+uid" do

    
  end

  describe "#settings" do
    it "alwayss be a hash" do
      User.new.settings.should eq Hash.new
    end

    it "serializes settings" do
      hsh = { "a" => "b" }
      @user.settings = hsh
      @user.save
      @user.reload.settings.should eq hsh
{'fraction_non_alphanumeric': 0.11396011396011396, 'fraction_numerical': 0.004558404558404558, 'mean_word_length': 2.809110629067245, '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': '2816917', 'n_tokens_mistral': 620, 'n_tokens_neox': 590, 'n_words': 152}