diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss
index b9871047a..996c2c036 100644
--- a/app/assets/stylesheets/layout.scss
+++ b/app/assets/stylesheets/layout.scss
@@ -2790,7 +2790,8 @@ table {
// ------------
.home-page,
-.custom-page {
+.custom-page,
+.sdg-goal-show {
a {
diff --git a/app/assets/stylesheets/sdg/goals/show.scss b/app/assets/stylesheets/sdg/goals/show.scss
index 8e1d6cf9f..5023e3743 100644
--- a/app/assets/stylesheets/sdg/goals/show.scss
+++ b/app/assets/stylesheets/sdg/goals/show.scss
@@ -1,7 +1,7 @@
.sdg-goal-show {
@include grid-row;
- > * {
+ > :not(.feeds-participation) {
@include grid-column-gutter;
}
diff --git a/app/components/sdg/goals/show_component.html.erb b/app/components/sdg/goals/show_component.html.erb
index 9bdf4b1e2..e316e2ddc 100644
--- a/app/components/sdg/goals/show_component.html.erb
+++ b/app/components/sdg/goals/show_component.html.erb
@@ -8,4 +8,6 @@
<%= goal.title %>
+
+ <%= render Widgets::Feeds::ParticipationComponent.new(feeds) %>
diff --git a/app/components/sdg/goals/show_component.rb b/app/components/sdg/goals/show_component.rb
index c7f17335a..07bdff277 100644
--- a/app/components/sdg/goals/show_component.rb
+++ b/app/components/sdg/goals/show_component.rb
@@ -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
diff --git a/app/models/sdg/widget/feed.rb b/app/models/sdg/widget/feed.rb
new file mode 100644
index 000000000..445af5e69
--- /dev/null
+++ b/app/models/sdg/widget/feed.rb
@@ -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
diff --git a/spec/system/sdg/goals_spec.rb b/spec/system/sdg/goals_spec.rb
index 2b0ba6030..277fe0eb0 100644
--- a/spec/system/sdg/goals_spec.rb
+++ b/spec/system/sdg/goals_spec.rb
@@ -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