Sha256: 281ef9677d14b93d38ae9a2d3b64e6b91987f6ad79257eaea41adad56a97ae01

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

require 'test_helper'
require 'workarea/blog/import/wordpress/page'

module Workarea
  module Blog
    module Import
      module Wordpress
        class PageTest < TestCase
          setup :page_via_import

          def page_via_import
            @page_hash = {
              guid_path: 'https://www.example.com/?page=1',
              page_title: 'Test Page Title',
              url: 'https://www.example.com/path/to/test-page',
              new_slug: 'test-page',
              published?: true,
              content: "<h1>This is a heading</h1>"
            }

            @page = Workarea::Blog::Import::Wordpress::Page.new(@page_hash).save
          end

          def test_creates_the_page
            assert(@page.present?)
            assert_equal(@page_hash[:page_title], @page.name)
          end

          def test_html_block_for_page_is_created
            model = Workarea::Content.for(@page)

            assert_equal(1, model.blocks.size)
            assert_equal(:html, model.blocks.first.type_id)
          end

          def test_creates_a_redirect_for_the_entry
            redirect = Workarea::Navigation::Redirect.find_by(path: '/path/to/test-page')

            assert(redirect.present?)
            assert_equal("/pages/#{@page_hash[:new_slug]}", redirect[:destination])
          end

          def test_does_not_create_a_page_if_one_exists
            Workarea::Blog::Import::Wordpress::Page.new(@page_hash).save

            assert_equal(1, Workarea::Content::Page.count)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-blog-3.5.2 test/lib/workarea/blog/import/wordpress/page_test.rb
workarea-blog-3.5.1 test/lib/workarea/blog/import/wordpress/page_test.rb
workarea-blog-3.5.0 test/lib/workarea/blog/import/wordpress/page_test.rb
workarea-blog-3.4.9 test/lib/workarea/blog/import/wordpress/page_test.rb
workarea-blog-3.4.8 test/lib/workarea/blog/import/wordpress/page_test.rb
workarea-blog-3.4.7 test/lib/workarea/blog/import/wordpress/page_test.rb