Skip to content

Commit

Permalink
🐛 (component) show proposal,blog fails to serialize in prod mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadrien Froger committed Dec 14, 2024
1 parent 5ce5716 commit f553ca0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def index

def show
component_id = params.require(:id).to_i
component = find_components(Decidim::Component.where(id: component_id)).first!
component = find_components(Decidim::Component.where(id: component_id)).first
raise Decidim::RestFull::ApiException::NotFound, "Component not found" unless component

serializer = "Decidim::Api::RestFull::#{component.manifest_name.singularize.camelize}ComponentSerializer".constantize

render json: serializer.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.resources_for(component, act_as)
if act_as.nil?
resources.published
else
resources.published.or(resources.where(published_at: nil, decidim_user_id: params[:act_as].id))
resources.published.or(resources.where(published_at: nil, decidim_user_id: act_as.id))
end
end
has_many :resources, meta: (proc do |component, params|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.resources_for(component, act_as)
if act_as.nil?
resources.published
else
resources.published.or(resources.where(published_at: nil, decidim_user_id: params[:act_as].id))
resources.published.or(resources.where(published_at: nil, decidim_user_id: act_as.id))
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/decidim/rest_full/public/components_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
let(:"locales[]") { %w(en fr) }

let!(:api_client) { create(:api_client, organization: organization) }
let!(:impersonation_token) { create(:oauth_access_token, scopes: "public", resource_owner_id: nil, application: api_client) }
let(:Authorization) { "Bearer #{impersonation_token.token}" }
let!(:client_creds) { create(:oauth_access_token, scopes: "public", resource_owner_id: nil, application: api_client) }
let(:Authorization) { "Bearer #{client_creds.token}" }

before do
host! organization.host
Expand Down

0 comments on commit f553ca0

Please sign in to comment.