<commit_before>require 'spec_helper'

describe Post do
  describe "#regenerate_permalink" do
    it "generates the permalink based on the post title" do
      subject.title = 'A big long post title'
      subject.regenerate_permalink
      subject.permalink.should == 'a-big-long-post-title'
    end
  end

  describe "#allowed_to_update_permalink?" do
    context "post is published" do
      before do
        subject.state = 'published'
      end

      it "returns false" do
        subject.allowed_to_update_permalink?.should be_false
      end
    end

    context "post is not published" do
      before do
        subject.state = 'draft'
      end

      it "returns true" do
        subject.allowed_to_update_permalink?.should be_true
      end
    end
  end

  describe "#formatted_published_date" do
    it "Formats the published_at date" do
      subject.published_at = Time.at(1329619863)
      subject.formatted_published_date.should == 'Feb 18, 2012'
    end
  end

  describe "#publish_if_allowed" do
    let(:user) { User.new }
    context "user is publisher" do
      before do
        user.is_publisher = true
      end

      it "changes its state" do
        subject.should_receive('publish')
        subject.publish_if_allowed('publish', user)
      end

      it "sets the user as publisher" do
        subject.publish_if_allowed('publish', user)
        subject.publisher.should be(user)
      end
    end

    context "user is not publisher" do
      before do
        user.is_publisher = false
      end

      it "does not change its state" do
        subject.should_not_receive('publish')
        subject.publish_if_allowed('publish', user)
      end
    end
  end

  describe "#month" do
    context "published at in february" do
      before do
        subject.published_at = stub(:month => 2)
      end

      it "returns 02" do
        subject.month.should == "02"
      end
    end
  end

  describe "#day" do
    context "published at in february" do
      before do
        subject.published_at = stub(:day => 2)
      end

      it "returns 02" do
        subject.day.should == "02"
      end
    end
  end
end
<commit_msg>Use namespaced models in specs<commit_after>require 'spec_helper'

describe CrowdblogCore::Post do
  describe "#regenerate_permalink" do
    it "generates the permalink based on the post title" do
      subject.title = 'A big long post title'
      subject.regenerate_permalink
      subject.permalink.should == 'a-big-long-post-title'
    end
  end

  describe "#allowed_to_update_permalink?" do
    context "post is published" do
      before do
        subject.state = 'published'
      end

      it "returns false" do
        subject.allowed_to_update_permalink?.should be_false
      end
    end

    context "post is not published" do
      before do
        subject.state = 'draft'
      end

      it "returns true" do
        subject.allowed_to_update_permalink?.should be_true
      end
    end
  end

  describe "#formatted_published_date" do
    it "Formats the published_at date" do
      subject.published_at = Time.at(1329619863)
      subject.formatted_published_date.should == 'Feb 18, 2012'
    end
  end

  describe "#publish_if_allowed" do
    let(:user) { CrowdblogCore::User.new }
    context "user is publisher" do
      before do
        user.is_publisher = true
      end

      it "changes its state" do
        subject.should_receive('publish')
        subject.publish_if_allowed('publish', user)
      end

      it "sets the user as publisher" do
        subject.publish_if_allowed('publish', user)
        subject.publisher.should be(user)
      end
    end

    context "user is not publisher" do
      before do
        user.is_publisher = false
      end

      it "does not change its state" do
        subject.should_not_receive('publish')
        subject.publish_if_allowed('publish', user)
      end
    end
  end

  describe "#month" do
    context "published at in february" do
      before do
        subject.published_at = stub(:month => 2)
      end

      it "returns 02" do
        subject.month.should == "02"
      end
    end
  end

  describe "#day" do
    context "published at in february" do
      before do
        subject.published_at = stub(:day => 2)
      end

      it "returns 02" do
        subject.day.should == "02"
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07560137457044673, 'fraction_numerical': 0.011912943871706758, 'mean_word_length': 2.255779269202088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2099101', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1289, 'n_words': 398}