-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:decidim/decidim into chore/remov…
…e-secrets
- Loading branch information
Showing
155 changed files
with
3,349 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
decidim-accountability/app/cells/decidim/accountability/result_history_cell.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Accountability | ||
# This cell is used to render a result history panel of a resource | ||
# inside a tab of a show view | ||
# | ||
# The `model` must be an accountability result resource to get the history from. | ||
# | ||
# Example: | ||
# | ||
# cell( | ||
# "decidim/result_history", | ||
# result | ||
# ) | ||
class ResultHistoryCell < Decidim::ResourceHistoryCell | ||
include Decidim::Accountability::ApplicationHelper | ||
|
||
def linked_resources_items | ||
[ | ||
{ | ||
resources: @model.linked_resources(:proposals, "included_proposals"), | ||
|
||
link_name: "included_proposals", | ||
text_key: "decidim.accountability.result.proposal_ids", | ||
icon_key: "Decidim::Proposals::Proposal" | ||
}, | ||
{ | ||
resources: @model.linked_resources(:projects, "included_projects"), | ||
link_name: "included_projects", | ||
text_key: "decidim.accountability.result.project_ids", | ||
icon_key: "Decidim::Budgets::Project" | ||
}, | ||
{ | ||
resources: @model.linked_resources(:meetings, "meetings_through_proposals"), | ||
link_name: "meetings_through_proposals", | ||
text_key: "decidim.accountability.result.meetings_ids", | ||
icon_key: "Decidim::Meetings::Meeting" | ||
} | ||
] | ||
end | ||
|
||
def creation_item | ||
{ | ||
id: "result_creation", | ||
date: @model.created_at, | ||
text: t("decidim.accountability.creation.text"), | ||
icon: resource_type_icon_key("Decidim::Accountability::Result") | ||
} | ||
end | ||
|
||
def history_cell_id | ||
"result" | ||
end | ||
end | ||
end | ||
end |
4 changes: 1 addition & 3 deletions
4
decidim-accountability/app/views/decidim/accountability/results/_project.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
decidim-accountability/spec/cells/decidim/accountability/result_history_cell_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim::Accountability | ||
describe ResultHistoryCell, type: :cell do | ||
controller Decidim::Accountability::ResultsController | ||
|
||
let!(:result) { create(:result) } | ||
let(:participatory_space) { result.participatory_space } | ||
let(:component) { create(:accountability_component) } | ||
let(:organization) { result.organization } | ||
let(:user) { create(:user, organization: result.participatory_space.organization) } | ||
|
||
before do | ||
allow(controller).to receive(:current_user).and_return(user) | ||
end | ||
|
||
context "when the result has linked resources" do | ||
context "when result has been linked in a proposal" do | ||
let(:proposal_component) do | ||
create(:component, manifest_name: :proposals, participatory_space: result.component.participatory_space) | ||
end | ||
let(:proposal) { create(:proposal, component: proposal_component) } | ||
|
||
before do | ||
proposal.link_resources([result], "included_proposals") | ||
end | ||
|
||
it "shows related proposals" do | ||
html = cell("decidim/accountability/result_history", result).call | ||
expect(html).to have_content("It was included in this proposal:") | ||
end | ||
end | ||
|
||
context "when a result has been linked in a project" do | ||
let(:budget_component) do | ||
create(:component, manifest_name: :budgets, participatory_space: result.component.participatory_space) | ||
end | ||
let(:project) { create(:project, component: budget_component) } | ||
|
||
before do | ||
project.link_resources([result], "included_projects") | ||
end | ||
|
||
it "shows related projects" do | ||
html = cell("decidim/accountability/result_history", result).call | ||
expect(html).to have_content("It was included in this project:") | ||
end | ||
end | ||
|
||
context "when a result has been linked in a meeting" do | ||
let(:meeting_component) do | ||
create(:component, manifest_name: :meetings, participatory_space: result.component.participatory_space) | ||
end | ||
let(:meeting) { create(:meeting, :published, component: meeting_component) } | ||
|
||
before do | ||
meeting.link_resources([result], "meetings_through_proposals") | ||
end | ||
|
||
it "shows related meetings" do | ||
html = cell("decidim/accountability/result_history", result).call | ||
expect(html).to have_content("It was discussed in this meeting:") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.