<commit_before>require File.dirname(__FILE__) + '/../spec_helper'

describe Form do
  before(:each) do
    @form = Form.new
  end

  it "should be valid" do
    @form.should be_valid
  end
  
  describe "when created with create_and_initialize_form_elements" do
    
    fixtures :forms, :form_elements
    
    it "should bootstrap the form element hierarchy" do
      @form.create_and_initialize_form_elements
      form_base_element = @form.form_base_element
      form_base_element.should_not be_nil
      default_view_element = form_base_element.children[0]
      default_view_element.should_not be_nil
      default_view_element.name.should == "Default View"
      default_section_element = default_view_element.children[0]
      default_section_element.should_not be_nil
      default_section_element.name.should == "Default Section"
    end
    
    it "should have a template's properties" do
      @form.create_and_initialize_form_elements
      @form.is_template.should be_true
      @form.template_id.should be_nil
      @form.version.should be_nil
      @form.status.should eql("Not Published")
    end
    
  end
  
  describe "when trying to call publish on a published instance" do
    
    fixtures :forms, :form_elements
    
    it "should fail" do
      form_to_publish = Form.find(1)
      error_message = ""<commit_msg>Adding question fixtures to form specs in an attempt to get the build passing.<commit_after>require File.dirname(__FILE__) + '/../spec_helper'

describe Form do
  before(:each) do
    @form = Form.new
  end

  it "should be valid" do
    @form.should be_valid
  end
  
  describe "when created with create_and_initialize_form_elements" do
    
    fixtures :forms, :form_elements, :questions
    
    it "should bootstrap the form element hierarchy" do
      @form.create_and_initialize_form_elements
      form_base_element = @form.form_base_element
      form_base_element.should_not be_nil
      default_view_element = form_base_element.children[0]
      default_view_element.should_not be_nil
      default_view_element.name.should == "Default View"
      default_section_element = default_view_element.children[0]
      default_section_element.should_not be_nil
      default_section_element.name.should == "Default Section"
    end
    
    it "should have a template's properties" do
      @form.create_and_initialize_form_elements
      @form.is_template.should be_true
      @form.template_id.should be_nil
      @form.version.should be_nil
      @form.status.should eql("Not Published")
    end
    
  end
  
  describe "when trying to call publish on a published instance" do
    
    fixtures :forms, :form_elements, :questions
    
    it "should fail" do
      form_to_publish = Form.find(1)
      error_message = ""
{'fraction_non_alphanumeric': 0.06892818477084085, 'fraction_numerical': 0.0021652832912306026, 'mean_word_length': 3.2580645161290325, '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': '7050748', 'n_tokens_mistral': 841, 'n_tokens_neox': 827, 'n_words': 207}