Sha256: 0d02fd56d1a32cf8ba798b34bab0a0fba708205e9bf72e5dfaca337c0633ed1e

Contents?: true

Size: 1.73 KB

Versions: 4

Compression:

Stored size: 1.73 KB

Contents

require 'test_helper'

module Workarea
  module Api
    module Admin
      class PagesIntegrationTest < IntegrationTest
        include Workarea::Admin::IntegrationTest

        setup :set_sample_attributes

        def set_sample_attributes
          @sample_attributes = create_page.as_json.except('_id', 'slug')
        end

        def test_lists_pages
          pages = [create_page, create_page]
          get admin_api.pages_path
          result = JSON.parse(response.body)['pages']

          assert_equal(3, result.length)
          assert_equal(pages.second, Content::Page.new(result.first))
          assert_equal(pages.first, Content::Page.new(result.second))
        end

        def test_creates_pages
          assert_difference 'Content::Page.count', 1 do
            post admin_api.pages_path, params: { page: @sample_attributes }
          end
        end

        def test_shows_pages
          page = create_page
          get admin_api.page_path(page.id)
          result = JSON.parse(response.body)['page']
          assert_equal(page, Content::Page.new(result))
        end

        def test_updates_pages
          page = create_page
          patch admin_api.page_path(page.id), params: { page: { name: 'foo' } }

          page.reload
          assert_equal('foo', page.name)
        end

        def test_bulk_upserts_pages
          data = [@sample_attributes] * 10

          assert_difference 'Content::Page.count', 10 do
            patch admin_api.bulk_pages_path, params: { pages: data }
          end
        end

        def test_destroys_pages
          page = create_page

          assert_difference 'Content::Page.count', -1 do
            delete admin_api.page_path(page.id)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
workarea-api-4.4.7 admin/test/integration/workarea/api/admin/pages_integration_test.rb
workarea-api-admin-4.4.7 test/integration/workarea/api/admin/pages_integration_test.rb
workarea-api-4.4.6 admin/test/integration/workarea/api/admin/pages_integration_test.rb
workarea-api-admin-4.4.6 test/integration/workarea/api/admin/pages_integration_test.rb