Improve routing tests

This commit is contained in:
riggraz
2019-09-27 14:41:54 +02:00
parent 970cd6934c
commit ccb63c4e16
4 changed files with 72 additions and 0 deletions

View File

@@ -30,6 +30,54 @@ RSpec.describe 'admin panel routing', :aggregate_failures, type: :routing do
)
end
it 'routes comments' do
expect(get: '/admin/comments').to route_to(
controller: 'admin/comments', action: 'index'
)
expect(get: '/admin/comments/1').to route_to(
controller: 'admin/comments', action: 'show', id: '1'
)
expect(get: '/admin/comments/new').to route_to(
controller: 'admin/comments', action: 'new'
)
expect(get: '/admin/comments/1/edit').to route_to(
controller: 'admin/comments', action: 'edit', id: '1'
)
expect(post: '/admin/comments').to route_to(
controller: 'admin/comments', action: 'create'
)
expect(patch: '/admin/comments/1').to route_to(
controller: 'admin/comments', action: 'update', id: '1'
)
expect(delete: '/admin/comments/1').to route_to(
controller: 'admin/comments', action: 'destroy', id: '1'
)
end
it 'routes posts' do
expect(get: '/admin/posts').to route_to(
controller: 'admin/posts', action: 'index'
)
expect(get: '/admin/posts/1').to route_to(
controller: 'admin/posts', action: 'show', id: '1'
)
expect(get: '/admin/posts/new').to route_to(
controller: 'admin/posts', action: 'new'
)
expect(get: '/admin/posts/1/edit').to route_to(
controller: 'admin/posts', action: 'edit', id: '1'
)
expect(post: '/admin/posts').to route_to(
controller: 'admin/posts', action: 'create'
)
expect(patch: '/admin/posts/1').to route_to(
controller: 'admin/posts', action: 'update', id: '1'
)
expect(delete: '/admin/posts/1').to route_to(
controller: 'admin/posts', action: 'destroy', id: '1'
)
end
it 'routes post statuses' do
expect(get: '/admin/post_statuses').to route_to(
controller: 'admin/post_statuses', action: 'index'

View File

@@ -7,6 +7,9 @@ RSpec.describe 'boards routing', :aggregate_failures, type: :routing do
)
expect(get: '/boards').not_to be_routable
expect(get: '/boards/new').not_to route_to(
controller: 'boards', action: 'new'
)
expect(get: '/boards/1/edit').not_to be_routable
expect(post: '/boards').not_to be_routable
expect(patch: '/boards/1').not_to be_routable

View File

@@ -0,0 +1,18 @@
require 'rails_helper'
RSpec.describe 'comments routing', :aggregate_failures, type: :routing do
it 'routes comments' do
expect(get: '/posts/1/comments').to route_to(
controller: 'comments', action: 'index', post_id: "1"
)
expect(post: '/posts/1/comments').to route_to(
controller: 'comments', action: 'create', post_id: "1"
)
expect(get: '/posts/1/comments/1').not_to be_routable
expect(get: '/posts/1/comments/new').not_to be_routable
expect(get: '/posts/1/comments/1/edit').not_to be_routable
expect(patch: '/posts/1/comments/1').not_to be_routable
expect(delete: '/posts/1/comments/1').not_to be_routable
end
end

View File

@@ -15,6 +15,9 @@ RSpec.describe 'posts routing', :aggregate_failures, type: :routing do
controller: 'posts', action: 'update', id: '1'
)
expect(get: '/posts/new').not_to route_to(
controller: 'posts', action: 'new'
)
expect(get: '/posts/1/edit').not_to be_routable
expect(delete: '/posts/1').not_to be_routable
end