From 0f74fc2b880253d4ece3f38c5364d1eb437b4689 Mon Sep 17 00:00:00 2001 From: riggraz Date: Sat, 24 Aug 2019 19:48:31 +0200 Subject: [PATCH] Add routing specs --- spec/routing/admin_panel_routing_spec.rb | 80 ++++++++++++++++++++++++ spec/routing/board_routing_spec.rb | 15 +++++ 2 files changed, 95 insertions(+) create mode 100644 spec/routing/admin_panel_routing_spec.rb create mode 100644 spec/routing/board_routing_spec.rb diff --git a/spec/routing/admin_panel_routing_spec.rb b/spec/routing/admin_panel_routing_spec.rb new file mode 100644 index 00000000..e6ccaa08 --- /dev/null +++ b/spec/routing/admin_panel_routing_spec.rb @@ -0,0 +1,80 @@ +require 'rails_helper' + +RSpec.describe 'admin panel routing', :aggregate_failures, type: :routing do + it 'routes root to boards index action' do + expect(get: '/admin').to route_to( + controller: 'admin/boards', action: 'index') + end + + it 'routes boards' do + expect(get: '/admin/boards').to route_to( + controller: 'admin/boards', action: 'index' + ) + expect(get: '/admin/boards/1').to route_to( + controller: 'admin/boards', action: 'show', id: '1' + ) + expect(get: '/admin/boards/new').to route_to( + controller: 'admin/boards', action: 'new' + ) + expect(get: '/admin/boards/1/edit').to route_to( + controller: 'admin/boards', action: 'edit', id: '1' + ) + expect(post: '/admin/boards').to route_to( + controller: 'admin/boards', action: 'create' + ) + expect(patch: '/admin/boards/1').to route_to( + controller: 'admin/boards', action: 'update', id: '1' + ) + expect(delete: '/admin/boards/1').to route_to( + controller: 'admin/boards', action: 'destroy', id: '1' + ) + end + + it 'routes post statuses' do + expect(get: '/admin/post_statuses').to route_to( + controller: 'admin/post_statuses', action: 'index' + ) + expect(get: '/admin/post_statuses/1').to route_to( + controller: 'admin/post_statuses', action: 'show', id: '1' + ) + expect(get: '/admin/post_statuses/new').to route_to( + controller: 'admin/post_statuses', action: 'new' + ) + expect(get: '/admin/post_statuses/1/edit').to route_to( + controller: 'admin/post_statuses', action: 'edit', id: '1' + ) + expect(post: '/admin/post_statuses').to route_to( + controller: 'admin/post_statuses', action: 'create' + ) + expect(patch: '/admin/post_statuses/1').to route_to( + controller: 'admin/post_statuses', action: 'update', id: '1' + ) + expect(delete: '/admin/post_statuses/1').to route_to( + controller: 'admin/post_statuses', action: 'destroy', id: '1' + ) + end + + it 'routes users' do + expect(get: '/admin/users').to route_to( + controller: 'admin/users', action: 'index' + ) + expect(get: '/admin/users/1').to route_to( + controller: 'admin/users', action: 'show', id: '1' + ) + expect(get: '/admin/users/new').to route_to( + controller: 'admin/users', action: 'new' + ) + expect(get: '/admin/users/1/edit').to route_to( + controller: 'admin/users', action: 'edit', id: '1' + ) + expect(post: '/admin/users').to route_to( + controller: 'admin/users', action: 'create' + ) + expect(patch: '/admin/users/1').to route_to( + controller: 'admin/users', action: 'update', id: '1' + ) + expect(delete: '/admin/users/1').to route_to( + controller: 'admin/users', action: 'destroy', id: '1' + ) + end +end \ No newline at end of file diff --git a/spec/routing/board_routing_spec.rb b/spec/routing/board_routing_spec.rb new file mode 100644 index 00000000..d243f6aa --- /dev/null +++ b/spec/routing/board_routing_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +RSpec.describe 'board routing', :aggregate_failures, type: :routing do + it 'only routes the page to show a board' do + expect(get: '/boards/1').to route_to( + controller: 'boards', action: 'show', id: '1' + ) + + expect(get: '/boards').not_to be_routable + expect(get: '/boards/1/edit').not_to be_routable + expect(post: '/boards').not_to be_routable + expect(patch: '/boards/1').not_to be_routable + expect(delete: '/boards/1').not_to be_routable + end +end \ No newline at end of file