Render participation feeds per SDG

This commit is contained in:
Javi Martín
2020-12-20 14:43:04 +01:00
parent fae52274a4
commit 2fcfa7ebd7
6 changed files with 44 additions and 3 deletions

View File

@@ -2790,7 +2790,8 @@ table {
// ------------
.home-page,
.custom-page {
.custom-page,
.sdg-goal-show {
a {

View File

@@ -1,7 +1,7 @@
.sdg-goal-show {
@include grid-row;
> * {
> :not(.feeds-participation) {
@include grid-column-gutter;
}

View File

@@ -8,4 +8,6 @@
<h1><%= goal.title %></h1>
</header>
</article>
<%= render Widgets::Feeds::ParticipationComponent.new(feeds) %>
</div>

View File

@@ -5,4 +5,8 @@ class SDG::Goals::ShowComponent < ApplicationComponent
def initialize(goal)
@goal = goal
end
def feeds
SDG::Widget::Feed.for_goal(goal)
end
end

View File

@@ -0,0 +1,17 @@
class SDG::Widget::Feed
attr_reader :feed, :goal
delegate :kind, to: :feed
def initialize(feed, goal)
@feed = feed
@goal = goal
end
def items
feed.items.by_goal(goal.code)
end
def self.for_goal(goal)
::Widget::Feed.active.map { |feed| new(feed, goal) }
end
end

View File

@@ -33,10 +33,27 @@ describe "SDG Goals", :js do
end
describe "Show" do
scenario "shows the SDG" do
scenario "shows the SDG and its related content" do
goal = SDG::Goal[15]
create(:debate, title: "Solar panels", sdg_goals: [SDG::Goal[7]])
create(:debate, title: "Hunting ground", sdg_goals: [goal])
create(:proposal, title: "Animal farm", sdg_goals: [goal])
create(:proposal, title: "Sea farm", sdg_goals: [SDG::Goal[14]])
visit sdg_goal_path(15)
within(".sdg-goal header") { expect(page).to have_content "Life on Land" }
within ".feed-proposals" do
expect(page).to have_content "Animal farm"
expect(page).not_to have_content "Sea farm"
end
within ".feed-debates" do
expect(page).to have_content "Hunting ground"
expect(page).not_to have_content "Solar panels"
end
end
end
end