Sha256: ec7ce5fbf02493f629079f0ab9e2bb660bf2b8605888433fe3ce191fd38493cf

Contents?: true

Size: 1.57 KB

Versions: 15

Compression:

Stored size: 1.57 KB

Contents

module Features
  module SiteHelpers

    def create_full_site
      # 1. create site
      sign_in
      click_link 'Add a new site'
      fill_in 'Name', with: 'Acme'
      click_button 'Create'

      sleep(1)

      @site = Locomotive::Site.where(name: 'Acme').first

      # 2. add content types
      messages  = create('message content type', site: @site)
      articles  = create('article content type', slug: 'articles', site: @site)
      photos    = create('photo content type', slug: 'photos', site: @site)

      # create relationships
      photos.entries_custom_fields.build(label: 'Article', name: 'article', type: 'belongs_to', class_name: articles.entries_class_name)
      photos.save!
      articles.entries_custom_fields.build(label: 'Photos', name: 'photos', type: 'has_many', class_name: photos.entries_class_name, inverse_of: 'article')
      articles.save!

      # 3. create pages
      @site.pages.create(parent: @site.pages.root.first, title: 'Contact', slug: 'contact', raw_template: %{<html><body>{% if message.errors %}num errors: {{ message.errors.size }} / {% for error in message.errors %}-{{error[0]}} {{error[1]}}-{% endfor %}{% endif %}{% model_form 'messages', success: '/', error: '/contact' %}<input type="text" name="content[name]" value="{{customer_message.name}}"><input type="text" name="content[message]" value="{{customer_message.message}}"><input type="submit" value="Send">{% endmodel_form %}</body></html>})

      click_link 'Dashboard'
    end

    def preview_page(path = '')
      visit "/locomotive/#{@site.handle}/preview/#{path}"
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 spec/support/features/site_helpers.rb
locomotivecms-3.3.0.rc3 spec/support/features/site_helpers.rb
locomotivecms-3.3.0.rc2 spec/support/features/site_helpers.rb
locomotivecms-3.1.2 spec/support/features/site_helpers.rb
locomotivecms-3.2.1 spec/support/features/site_helpers.rb
locomotivecms-3.3.0.rc1 spec/support/features/site_helpers.rb
locomotivecms-3.2.0 spec/support/features/site_helpers.rb
locomotivecms-3.2.0.rc2 spec/support/features/site_helpers.rb
locomotivecms-3.2.0.rc1 spec/support/features/site_helpers.rb
locomotivecms-3.1.1 spec/support/features/site_helpers.rb
locomotivecms-3.1.0 spec/support/features/site_helpers.rb
locomotivecms-3.1.0.rc3 spec/support/features/site_helpers.rb
locomotivecms-3.1.0.rc2 spec/support/features/site_helpers.rb
locomotivecms-3.1.0.rc1 spec/support/features/site_helpers.rb
locomotivecms-3.0.1 spec/support/features/site_helpers.rb