Skip to content

Commit

Permalink
Merge pull request #48 from AlchemyCMS/join-to-version
Browse files Browse the repository at this point in the history
Join to page version in PagesController
  • Loading branch information
tvdeyen authored Mar 29, 2021
2 parents 3baa217 + 15e9112 commit eb98fbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/controllers/alchemy/json_api/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def api_page(page)
def base_page_scope
# cancancan is not able to merge our complex AR scopes for logged in users
if can?(:edit_content, ::Alchemy::Page)
Alchemy::Page.all
Alchemy::Page.all.joins(page_version)
else
Alchemy::Page.published
Alchemy::Page.published.joins(page_version)
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/requests/alchemy/json_api/layout_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
end
end

it "finds the page" do
it "does not find the page" do
get alchemy_json_api.layout_page_path(page.urlname)
expect(response).to have_http_status(200)
expect(response).to have_http_status(404)
end
end
end
Expand Down Expand Up @@ -101,11 +101,11 @@
end
end

it "returns all layout pages" do
it "returns all published layout pages" do
get alchemy_json_api.layout_pages_path
document = JSON.parse(response.body)
expect(document["data"]).to include(have_id(layoutpage.id.to_s))
expect(document["data"]).to include(have_id(non_public_layout_page.id.to_s))
expect(document["data"]).not_to include(have_id(non_public_layout_page.id.to_s))
expect(document["data"]).not_to include(have_id(public_page.id.to_s))
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/requests/alchemy/json_api/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@
end
end

it "finds the page" do
it "does not find the page" do
get alchemy_json_api.page_path(page.urlname)
expect(response).to have_http_status(200)
expect(response).to have_http_status(404)
end
end
end
Expand Down Expand Up @@ -121,11 +121,11 @@
end
end

it "returns all content pages" do
it "returns all published content pages" do
get alchemy_json_api.pages_path
document = JSON.parse(response.body)
expect(document["data"]).not_to include(have_id(layoutpage.id.to_s))
expect(document["data"]).to include(have_id(non_public_page.id.to_s))
expect(document["data"]).not_to include(have_id(non_public_page.id.to_s))
expect(document["data"]).to include(have_id(public_page.id.to_s))
end
end
Expand Down

0 comments on commit eb98fbd

Please sign in to comment.