-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We are able to request nested urlnames now as well. Before we only support top level urlnames.
- Loading branch information
Showing
6 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# frozen_string_literal: true | ||
Alchemy::JsonApi::Engine.routes.draw do | ||
resources :pages, only: [:show, :index] | ||
resources :layout_pages, only: [:show, :index] | ||
resources :pages, only: [:index] | ||
get "pages/*path" => "pages#show", as: :page | ||
resources :layout_pages, only: [:index] | ||
get "layout_pages/*path" => "layout_pages#show", as: :layout_page | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Page Routing" do | ||
routes { Alchemy::JsonApi::Engine.routes } | ||
|
||
it "routes layout_pages/" do | ||
expect(get: "/layout_pages").to route_to( | ||
controller: "alchemy/json_api/layout_pages", | ||
action: "index", | ||
) | ||
end | ||
|
||
it "routes layout_pages/:id" do | ||
expect(get: "/layout_pages/1").to route_to( | ||
controller: "alchemy/json_api/layout_pages", | ||
action: "show", | ||
path: "1", | ||
) | ||
end | ||
|
||
it "routes layout_pages/:urlname" do | ||
expect(get: "/layout_pages/a-page").to route_to( | ||
controller: "alchemy/json_api/layout_pages", | ||
action: "show", | ||
path: "a-page", | ||
) | ||
end | ||
|
||
it "routes layout_pages/:nested/urlname" do | ||
expect(get: "/layout_pages/a-nested/page").to route_to( | ||
controller: "alchemy/json_api/layout_pages", | ||
action: "show", | ||
path: "a-nested/page", | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Page Routing" do | ||
routes { Alchemy::JsonApi::Engine.routes } | ||
|
||
it "routes pages/" do | ||
expect(get: "/pages").to route_to( | ||
controller: "alchemy/json_api/pages", | ||
action: "index", | ||
) | ||
end | ||
|
||
it "routes pages/:id" do | ||
expect(get: "/pages/1").to route_to( | ||
controller: "alchemy/json_api/pages", | ||
action: "show", | ||
path: "1", | ||
) | ||
end | ||
|
||
it "routes pages/:urlname" do | ||
expect(get: "/pages/a-page").to route_to( | ||
controller: "alchemy/json_api/pages", | ||
action: "show", | ||
path: "a-page", | ||
) | ||
end | ||
|
||
it "routes pages/:nested/urlname" do | ||
expect(get: "/pages/a-nested/page").to route_to( | ||
controller: "alchemy/json_api/pages", | ||
action: "show", | ||
path: "a-nested/page", | ||
) | ||
end | ||
end |