Skip to content

Commit

Permalink
Add the summary field to the project type in the API
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Dec 4, 2023
1 parent cbd6dbd commit 41ea783
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Api
module ProjectTypeExtensions
def self.included(type)
type.include Decidim::Stats::StatsTypeExtension
type.field :summary, Decidim::Core::TranslatedFieldType, "The summary for this project", null: true

return unless Decidim::BudgetingPipeline.possible_project_linked_resources.any?

Expand Down
16 changes: 16 additions & 0 deletions spec/types/decidim/budgets/project_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@
let(:proposal) { create(:proposal, component: proposals_component) }
let(:proposals_component) { create(:proposal_component, participatory_space: participatory_space) }

describe "summary" do
let(:query) { "{ summary { translations { text locale } } }" }

let(:response_summary) do
response["summary"]["translations"].to_h do |value|
[value["locale"], value["text"]]
end
end

it "returns the project summary" do
actual_summary = model.summary.except("machine_translations")
machine_translations = model.summary["machine_translations"]
expect(response_summary).to match(actual_summary.merge(machine_translations))
end
end

describe "linkedResources" do
let(:query) { "{ linkedResources { ...on Proposal { id } } }" }

Expand Down

0 comments on commit 41ea783

Please sign in to comment.