<commit_before>require 'spec_helper'

describe Page do

  let(:page) do
    Page.create!({
      :title => "RSpec is great for testing too",
      :deletable => true
    })
  end
  let(:child) { page.children.create(:title => 'The child page') }

  def page_cannot_be_destroyed
    page.destroy.should == false
  end

  def turn_off_marketable_urls
    RefinerySetting.set(:use_marketable_urls, {:value => false, :scoping => 'pages'})
  end

  def turn_on_marketable_urls
    RefinerySetting.set(:use_marketable_urls, {:value => true, :scoping => 'pages'})
  end

  def create_page_parts
    page.parts.create(:title => 'body', :content => "I'm the first page part for this page.")
    page.parts.create(:title => 'side body', :content => "Closely followed by the second page part.")
  end

  context "cannot be deleted under certain rules" do
    it "if link_url is present" do
      page.link_url = '/plugin-name'
      page_cannot_be_destroyed
    end


    it "if refinery team deems it so" do
      page.deletable = false
      page_cannot_be_destroyed
    end

    it "if menu_match is present" do
      page.menu_match = '^/RSpec is great for testing too.*$'
      page_cannot_be_destroyed
    end

    it "unless you really want it to! >:]" do
      page.destroy.should be
    end
  end

  context "page urls" do

    it "return a full path" do
      page.path.should == 'RSpec is great for testing too'
    end

    it "and all of its parent page titles, reversed" do
      child.path.should == 'RSpec is great for testing too - The child page'
    end

    it "or normally ;-)" do<commit_msg>This spec really is supposed to test forceful destroy!<commit_after>require 'spec_helper'

describe Page do

  let(:page) do
    Page.create!({
      :title => "RSpec is great for testing too",
      :deletable => true
    })
  end
  let(:child) { page.children.create(:title => 'The child page') }

  def page_cannot_be_destroyed
    page.destroy.should == false
  end

  def turn_off_marketable_urls
    RefinerySetting.set(:use_marketable_urls, {:value => false, :scoping => 'pages'})
  end

  def turn_on_marketable_urls
    RefinerySetting.set(:use_marketable_urls, {:value => true, :scoping => 'pages'})
  end

  def create_page_parts
    page.parts.create(:title => 'body', :content => "I'm the first page part for this page.")
    page.parts.create(:title => 'side body', :content => "Closely followed by the second page part.")
  end

  context "cannot be deleted under certain rules" do
    it "if link_url is present" do
      page.link_url = '/plugin-name'
      page_cannot_be_destroyed
    end


    it "if refinery team deems it so" do
      page.deletable = false
      page_cannot_be_destroyed
    end

    it "if menu_match is present" do
      page.menu_match = '^/RSpec is great for testing too.*$'
      page_cannot_be_destroyed
    end

    it "unless you really want it to! >:]" do
      page.deletable = false
      page_cannot_be_destroyed
      page.destroy!.should be
    end
  end

  context "page urls" do

    it "return a full path" do
      page.path.should == 'RSpec is great for testing too'
    end

    it "and all of its parent page titles, reversed" do
      child.path.should == 'RSpec is great for testing too - The child page'
    end

    it "or normally ;-)" do
{'fraction_non_alphanumeric': 0.10042347247428918, 'fraction_numerical': 0.0, 'mean_word_length': 2.9275534441805227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '1185033', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1043, 'n_words': 350}