Skip to content

Commit

Permalink
Fix admin edit bug with official proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
JoonasAapro committed Sep 30, 2024
1 parent 78cbdc0 commit 67904c5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def authors
authors = authors.flat_map do |klass, ids|
klass.constantize.where(id: ids)
end
@authors = authors.filter { |author| author.is_a?(Decidim::User) && !author.published_at.nil? }.compact.uniq
@authors = authors.filter { |author| !author.is_a?(Decidim::User) || author.published_at.present? }.compact.uniq
end
end
end
Expand Down
33 changes: 33 additions & 0 deletions spec/system/admin/proposals_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require "spec_helper"
require "decidim/privacy/test/rspec_support/component"

describe "Proposals" do
include ComponentTestHelper

let!(:organization) { create(:organization) }
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
let!(:user) { create(:user, :admin, :confirmed, organization:) }
let!(:proposal) { create(:proposal, :official, :published, component:) }

before do
switch_to_host(organization.host)
login_as user, scope: :user
visit decidim_admin.root_path
end

context "when trying to edit an official proposal" do
let!(:component) { create(:proposal_component, :with_creation_enabled, participatory_space: participatory_process) }

it "lets the admin user to edit" do
click_on "Processes"
click_on participatory_process.title["en"]
click_on "Proposals"
expect(page).to have_content(proposal.title["en"])
within("a.action-icon--edit-proposal") do
expect(page).to have_css('svg[aria-label="Edit proposal"]')
end
end
end
end

0 comments on commit 67904c5

Please sign in to comment.