Sha256: 8a4f4ea4afdc50b71bf67409df4311b278bc98432181f2b33df2c2cbc9faf0ee

Contents?: true

Size: 1.18 KB

Versions: 28

Compression:

Stored size: 1.18 KB

Contents

class LayoutsDataset < Dataset::Base

  def load
    create_layout "Main", :content => <<-CONTENT
<html>
  <head>
    <title><r:title /></title>
  </head>
  <body>
    <r:content />
  </body>
</html>
    CONTENT

    create_layout "UTF8", :content_type => "text/html;charset=utf8", :content => <<-CONTENT
<html>
  <head>
    <title><r:title /></title>
  </head>
  <body>
    <r:content />
  </body>
</html>
    CONTENT
  end

  helpers do
    def create_layout(name, attributes={})
      create_record :layout, name.symbolize, layout_params(attributes.reverse_merge(:name => name))
    end

    def layout_params(attributes={})
      name = attributes[:name] || unique_layout_name
      {
        :name => name,
        :content => "<r:content />"
      }.merge(attributes)
    end

    def destroy_test_layout(name = @layout_name)
      while layout = get_test_layout(name) do
        layout.destroy
      end
    end

    def get_test_layout(name = @layout_name)
      Layout.find_by_name(name)
    end

    private

      @@unique_layout_name_call_count = 0
      def unique_layout_name
        @@unique_layout_name_call_count += 1
        "Layout #{@@unique_layout_name_call_count}"
      end
  end
end

Version data entries

28 entries across 28 versions & 5 rubygems

Version Path
radiant-1.0.0.rc3 spec/datasets/layouts_dataset.rb
kajam-1.0.3.rc2 spec/datasets/layouts_dataset.rb
radiant-1.0.0.rc2 spec/datasets/layouts_dataset.rb
radiant-1.0.0.rc1 spec/datasets/layouts_dataset.rb
radiant-rails3-0.1 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.2.4 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.2.2 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.2.1 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.2 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.9 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.8 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.7 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.6 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.5 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.4 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.3 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.2 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1.1 spec/datasets/layouts_dataset.rb
radiantcms-couchrest_model-0.1 spec/datasets/layouts_dataset.rb
radiant-0.7.2 spec/datasets/layouts_dataset.rb