<commit_before># encoding: utf-8

require 'spec_helper'

describe 'Cms/Pages' do

  context '#new' do
    before do
      visit kuhsaft.new_cms_page_path
      fill_in 'Titel', :with => 'The Title of the page'
      fill_in 'Stichwörter', :with => 'My keywords'
      fill_in 'Beschreibung', :with => 'My Description'
    end

    describe '#create' do
      it 'creates a new page' do
        expect { click_on 'Create Seite' }.to change(Kuhsaft::Page, :count).by(1)
      end
    end

  end
end<commit_msg>prepare specs<commit_after># encoding: utf-8

require 'spec_helper'

describe 'Cms/Pages' do

  context '#new' do
    before do
      visit kuhsaft.new_cms_page_path
      fill_in 'Titel', :with => 'The Title of the page'
      fill_in 'Stichwörter', :with => 'My keywords'
      fill_in 'Beschreibung', :with => 'My Description'
    end

    describe '#create' do
      it 'creates a new page' do
        expect { click_on 'Create Seite' }.to change(Kuhsaft::Page, :count).by(1)
      end

      it 'is not possible to change the value in url' do
        page.find('#page_url')['disabled'].should be_true
      end
    end

    describe '#update' do
      context 'when creating a redirect page' do
        before do
          @page = FactoryGirl.create(:page, :url => 'de/dumdidum')
          visit kuhsaft.edit_cms_page_path(@page)
          select 'redirect', :from => 'Seitentyp'
        end

        it 'has a value in redirect_page' do
          fill_in 'Redirect URL', :with => 'target_page'
          expect { click_on 'Update Seite' }.to change{ @page.reload.redirect_page }.to('redirect_page')
        end

        it 'is invalid when no value is in redirect_page' do
          click_on 'Update Seite'
          page.should have_css('.error', :count => 1)
        end

        it 'does not change the value in url' do
          fill_in 'Redirect URL', :with => 'target_page'
          expect { click_on 'Update Seite' }.to_not change{ @page.reload.url }
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10834990059642147, 'fraction_numerical': 0.002485089463220676, 'mean_word_length': 2.4410256410256412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '4530828', 'n_tokens_mistral': 666, 'n_tokens_neox': 649, 'n_words': 208}