-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2258 from tvdeyen/allow-all-pages-in-api-again
Allow all pages in API again
- Loading branch information
Showing
6 changed files
with
163 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
<div class="page-select--page"> | ||
<i class="icon far fa-file fa-lg"></i> | ||
<span class="page-select--page-name"> | ||
{{ page.name }} | ||
</span> | ||
<span class="page-select--page-urlname"> | ||
{{ page.url_path }} | ||
</span> | ||
<div class="page-select--top"> | ||
<i class="icon far fa-file fa-lg"></i> | ||
<span class="page-select--page-name"> | ||
{{ page.name }} | ||
</span> | ||
<span class="page-select--page-urlname"> | ||
{{ page.url_path }} | ||
</span> | ||
</div> | ||
<div class="page-select--bottom"> | ||
<span class="page-select--site-name"> | ||
{{ page.site.name }} | ||
</span> | ||
<span class="page-select--language-code"> | ||
{{ page.language.name }} | ||
</span> | ||
</div> | ||
</div> |
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
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,87 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe Alchemy::PageSerializer do | ||
subject do | ||
described_class.new(page, scope: Alchemy::Permissions.new(user)).to_json | ||
end | ||
|
||
let(:page) { build_stubbed(:alchemy_page) } | ||
|
||
context "for guest user" do | ||
let(:user) { nil } | ||
|
||
it "includes public attributes" do | ||
json = JSON.parse(subject) | ||
expect(json).to match( | ||
"id" => page.id, | ||
"name" => page.name, | ||
"urlname" => page.urlname, | ||
"page_layout" => page.page_layout, | ||
"title" => page.title, | ||
"language_code" => page.language_code, | ||
"meta_keywords" => page.meta_keywords, | ||
"meta_description" => page.meta_description, | ||
"tag_list" => page.tag_list, | ||
"created_at" => an_instance_of(String), | ||
"updated_at" => an_instance_of(String), | ||
"status" => page.status.transform_keys(&:to_s), | ||
"url_path" => page.url_path, | ||
"parent_id" => page.parent_id, | ||
"elements" => [], | ||
) | ||
end | ||
end | ||
|
||
context "for admin user" do | ||
let(:user) { build_stubbed(:alchemy_dummy_user, :as_author) } | ||
|
||
it "includes all attributes" do | ||
json = JSON.parse(subject) | ||
expect(json).to match( | ||
"id" => page.id, | ||
"name" => page.name, | ||
"urlname" => page.urlname, | ||
"page_layout" => page.page_layout, | ||
"title" => page.title, | ||
"language_code" => page.language_code, | ||
"meta_keywords" => page.meta_keywords, | ||
"meta_description" => page.meta_description, | ||
"tag_list" => page.tag_list, | ||
"created_at" => an_instance_of(String), | ||
"updated_at" => an_instance_of(String), | ||
"status" => page.status.transform_keys(&:to_s), | ||
"url_path" => page.url_path, | ||
"parent_id" => page.parent_id, | ||
"elements" => [], | ||
"site" => { | ||
"id" => page.site.id, | ||
"aliases" => nil, | ||
"created_at" => an_instance_of(String), | ||
"host" => "*", | ||
"name" => "Default Site", | ||
"public" => true, | ||
"redirect_to_primary_host" => false, | ||
"updated_at" => an_instance_of(String), | ||
}, | ||
"language" => { | ||
"country_code" => "", | ||
"created_at" => an_instance_of(String), | ||
"creator_id" => nil, | ||
"default" => true, | ||
"frontpage_name" => "Intro", | ||
"id" => page.language_id, | ||
"language_code" => "en", | ||
"locale" => "en", | ||
"name" => "Your Language", | ||
"page_layout" => "index", | ||
"public" => true, | ||
"site_id" => page.site.id, | ||
"updated_at" => an_instance_of(String), | ||
"updater_id" => nil, | ||
}, | ||
) | ||
end | ||
end | ||
end |