Sha256: 64b60988b3e1cea2fa2dd5937ce0310e32cdd60d87975ffbb33419d97ff60d95

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

require 'test_helper'

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

        setup :set_sample_attributes

        def set_sample_attributes
          @sample_attributes = create_menu.as_json.except('_id')
        end

        def test_lists_menus
          2.times { create_menu }
          get admin_api.navigation_menus_path
          result = JSON.parse(response.body)['navigation_menus']
          assert_equal(3, result.length)
        end

        def test_creates_menus
          assert_difference 'Navigation::Menu.count', 1 do
            post admin_api.navigation_menus_path,
              params: { navigation_menu: @sample_attributes }
          end
        end

        def test_shows_menus
          menu = create_menu
          get admin_api.navigation_menu_path(menu.id)
          result = JSON.parse(response.body)['navigation_menu']
          assert_equal(menu, Navigation::Menu.new(result))
        end

        def test_updates_menus
          menu = create_menu
          patch admin_api.navigation_menu_path(menu.id),
            params: { navigation_menu: { name: 'foo' } }

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

        def test_destroys_menus
          menu = create_menu

          assert_difference 'Navigation::Menu.count', -1 do
            delete admin_api.navigation_menu_path(menu.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/navigation_menus_integration_test.rb
workarea-api-admin-4.4.7 test/integration/workarea/api/admin/navigation_menus_integration_test.rb
workarea-api-4.4.6 admin/test/integration/workarea/api/admin/navigation_menus_integration_test.rb
workarea-api-admin-4.4.6 test/integration/workarea/api/admin/navigation_menus_integration_test.rb