mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
Improve routing tests
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
18
spec/routing/comments_routing_spec.rb
Normal file
18
spec/routing/comments_routing_spec.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user