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

Fix miss-match of JSON structure with X-Gov metadata model #22

Merged
merged 1 commit into from
Mar 18, 2024
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/controllers/esdas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ class EsdasController < ApplicationController
before_action :set_esda, only: %i[show update destroy]
skip_before_action :verify_authenticity_token

# GET /esdas
# GET /esdas.json
def index
@esdas = Esda.all
end

# GET /esdas/1
# GET /esdas/1.json
def show; end

# POST /esdas
# POST /esdas.json
def create
@esda = Esda.new(metadata: params.dig(:esda, :metadata))
Expand All @@ -24,7 +21,6 @@ def create
end
end

# PATCH/PUT /esdas/1
# PATCH/PUT /esdas/1.json
def update
if @esda.update(esda_params)
Expand All @@ -34,7 +30,6 @@ def update
end
end

# DELETE /esdas/1
# DELETE /esdas/1.json
def destroy
@esda.destroy
Expand Down
2 changes: 1 addition & 1 deletion app/forms/creator_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class CreatorForm < BaseForm
validates :creator, presence: true

def update_item
item.metadata["creator"] = creator
item.metadata["creator"] = [creator]
end

def creator
Expand Down
2 changes: 1 addition & 1 deletion app/forms/publisher_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class PublisherForm < BaseForm
validates :publisher, presence: true

def update_item
item.metadata["publisher"] = [publisher]
item.metadata["publisher"] = publisher
end

def publisher
Expand Down
2 changes: 1 addition & 1 deletion app/forms/related_resource_form.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class RelatedResourceForm < BaseForm
def update_item
item.metadata["relatedResource"] = from_params(:related_resource)
item.metadata["relatedResource"] = [from_params(:related_resource)]
end
end
4 changes: 2 additions & 2 deletions spec/forms/creator_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
let(:creator_form) { described_class.new(item:, params:) }

describe "#save" do
it "saves the creator to metadata" do
it "saves the creator to metadata in an array" do
creator_form.save
expect(item.reload.metadata["creator"]).to eq(organisation)
expect(item.reload.metadata["creator"]).to eq([organisation])
end

context "with blank entry" do
Expand Down
4 changes: 2 additions & 2 deletions spec/forms/publisher_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
let(:creator_form) { described_class.new(item:, params:) }

describe "#save" do
it "saves the publisher to metadata in an array" do
it "saves the publisher to metadata" do
creator_form.save
expect(item.reload.metadata["publisher"]).to eq([organisation])
expect(item.reload.metadata["publisher"]).to eq(organisation)
end

context "with blank entry" do
Expand Down
4 changes: 2 additions & 2 deletions spec/forms/related_resource_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
let(:related_resource_form) { described_class.new(item:, params:) }

describe "#save" do
it "saves the related resource to metadata" do
it "saves the related resource to metadata in an array" do
related_resource_form.save
expect(item.reload.metadata["relatedResource"]).to eq(related_resource)
expect(item.reload.metadata["relatedResource"]).to eq([related_resource])
end

context "when title blank" do
Expand Down
Loading