Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove admin features from serializers #32

Merged
merged 1 commit into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/serializers/alchemy/json_api/element_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class ElementSerializer
end

has_many :nested_elements, record_type: :element, serializer: self

with_options if: ->(_, params) { params[:admin] == true } do
attribute :tag_list
attribute :display_name, &:display_name_with_preview_text
end
end
end
end
6 changes: 0 additions & 6 deletions app/serializers/alchemy/json_api/language_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ class LanguageSerializer
end
has_many :pages
has_one :root_page, record_type: :page, serializer: ::Alchemy::JsonApi::PageSerializer

with_options if: ->(_, params) { params[:admin] == true } do
attribute :created_at
attribute :updated_at
attribute :public
end
end
end
end
5 changes: 0 additions & 5 deletions app/serializers/alchemy/json_api/page_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class PageSerializer
has_many :all_elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |page|
page.all_elements.select { |e| e.public? && !e.trashed? }
end

with_options if: ->(_, params) { params[:admin] == true } do
attribute :tag_list
attribute :status
end
end
end
end
9 changes: 0 additions & 9 deletions spec/serializers/alchemy/json_api/element_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@
expect(subject[:deprecated]).to eq(true)
end
end

context "with admin set to true" do
let(:options) { { params: { admin: true } } }

it "includes admin-only attributes" do
expect(subject[:tag_list]).to eq(["Tag1", "Tag2"])
expect(subject[:display_name]).to eq("Article: ")
end
end
end

describe "relationships" do
Expand Down
11 changes: 0 additions & 11 deletions spec/serializers/alchemy/json_api/language_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@
expect(attributes[:country_code]).to eq("DE")
expect(attributes[:locale]).to eq("de")
end

context "with admin set to true" do
let(:options) { { params: { admin: true } } }

it "includes admin-only attributes" do
attributes = subject[:data][:attributes]
expect(attributes[:created_at]).to be_present
expect(attributes[:updated_at]).to be_present
expect(attributes[:public]).to be true
end
end
end

describe "relationships" do
Expand Down
16 changes: 0 additions & 16 deletions spec/serializers/alchemy/json_api/page_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,6 @@
expect(attributes[:updated_at]).to eq(page.updated_at)
expect(attributes.keys).not_to include(:tag_list, :status)
end

context "with admin set to true" do
let(:options) { { params: { admin: true } } }

it "includes admin-only attributes" do
attributes = subject[:data][:attributes]
expect(attributes[:tag_list]).to eq(["Tag1", "Tag2"])
expect(attributes[:status]).to eq(
{
public: false,
locked: false,
restricted: false,
},
)
end
end
end

describe "relationships" do
Expand Down