<commit_before># encoding: UTF-8
require 'spec_helper'

describe Monologue::PostsRevision do
  before(:each) do
    @post = Factory(:post_with_multiple_revisions)
  end

  it { should_not allow_mass_assignment_of(:user_id) }
  
  it "can have more than one revision" do
    attr = Factory.attributes_for(:posts_revision)
    attr[:id] = 2
    @post.posts_revisions.create(attr)
  end
  
  it "is always the latest revisions that is current one on post" do
    attr = Factory.attributes_for(:posts_revision)
    attr[:id] = 2
    @post.posts_revisions.create(attr)
    post = Monologue::Post.last
    post.posts_revision_id.should equal(post.posts_revisions.last.id)
  end

  it { validate_presence_of(:title) }
  it { validate_presence_of(:content) }
  it { validate_presence_of(:user_id) }
  it { validate_presence_of(:published_at) }
    <commit_msg>added test for permalink (url) generation fixing #29<commit_after># encoding: UTF-8
require 'spec_helper'

describe Monologue::PostsRevision do
  before(:each) do
    @post = Factory(:post_with_multiple_revisions)
  end

  it { should_not allow_mass_assignment_of(:user_id) }
  
  it "can have more than one revision" do
    attr = Factory.attributes_for(:posts_revision)
    attr[:id] = 2
    @post.posts_revisions.create(attr)
  end
  
  it "is always the latest revisions that is current one on post" do
    attr = Factory.attributes_for(:posts_revision)
    attr[:id] = 2
    @post.posts_revisions.create(attr)
    post = Monologue::Post.last
    post.posts_revision_id.should equal(post.posts_revisions.last.id)
  end

  it "should create permalink (url) automaticly with title and year if none is provided" do
    title = "this is a great title!!!"
    post = Factory(:posts_revision, url:"", title:title, published_at: "2012-02-02")
    post.url.should == "/2012/#{title.parameterize}"
  end

  it { validate_presence_of(:title) }
  it { validate_presence_of(:content) }
  it { validate_presence_of(:user_id) }
  it { validate_presence_of(:published_at) }
    
{'fraction_non_alphanumeric': 0.10549777117384844, 'fraction_numerical': 0.009905894006934125, 'mean_word_length': 4.219638242894057, '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': '7239676', 'n_tokens_mistral': 714, 'n_tokens_neox': 675, 'n_words': 159}